1

我正在使用 OSX 并尝试语音助手的概念。但是,代码卡在audio = r.listen(source). 我尝试升级所有东西,但它不起作用。我的代码是:

r = sr.Recognizer()
with sr.Microphone() as source:
    audio = r.listen(source)
try:
    print("You said " + r.recognize_google(audio))
except LookupError:
    print("Could not understand audio")

回溯是:

File "/Users/ngovandat/PycharmProjects/untitled2/test.py", line 4, in <module>
  audio = r.listen(source)
File "/Users/ngovandat/PycharmProjects/untitled2/venv/lib/python3.7/site-packages/speech_recognition/__init__.py", line 620, in listen
  buffer = source.stream.read(source.CHUNK)
File "/Users/ngovandat/PycharmProjects/untitled2/venv/lib/python3.7/site-packages/speech_recognition/__init__.py", line 161, in read
  return self.pyaudio_stream.read(size, exception_on_overflow=False)
File "/Users/ngovandat/PycharmProjects/untitled2/venv/lib/python3.7/site-packages/pyaudio.py", line 608, in read
  return pa.read_stream(self._stream, num_frames, exception_on_overflow)
KeyboardInterrupt

4

0 回答 0