This is in reference to the link you have given in the question description.
I had a similar problem which was due to the fact that 'pocketsphinx' library do not have the files en-us.lm.bin and cmudict-en-us.dict by default.
It was solved by downloading the files and pasting them to correct location and giving the correct path:
P.S.: Make sure your PocketSphinx is up-to-date. You can install/update it by executing pip install pocketsphinx
on terminal.
Detailed steps are given below:
STEP-1: Giving the correct path
Get the MODELDIR by:
MODELDIR= get_model_path()
STEP-2: Download the files en-us.lm.bin and cmudict-en-us.dict
Download 'en-us.lm.bin' file from:
https://github.com/cmusphinx/sphinx4/tree/master/sphinx4-data/src/main/resources/edu/cmu/sphinx/models/en-us
Download 'cmudict-en-us.dict' file from: https://github.com/cmusphinx/sphinx4/blob/master/sphinx4-data/src/main/resources/edu/cmu/sphinx/models/en-us/cmudict-en-us.dict
STEP-3: Pasting the files to correct location.
Paste the downloaded files to the directory given by: (MODELDIR + '/en-us/')
It should be something like this: C:\Users\Username\Anaconda3\Lib\site-packages\pocketsphinx\model\en-us
STEP-4: Modifying the code
The link you have given has the following code:
config = Decoder.default_config()
config.set_string('-hmm', path.join(MODELDIR, 'en-us/en-us'))
config.set_string('-lm', path.join(MODELDIR, 'en-us/en-us.lm.bin'))
config.set_string('-dict', path.join(MODELDIR, 'en-us/cmudict-en-us.dict'))
decoder = Decoder(config)
Make sure the directory MODELDIR + 'en-us/en-us'
actually exists.
In my case, the directory was just till MODELDIR + '/en-us'
.
If this is the case, modify the above code with correct directory:
config = Decoder.default_config()
config.set_string('-hmm', path.join(MODELDIR, 'en-us'))
config.set_string('-lm', path.join(MODELDIR, 'en-us/en-us.lm.bin'))
config.set_string('-dict', path.join(MODELDIR, 'en-us/cmudict-en-us.dict'))
decoder = Decoder(config)
Hope this helps :)