We need to install the sphinx packages before we can proceed with it:
The packages can be installed from Ubuntu Software center or via apt-get.
$ sudo apt-get install python-pocketsphinx $ sudo apt-get install pocketsphinx-hmm-wsj1 $ sudo apt-get install pocketsphinx-lm-wsj
Once you are done we can move on with out python script for speech recognition.
Have a voice recorded WAV file in the directory where you are running the python script. You can record voice by your fav voice recorder software.
#!/usr/bin/ python import sys import pocketsphinx if __name__ == "__main__": hmdir = "/usr/share/pocketsphinx/model/hmm/wsj1" lmdir = "/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 speechRec = pocketsphinx.Decoder(hmm = hmdir, lm = lmdir, dict = dictd) wavFile = file(wavfile,'rb') speechRec.decode_raw(wavFile) result = speechRec.get_hyp() print result
$ python pythonPocketSphinxTest.py sndClip.wav
Note: sndClip.wav is my voice recorded file, and lies in the same folder as the script pythonPocketSphinxTest.
'LITTLE WHO FALLS MORE IN THE IN THE FULL AND WHO IS NEWS UNLIKE TO THE USE THAN THIS SO ALL HER WHOSE'
Yash Sharma is a Big Data & Machine Learning Engineer, A newbie OpenSource contributor, Plays guitar and enjoys teaching as part time hobby.
Talk to Yash about Distributed Systems and Data platform designs.