pocketsphinx获取错误AttributeError:get_hyp

时间:2014-08-31 11:13:40

标签: python python-2.7 cmusphinx

我正在尝试在Ubuntu 14.04LTS和python 2.7中运行pocketsphinx pocketsphinx& sphenixbase是从最新的git源编译而来的。当我试图运行代码时,我遇到了以下错误:

Traceback (most recent call last):
  File "test.py", line 28, in <module>
    hyp, uttid, score = speechRec.get_hyp()
  File "/usr/local/lib/python2.7/dist-packages/pocketsphinx/pocketsphinx.py", line 252, in <lambda>
    __getattr__ = lambda self, name: _swig_getattr(self, Decoder, name)
  File "/usr/local/lib/python2.7/dist-packages/pocketsphinx/pocketsphinx.py", line 75, in _swig_getattr
    raise AttributeError(name)
AttributeError: get_hyp

我正在尝试执行的代码:

#!/usr/bin/ python

import sys
import pocketsphinx

if __name__ == "__main__":

   hmdir = "./lang/model/en_us"
   lmdir = "./lang/etc/cmusphinx-5.0-en-us.lm.dmp"
   dictd = "./lang/etc/cmu07a.dic"
   wavfile = sys.argv[1]

   config = pocketsphinx.Decoder.default_config()
   config.set_string('-hmm', hmdir)
   config.set_string('-lm', lmdir)
   config.set_string('-dict', dictd)

   speechRec = pocketsphinx.Decoder(config)
   audioFile = file(wavfile, 'rb')
   speechRec.decode_raw(audioFile)
   hyp, uttid, score = speechRec.get_hyp()

   print 'Got result'+ hyp+'score'+score

1 个答案:

答案 0 :(得分:1)

它是hyp,而不是get_hyp。您可以在pocketsphinx发行版的swig/python/test目录中找到一些代码示例。