我通过将与捕获音频无关的语句从 with 语句中移出来让它工作,这应该对你有用:
import speech_recognition as sr
rec = sr.Recognizer()
print('say something')
with sr.Microphone() as source:
audio = rec.listen(source)
voice_data = rec.recognize_google(audio)
print(voice_data)
跃然一笑
相关分类