使用Python和PyAudio转换为文本无法在操作系统上使用

问题描述 投票:1回答:1

我正在尝试在Python 3.7(OS X /内置麦克风)上使用语音识别库

这里是我到目前为止使用的代码:

import speech_recognition as sr

r = sr.Recognizer()
with sr.Microphone() as source:
    print("Say something!")
    audio = r.listen(source)

print("Google Speech Recognition thinks you said " + r.recognize_google(audio))

但是,运行程序时没有输出,也没有错误消息。但是当我按下“停止”按钮时,此错误消息出现了

追踪(最近通话):文件“ /Users/diandraelmira/PycharmProjects/untitled/venv/APP.py”,第6行音频= r.listen(来源)侦听文件“ /Users/diandraelmira/PycharmProjects/untitled/venv/lib/python3.7/site-packages/speech_recognition/init.py”,行620缓冲区= source.stream.read(source.CHUNK)文件“ /Users/diandraelmira/PycharmProjects/untitled/venv/lib/python3.7/site-packages/speech_recognition/init.py”,第161行,已读取返回self.pyaudio_stream.read(size,exception_on_overflow = False)读取文件“ /Users/diandraelmira/PycharmProjects/untitled/venv/lib/python3.7/site-packages/pyaudio.py”,行608返回pa.read_stream(self._stream,num_frames,exception_on_overflow)KeyboardInterrupt

我该如何解决?

python python-3.x speech-recognition speech-to-text pyaudio
1个回答
0
投票

嗨,您能不能尝试一下,将查找错误

© www.soinside.com 2019 - 2024. All rights reserved.