2014-08-31 115 views
0

我想在Ubuntu 14.04LTS和Python 2.7中运行pocketsphinx 012,pocketsphinx & sphenixbase是从最新的git源代码编译而来的。当我试图运行我收到以下错误代码:pocketsphinx越来越错误AttributeError:get_hyp

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 
+0

它只是'hyp',没有'get_'前缀。 – 2014-08-31 12:14:16

回答

1

hyp,不get_hyp。您可以在pocketsphinx发行版的swig/python/test目录中找到几个代码示例。