Created
December 17, 2013 15:28
-
-
Save metakermit/8006735 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys,os | |
def decodeSpeech(hmmd,lmdir,dictp,wavfile): | |
""" | |
Decodes a speech file | |
""" | |
try: | |
import pocketsphinx as ps | |
import sphinxbase | |
except: | |
print """Pocket sphinx and sphixbase is not installed | |
in your system. Please install it with package manager. | |
""" | |
speechRec = ps.Decoder(hmm = hmmd, lm = lmdir, dict = dictp) | |
wavFile = file(wavfile,'rb') | |
wavFile.seek(44) | |
speechRec.decode_raw(wavFile) | |
result = speechRec.get_hyp() | |
return result[0] | |
if __name__ == "__main__": | |
hmdir = "/usr/share/pocketsphinx/model/hmm/wsj1" | |
lmd = "/usr/share/pocketsphinx/model/lm/wsj/wlist5o.3e-7.vp.tg.lm.DMP" | |
dictd = "/usr/share/pocketsphinx/model/lm/wsj/wlist5o.dic" | |
wavfile = sys.argv[1] | |
recognised = decodeSpeech(hmdir,lmd,dictd,wavfile) | |
print "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" | |
print recognised | |
print "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment