首页 > 解决方案 > 为什么即使代码正确,我的语音识别程序也无法工作?

问题描述

我正在尝试用 python 制作我自己的助手,比如谷歌助手。我的语音识别程序以前可以工作,但是从计算机中清除了一些垃圾文件后它无法正常工作,它卡在“Speak:”上并且没有将语音转换为文本,甚至没有显示任何错误。

我已经安装了pyaudio,speechrecognition。

这是代码:

import speech_recognition as sr  

r = sr.Recognizer()                                                                                   
with sr.Microphone() as source:                                                                       
    print("Speak:")                                                                                   
    audio = r.listen(source)   
try:
    print("You said " + r.recognize_google(audio))
except sr.UnknownValueError:
    print("Could not understand audio")
except sr.RequestError as e:
    print("Could not request results; {0}".format(e))

标签: pythonspeech-recognitionpyaudiogoogle-speech-api

解决方案


推荐阅读