【发布时间】:2021-03-15 15:43:46
【问题描述】:
在我的 Python 3.8.6 项目中,我为我的 Windows 10 计算机安装了“pip install SpeechRecognition”。代码示例如下,
import speech_recognition as sr
listener = sr.Recognizer()
try:
with sr.Microphone() as source:
print('Listening...')
voice = listener.listen(source)
command = listener.recognize_google(voice)
print(command)
except:
print("Something else went wrong")
pass
运行这段代码后,输出如下,
Something else went wrong
我的笔记本电脑已经内置了麦克风,并且我还使用插入外部 USB 麦克风对其进行了检查。那么这里有什么问题呢?是否需要任何硬件配置来解决此问题?
【问题讨论】:
-
从不抑制异常开始。
-
确保已安装 pyAudio
标签: python python-3.x speech-recognition speech-to-text