【发布时间】:2022-01-04 15:39:11
【问题描述】:
我知道版本已经过时,但我需要知道问题所在。如果我想运行我的脚本,就会出现这个错误。
File "c:/Users/auth/Downloads/JARVIS/JARVIS/jarvis.py", line 319, in <module>
query = takeCommandMic().lower()
File "c:/Users/auth/Downloads/JARVIS/JARVIS/jarvis.py", line 118, in takeCommandMic
with sr.Microphone() as source:
File "C:\Users\auth\AppData\Roaming\Python\Python36\site-packages\speech_recognition\__init__.py", line 141, in __enter__
input=True, # stream is an input stream
File "C:\Users\auth\AppData\Roaming\Python\Python36\site-packages\pyaudio.py", line 750, in open
stream = Stream(self, *args, **kwargs)
File "C:\Users\auth\AppData\Roaming\Python\Python36\site-packages\pyaudio.py", line 441, in __init__
self._stream = pa.open(**arguments)
OSError: [Errno -9999] Unanticipated host error
Error in sys.excepthook:
Original exception was:
问题应该在那里:
def takeCommandMic():
r = sr.Recognizer()
with sr.Microphone() as source:
print("Listening...")
r.pause_threshold = 0.5
audio = r.listen(source)
try:
print("recognizing...")
query = r.recognize_google(audio , language="de-DE")
print(query)
except Exception as e:
print(e)
return "Nichts"
return query
还有
if __name__ == "__main__":
getvoices(1)
speak("Hallo, hier ist jarvis")
#wishme()
while True:
turnOnLightsAtTime()
query = takeCommandMic().lower()
【问题讨论】:
-
您能提供一个代码示例吗?
-
在您的问题中可能已格式化
标签: python python-3.x speech-recognition text-to-speech pyaudio