Pocketsphinx解码器初始化返回-1

时间:2016-08-14 10:44:51

标签: python pocketsphinx

我使用raspphinx python的raspberry pi,我找到了一个例子here。从该脚本我使用与脚本中描述的相同的路径。当我尝试运行此脚本时,它会给我一个错误:

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

有谁知道问题是什么?

1 个答案:

答案 0 :(得分:3)

更好地使用绝对路径,例如:如果你的'deps'目录出现在'/ home / pi'下,那么你的代码将如下所示:

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)
相关问题