1

I'm use OSX and trying the voice assistant concept. However, the code stuck in audio = r.listen(source). I try to upgrade all of stuff but it does not work. My code is:

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")

The traceback is:

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

Dat.N.V
  • 21
  • 1
  • Why does the error state `KeyboardInterrupt`? – Fourier Dec 05 '19 at 13:46
  • It does not end and I have to stop manually. But it have the some traceback for all of the example program on internet that I use to test.(sorry if my English bad) – Dat.N.V Dec 05 '19 at 14:09

0 Answers0