我在Python 2.7中运行以下安装了pyAudio的代码。
import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source: # use the default microphone as the audio source
audio = r.listen(source) # listen for the first phrase and extract it into audio data
try:
print("You said " + r.recognize(audio)) # recognize speech using Google Speech Recognition
except LookupError: # speech is unintelligible
print("Could not understand audio")
输出给出一个闪烁的指针。就这样。请帮忙,因为我是新来的。
我用以下方法解决了同样的问题(噪音抑制), “listen”功能存在环境噪音问题。所以运行代码只是在等待。
使用该环境噪声抑制/调整;
r.adjust_for_ambient_noise(source, duration=5)
推荐 Tuesday, March 28, 2017 Easy Speech Recognition in Python with PyAudio and Pocketsphinx
你试过更换吗
与
通过运行以下命令确保pyaudio.h已安装
可能的原因可能是
recognizer_instance.energy_threshold
属性设置的值太高,无法开始使用。您应该降低此阈值,或调用recognizer_instance.adjust_for_ambient_noise(source, duration = 1)
。你可以在Speech Recognition上了解更多相关问题 更多 >
编程相关推荐