语音识别python3.4 with pocketsphinx

时间:2017-07-15 14:51:15

标签: speech-recognition python-3.4 pocketsphinx

我只是按照这个>> steps<<并且运作良好,

现在,我如何开始使用python? 我试过这段代码:

import speech_recognition as sr

# obtain audio from the microphone
r = sr.Recognizer()
with sr.Microphone() as source:
    print("Say something!")
    audio = r.listen(source)

# recognize speech using Sphinx
try:
    print("Sphinx thinks you said " + r.recognize_sphinx(audio))
except sr.UnknownValueError:
    print("Sphinx could not understand audio")
except sr.RequestError as e:
    print("Sphinx error; {0}".format(e))

并收到错误:

Sphinx error; missing PocketSphinx module: ensure that PocketSphinx is set up correctly.

已经安装了speech_recognition,但我不确定pocketphinx和sphinxbase。我刚才所做的一切:https://cmusphinx.github.io/wiki/tutorialpocketsphinx/

1 个答案:

答案 0 :(得分:0)

您需要pip install PocketSphinx,这取决于二进制SWIG包。对于Windows,SWIG说明位于this SO answer

对于OSX,还有其他要求:

$ brew install cmu-pocketsphinx
$ brew install portaudio
$ brew install swig
$ pip install PocketSphinx