如何解决此python portaudio绑定问题?

时间:2019-01-21 16:22:30

标签: python speech-recognition pyaudio

我正在用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;

1 个答案:

答案 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的事实。

我建议您在线下载这些内容。