问题描述
我正在使用 pyttsx3
和 speech_recognition
模块,有时会收到此错误:OSError [Errno -9988] Stream closed
。 Here is 有点相同的问题,但在 RaspBerry Pi 上没有答案。
我的操作系统 - Windows 10,Python 版本 - 3.8.5
最小的可重现示例 -
import speech_recognition as sr
import pyttsx3
engine = pyttsx3.init()
while True:
r = sr.Recognizer()
print("Say something")
try:
with sr.Microphone() as source:
audio = r.listen(source,phrase_time_limit = 10)
said = ''
try:
said = r.recognize_google(audio,language="en-EN")
except sr.UnkNownValueError:
print("Unrecognised speech")
if said == 'hi':
engine.say("Hello there!")
engine.runAndWait()
except OSError as ose:
print(ose)
它产生的完整输出 - 我except
编辑了这个错误,我的输出是 OSError [Errno -9988] Stream closed
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)