Speech Recognition in python3.7 does not work

129 views Asked by At

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

0

There are 0 answers