我已经安装了最新版本的 pocketsphinx 和 sphinxbase (0.8)。我尝试将 pocketsphinx 导入 python 代码(Python 3.4.2 版)并像这样使用“解码器”:
try:
import sphinxbase
import pocketsphinx as ps
except:
print ("Pocket sphinx and sphixbase is not installed in your system.
Please install it with package manager.")
speechRec = ps.Decoder(hmm = hmmd, lm = lmdir, dict = dictp, beam = '1e-80')
wavFile = file(wavfile,'rb')
wavFile.seek(44)
speechRec.decode_raw(wavFile)
但是,我收到以下错误:
AttributeError: 'module' object has no attribute 'Decoder'
有人知道这是怎么回事吗?
请您参考如下方法:
正如 Bhargav 已经提到的,您已将文件命名为 pocketsphinx.py 或路径中有一个 pocketsphinx.py,因此您需要重命名该文件并确保同时删除 pocketsphinx.pyc 文件。您正在尝试从该文件而不是 pocketsphinx 模块导入。
