From 35a3fdcca54aa2ceaa48cf29549293b5389dd82a Mon Sep 17 00:00:00 2001 From: William Campbell Date: Fri, 21 Apr 2017 18:49:35 -0400 Subject: [PATCH] examples unix version --- examples/example_gsv.py | 82 ++++++++++++++++++++-------------------- examples/example_ivec.py | 82 ++++++++++++++++++++-------------------- 2 files changed, 82 insertions(+), 82 deletions(-) diff --git a/examples/example_gsv.py b/examples/example_gsv.py index 2e362f5..582b9ae 100755 --- a/examples/example_gsv.py +++ b/examples/example_gsv.py @@ -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' \ No newline at end of file diff --git a/examples/example_ivec.py b/examples/example_ivec.py index 194770b..0d78e4f 100755 --- a/examples/example_ivec.py +++ b/examples/example_ivec.py @@ -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' \ No newline at end of file