【发布时间】:2016-03-19 18:35:37
【问题描述】:
我正在使用 Python 袖珍狮身人面像教程,根据
https://metakermit.com/2011/python-speech-recognition-helloworld/
(此处为完整代码):
import sys,os
def decodeSpeech(hmmd,lmdir,dictp,wavfile):
"""
Decodes a speech file
"""
try:
import pocketsphinx as ps
import sphinxbase
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)
wavFile = file(wavfile,'rb')
wavFile.seek(44)
speechRec.decode_raw(wavFile)
result = speechRec.get_hyp()
return result[0]
if __name__ == "__main__":
hmdir = "/usr/share/pocketsphinx/model/hmm/en_US/"
lmd = "/usr/share/pocketsphinx/model/lm/en_US/hub4.5000.DMP"
dictd = "/usr/share/pocketsphinx/model/lm/en_US/cmu07a.dic"
wavfile = sys.argv[1]
recognised = decodeSpeech(hmdir,lmd,dictd,wavfile)
print "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
print recognised
print "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
当我运行它时,我收到以下错误消息:
Traceback (most recent call last):
File "hello.py", line 30, in <module>
recognised = decodeSpeech(hmdir,lmd,dictd,wavfile)
File "hello.py", line 17, in decodeSpeech
speechRec = ps.Decoder(hmm = hmmd, lm = lmdir, dict = dictp)
TypeError: __init__() got an unexpected keyword argument 'hmm'
你能帮帮我吗?
【问题讨论】:
-
检查您可以将什么参数传递给 init
-
@galaxyan 已编辑。很抱歉身份识别。
-
我的意思是错误告诉你,嗯不是你可以在 init 中传递的参数
-
从我在example file bundled with the project 中可以看到,
Decoder()类只需要一个config参数。我怀疑您的教程已过时,请查找其他教程。 -
如果你这样做
help(ps.Decoder),它是否提到了它所需要的论点?正如 Martijn Pieters 所说,您的教程可能是针对不同版本的。
标签: python pocketsphinx