Skip to content

Commit

Permalink
examples unix version
Browse files Browse the repository at this point in the history
  • Loading branch information
William Campbell committed Apr 21, 2017
1 parent 01a07cc commit 35a3fdc
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 82 deletions.
82 changes: 41 additions & 41 deletions examples/example_gsv.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
#!/usr/bin/env python

import json

from pyslgr.GMMModel import GMMSAD
from pyslgr.GSV import GSV
from pyslgr.LLSignal import LLSignal
from pyslgr.MFCCFeatures import MFCCFeatures
from pyslgr.FeatPipe import FeatPipe
from pyslgr.sad import XtalkSAD

if __name__ == "__main__":

# Load example signal
fn = 'signals/example.sph'
x = LLSignal()
x.load_sph(fn, 0)

# Initialize feature pipe
mfcc_pipe_fn = "config/sid_mfcc+gmmsad_pipe.json"
with open(mfcc_pipe_fn, 'r') as fp:
pipe_config = json.load(fp)
fpipe = FeatPipe(pipe_config, MFCCFeatures, GMMSAD)

# Get MFCCFeatures
f = fpipe.process(x)

# Info
print 'Number of output features: {}'.format(f.num_outfeat())
# f.save_raw('tmp/gsv_feat.dat')

# Load in and create GSV
with open('config/gsv.json', 'r') as fp:
config = json.load(fp)
gsv = GSV(config)

# Now compute a GSV expansion
v = gsv.process(f)
print 'A few elements of GSV expansion: {}'.format(v[0:10])
print 'GSV expansion dimension = {}'.format(len(v))

#!/usr/bin/env python

import json

from pyslgr.GMMModel import GMMSAD
from pyslgr.GSV import GSV
from pyslgr.LLSignal import LLSignal
from pyslgr.MFCCFeatures import MFCCFeatures
from pyslgr.FeatPipe import FeatPipe
from pyslgr.sad import XtalkSAD

if __name__ == "__main__":

# Load example signal
fn = 'signals/example.sph'
x = LLSignal()
x.load_sph(fn, 0)

# Initialize feature pipe
mfcc_pipe_fn = "config/sid_mfcc+gmmsad_pipe.json"
with open(mfcc_pipe_fn, 'r') as fp:
pipe_config = json.load(fp)
fpipe = FeatPipe(pipe_config, MFCCFeatures, GMMSAD)

# Get MFCCFeatures
f = fpipe.process(x)

# Info
print 'Number of output features: {}'.format(f.num_outfeat())
# f.save_raw('tmp/gsv_feat.dat')

# Load in and create GSV
with open('config/gsv.json', 'r') as fp:
config = json.load(fp)
gsv = GSV(config)

# Now compute a GSV expansion
v = gsv.process(f)
print 'A few elements of GSV expansion: {}'.format(v[0:10])
print 'GSV expansion dimension = {}'.format(len(v))

print 'Done! Successfully completed GSV tests'
82 changes: 41 additions & 41 deletions examples/example_ivec.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
#!/usr/bin/env python

import json

from pyslgr.GMMModel import GMMSAD
from pyslgr.iVector import iVector
from pyslgr.LLSignal import LLSignal
from pyslgr.MFCCFeatures import MFCCFeatures
from pyslgr.FeatPipe import FeatPipe
import sys

if __name__ == "__main__":

# Load example signal
fn = 'signals/example.sph'
x = LLSignal()
x.load_sph(fn, 0)

# Initialize feature pipe
mfcc_pipe_fn = "config/sid_mfcc+gmmsad_pipe.json"
with open(mfcc_pipe_fn, 'r') as fp:
pipe_config = json.load(fp)
fpipe = FeatPipe(pipe_config, MFCCFeatures, GMMSAD)

# Get MFCCFeatures
f = fpipe.process(x)

# Info
print 'Number of output features: {}'.format(f.num_outfeat())
# f.save_raw('tmp/ivec_feat.dat')

# Load in and create ivector
with open('config/ivec.json', 'r') as fp:
config = json.load(fp)
ivec = iVector(config)

# Now compute an ivector
v = ivec.process(f)
print 'A few elements of iVector: {}'.format(v[0:10])
print 'iVector dimension = {}'.format(len(v))

#!/usr/bin/env python

import json

from pyslgr.GMMModel import GMMSAD
from pyslgr.iVector import iVector
from pyslgr.LLSignal import LLSignal
from pyslgr.MFCCFeatures import MFCCFeatures
from pyslgr.FeatPipe import FeatPipe
import sys

if __name__ == "__main__":

# Load example signal
fn = 'signals/example.sph'
x = LLSignal()
x.load_sph(fn, 0)

# Initialize feature pipe
mfcc_pipe_fn = "config/sid_mfcc+gmmsad_pipe.json"
with open(mfcc_pipe_fn, 'r') as fp:
pipe_config = json.load(fp)
fpipe = FeatPipe(pipe_config, MFCCFeatures, GMMSAD)

# Get MFCCFeatures
f = fpipe.process(x)

# Info
print 'Number of output features: {}'.format(f.num_outfeat())
# f.save_raw('tmp/ivec_feat.dat')

# Load in and create ivector
with open('config/ivec.json', 'r') as fp:
config = json.load(fp)
ivec = iVector(config)

# Now compute an ivector
v = ivec.process(f)
print 'A few elements of iVector: {}'.format(v[0:10])
print 'iVector dimension = {}'.format(len(v))

print 'Done! Successfully completed iVector tests'

0 comments on commit 35a3fdc

Please sign in to comment.