这是我的代码
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))
这是结果
#ALSA lib pcm_dsnoop.c:638:(snd_pcm_dsnoop_open) unable to open slave
#ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
#ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
#ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
#ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel #map
#ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map
#ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map