2016-03-19 20 views
3

BenNeden Python pocketsphinx, TypeError veriyor?

https://metakermit.com/2011/python-speech-recognition-helloworld/

(tam burada koduna) 'e göre, Python cep sfenks öğretici kullanıyorum:

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 "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" 

ve bunu çalıştırdığınızda aşağıdaki hata iletisi alıyorum:

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' 

Yardımcı olabilir misiniz?

+0

onay Ne argüman yapabilirsiniz geçmiş Düzenlendi @galaxyan __init__ – galaxyan

+0

için. İstasyon için üzgünüm. – Hugo

+0

Hatasız, hmm'nin init – galaxyan

cevap

8

GitHub'daki pocketsphinx koduna bakarak, decoder_test.py'da, seçeneklerin Decoder'a nasıl iletileceğine bir örnek var.

Yani sizin öğretici eski sürümüne yöneliktir ve gerçekten istediğiniz şekilde görünür:

config = ps.Decoder.default_config() 
config.set_string('-hmm', hmmd) 
config.set_string('-lm', lmdir) 
config.set_string('-dict', dictp) 

speechRec = ps.Decoder(config)