Python pocketsphinx'模块'对象没有属性'解码器'

时间:2015-04-12 19:57:07

标签: python speech-recognition cmusphinx decoder pocketsphinx

我尝试运行使用pocketsphinx的简单示例。我已经安装了所有需要的插件库...... Python 2.7.6。但仍然会出错:

  

pocketsphinx'模块'对象没有属性'解码器'

import sys,os 
import pocketsphinx as ps 
import sphinxbase


def decodeSpeech(hmmd,lmdir,dictp,wavfile):
    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/wsj1'
    lmd   = '/usr/share/pocketsphinx/model/lm/wsj/wlist5o.3e-7.vp.tg.lm.DMP'
    dictd = '/usr/share/pocketsphinx/model/lm/wsj/wlist5o.dic'
    wavfile = "msg_12c3da80-c6be-11e3-9430-eb6ba5ab4d1f.wav"
    recognised = decodeSpeech(hmdir,lmd,dictd,wavfile)

1 个答案:

答案 0 :(得分:0)

您在代码中使用旧API。在pocketsphinx-python中实现的新API的工作原理如下:

https://github.com/cmusphinx/pocketsphinx/blob/master/swig/python/test/decoder_test.py

在配置对象的帮助下初始化解码器。模特也不同。