我正在用python编写文本语音代码,但遇到了以下问题:“请先构建并安装PortAudio Python绑定。”
import speech_recognition as sr;
r=sr.Recognizer()
with sr.Microphone() as source:
print("say something");
audio=r.listen(source)
try:
print(r.recognize_google(audio));
except:
pass;
答案 0 :(得分:0)
首先,代码不正确:
import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source:
print("say something")
audio = r.listen(source)
text = r.recognize_google(audio)
try:
print("You said: {}",format(text))
except:
print("Sorry I couldn't understand you")
接下来,您需要安装pyaudio,speech_recognition和 portaudio。请注意,由于 它们不属于c:libary的事实。
我建议您在线下载这些内容。