使用pocketsphinx无法获得所需的输出

时间:2016-03-24 11:17:14

标签: python pocketsphinx

我的问题是我正在使用音频文件并将其转换为文本

我的音频文件包含" HI HELLO" ,但我将输出视为  对印度的短期卖家我不知道怎么做?

我使用的代码如下。

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/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 = sys.argv[1]
    recognised = decodeSpeech(hmdir,lmd,dictd,wavfile)

    print "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
    print recognised
    print "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"

1 个答案:

答案 0 :(得分:0)

您的输入文件格式错误。确保它是16khz 16位单声道PCM文件。

此外,您正在使用旧的pocketsphinx。请务必使用http://github.com/cmusphinx/pocketsphinx-python