【发布时间】:2020-12-24 12:45:42
【问题描述】:
我在下面有一个 python 程序。我想接受麦克风输入并从输入中获取文本。当我运行程序时,它总是在第 9 行“audio_text = r.listen(source)”处停止并且不会继续。即使我已经停止说话,它似乎仍在等待麦克风输入停止。我知道我的麦克风可以正常工作,因为我录制了一个文件并使用 aplay 播放它。有谁知道为什么我的程序会卡在那条线上?
import speech_recognition as sr
print("Program has started!")
r = sr.Recognizer()
with sr.Microphone() as source:
print("Talk")
audio_text = r.listen(source)
print("Time over, thanks")
try:
# using google speech recognition
print("Text: "+r.recognize_google(audio_text))
except:
print("Sorry, I did not get that")
我在 Raspberry pi os 上运行它并使用 python3。
【问题讨论】:
标签: python raspberry-pi speech-recognition