【问题标题】:New Decoder Returned -1 When trying to run PocketSphinx on Raspberry pi尝试在 Raspberry pi 上运行 PocketSphinx 时,新解码器返回 -1
【发布时间】:2017-06-03 01:09:30
【问题描述】:

我正在尝试让 pocketsphinx 在我的 raspberrypi 3 上工作。我已经成功地将它安装在我的 rpi 上,但现在它无法正常运行。我正在使用他们为 github 上的 python 模块提供的示例代码,但是每当我尝试运行它时,都会出现此错误

Traceback (most recent call last):
 File "/home/pi/VoiceTesting/SphinxTest.py", line 14, in <module>
decoder = Decoder(config)
File "/usr/local/lib/python3.4/dist-packages/pocketsphinx/pocketsphinx.py", line 228, in __init__
this = _pocketsphinx.new_Decoder(*args)
RuntimeError: new_Decoder returned -1

我已经做了一些谷歌搜索,但我无法找到解决方案。 here 是 pocketsphinx github 上示例代码的链接。我没有编辑任何内容,我只是复制并粘贴了它。

【问题讨论】:

标签: python raspberry-pi pocketsphinx


【解决方案1】:

这是参考您在问题描述中给出的link

我遇到了类似的问题,这是因为“pocketsphinx”库没有文件 en-us.lm.bincmudict-en-us.dict 默认情况下。

通过下载文件并将它们粘贴到正确的位置并提供正确的路径解决了这个问题:

P.S.:确保您的 PocketSphinx 是最新的。您可以通过在终端上执行pip install pocketsphinx 来安装/更新它。

详细步骤如下:

STEP-1:给出正确的路径

通过以下方式获取 MODELDIR:

MODELDIR= get_model_path()

第 2 步: 下载文件 en-us.lm.bin 和 cmudict-en-us.dict

从以下位置下载“en-us.lm.bin”文件: https://github.com/cmusphinx/sphinx4/tree/master/sphinx4-data/src/main/resources/edu/cmu/sphinx/models/en-us

从以下位置下载“cmudict-en-us.dict”文件:https://github.com/cmusphinx/sphinx4/blob/master/sphinx4-data/src/main/resources/edu/cmu/sphinx/models/en-us/cmudict-en-us.dict

第 3 步:将文件粘贴到正确的位置。

将下载的文件粘贴到(MODELDIR + '/en-us/')给出的目录中

应该是这样的:C:\Users\Username\Anaconda3\Lib\site-packages\pocketsphinx\model\en-us

STEP-4:修改代码

你给的link有如下代码:

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)

确保目录MODELDIR + 'en-us/en-us' 确实存在。

在我的例子中,目录直到MODELDIR + '/en-us'

如果是这种情况,用正确的目录修改上面的代码:

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)

希望这会有所帮助:)

【讨论】:

  • 你太棒了 :) 我从 github 错误中得到了这个答案 :) 感谢您的回答
  • @Ashu 我很高兴听到这个消息。如果有任何帮助,请支持我的回答:)
猜你喜欢
  • 2022-12-17
  • 2019-08-02
  • 1970-01-01
  • 1970-01-01
  • 2014-06-12
  • 1970-01-01
  • 2023-04-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多