2016-08-14 68 views
1

我用pocketsphinx python使用樹莓派,我發現一個例子here。從該腳本中,我使用腳本中描述的相同路徑。當我嘗試運行此腳本時,它給我一個錯誤:Pocketsphinx解碼器初始化返回-1

ERROR: "acmod.c", line 83: Folder 'deps/pocketsphinx/model/en-us/en-us' does not contain acoustic model definition 'mdef' 
Traceback (most recent call last): 
    File "test.py", line 15, in <module> 
    decoder = ps.Decoder(config) 
    File "/usr/local/lib/python2.7/dist-packages/pocketsphinx/pocketsphinx.py", line 271, in __init__ 
    this = _pocketsphinx.new_Decoder(*args) 
RuntimeError: new_Decoder returned -1 

有誰知道問題是什麼?

回答

1

更好地使用絕對路徑,例如:如果你的「DEPS」目前下一個「/ home/PI」目錄,然後你的代碼看起來像下面:

MODELDIR = '/home/pi/deps/pocketsphinx/model' 
DATADIR = '/home/pi/deps/pocketsphinx/test/data' 

# Create a decoder with certain model 
config = ps.Decoder.default_config() 
config.set_string('-hmm', os.path.join(MODELDIR, 'en-us/en-us')) 
config.set_string('-lm', os.path.join(MODELDIR, 'en-us/en-us.lm.bin')) 

config.set_string('-dict', os.path.join(MODELDIR, 'en-us/cmudict-en-us.dict')) 
decoder = ps.Decoder(config) 
+0

感謝您的答覆。但是dir pocketsphinx在我的根目錄/ pocketsphinx/tests test.py – input

+0

昨天你在CMUSphinx論壇中提出了類似的問題,你不明白答案。 https://sourceforge.net/p/cmusphinx/discussion/help/thread/afac44ac/ – G10DRAS

+0

我在CMUSphinx論壇中詢問的問題與我現在的腳本不同。但我相信我的道路是正確的。我認爲它與deps/pocketsphinx/model/en-us/en-us有關'不包含聲學模型定義'mdef'但是我看着我們-en/us-en en de mdef文件就在那裏。 – input