语音识别python3.4与pocketsphinx

问题描述 投票:3回答:1

我只是按照这个>> 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/

speech-recognition python-3.4 pocketsphinx
1个回答
0
投票

你需要pip install PocketSphinx,它取决于二进制SWIG包。对于Windows,SWIG指令位于this SO answer中。

对于OSX,还有其他要求:

$ brew install cmu-pocketsphinx
$ brew install portaudio
$ brew install swig
$ pip install PocketSphinx
© www.soinside.com 2019 - 2024. All rights reserved.