Pocketsphinx decoder initialization returns -1

我的未来我决定 提交于 2019-12-17 14:59:02

问题


I use the raspberry pi with pocketsphinx python and I found an example here. From that script I use the same path as described in the script. When I try to run this script it give me an error:

ERROR: "acmod.c", line 83: Folder 'deps/pocketsphinx/model/en-us/en-us' does not contain acoustic model definition 'mdef'
Traceback (most recent call last):
  File "test.py", line 15, in <module>
    decoder = ps.Decoder(config)
  File "/usr/local/lib/python2.7/dist-packages/pocketsphinx/pocketsphinx.py", line 271, in __init__
    this = _pocketsphinx.new_Decoder(*args)
RuntimeError: new_Decoder returned -1

Does anyone know what the problem is?


回答1:


Better use absolute path, for ex: if your 'deps' dir present under '/home/pi' then your code will looks like below:

MODELDIR = '/home/pi/deps/pocketsphinx/model'
DATADIR = '/home/pi/deps/pocketsphinx/test/data'

# Create a decoder with certain model
config = ps.Decoder.default_config()
config.set_string('-hmm', os.path.join(MODELDIR, 'en-us/en-us'))
config.set_string('-lm', os.path.join(MODELDIR, 'en-us/en-us.lm.bin'))

config.set_string('-dict', os.path.join(MODELDIR, 'en-us/cmudict-en-us.dict'))
decoder = ps.Decoder(config)


来源:https://stackoverflow.com/questions/38941443/pocketsphinx-decoder-initialization-returns-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!