Нет ответа, когда я говорю с распознаванием речи - PullRequest
0 голосов
/ 15 октября 2018
import speech_recognition as sr
r = sr.Recognizer()
#
with sr.Microphone() as source:
    print("Say something!")
    audio = r.listen(source)

try:
    print("google speech recognition thinks you said " + r.recognize_google(audio))
except sr.UnknowValueError:
    print("google speech recognition could not understand audio")
except sr.RequestError as e:
    print("Could not request results from google speech recognition service;{0}".format(e))

macOS Mojave.

portaudio-19.6.0

pyaudio-0.2.11

После запуска python main.py я кое-что сказал своему макинтошуи ждал несколько минут.НЕТ ответа вообще!Ctrl + C, чтобы остановить процесс, и сообщение об ошибке ниже.

Say something!
^CTraceback (most recent call last):
  File "main.py", line 6, in <module>
    audio = r.listen(source)
  File "/Library/Python/2.7/site-packages/speech_recognition/__init__.py", line 620, in listen
    buffer = source.stream.read(source.CHUNK)
  File "/Library/Python/2.7/site-packages/speech_recognition/__init__.py", line 161, in read
    return self.pyaudio_stream.read(size, exception_on_overflow=False)
  File "/Library/Python/2.7/site-packages/pyaudio.py", line 608, in read
    return pa.read_stream(self._stream, num_frames, exception_on_overflow)
KeyboardInterrupt
...