#raise AttributeError("Could not find PyAudio; check installation")
#AttributeError:找不到PyAudio;检查安装
#我已经尝试了每种类型的pip或sudo类型的命令,但是 #不起作用,只是说PyAudio丢失了
import speech_recognition as sr
# get audio from the microphone
r = sr.Recognizer()
with sr.Microphone() as source:
print("Speak:")
audio = r.listen(source)
try:
print("You said " + r.recognize_google(audio))
except sr.UnknownValueError:
print("Could not understand audio")
except sr.RequestError as e:
print("Could not request results; {0}".format(e))