Python SpeechRecognition正在运行,但无法通过mi进行听觉识别

2024-04-19 15:17:03 发布

您现在位置:Python中文网/ 问答频道 /正文

所以我尝试使用python SpeechRecognition 1.1.3,但它无法通过麦克风识别我。我已经安装了pyAudio,当我运行SpeechRecognition提供的示例代码时,一切似乎都很顺利:

# NOTE: this requires PyAudio because it uses the Microphone class
import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source:                # use the default microphone as the audio source
    audio = r.listen(source)                   # listen for the first phrase and extract it into audio data

try:
    print("You said " + r.recognize(audio))    # recognize speech using Google Speech Recognition
except LookupError:                            # speech is unintelligible
    print("Could not understand audio")

它只是坐在那里等待麦克风的输入。麦克风工作正常,SpeechRecognition能够识别出它是默认麦克风,因为当我拔下它时,代码条就会出现。有什么建议吗?在

我运行的是python2.7.6,我的操作系统是windows7。另外,我把所有这些都放在E:drive上,只是为了让生活更复杂一点。。。:/


Tags: the代码示例sourceasitaudiospeech
1条回答
网友
1楼 · 发布于 2024-04-19 15:17:03

根据脚本,Pyaudio还没有安装。别担心,这是应用程序可能收到的常见语法错误。我建议您重新安装Python程序到能够在Pyaudio 1.1.3下运行的版本。您还没有指定所使用的Python版本以及您的计算机在什么操作系统下运行(即windowsvista,7或8)。假设您使用的是windows8或windows7,那么您必须在Windows命令中输入easy\u install。但是,如果这不起作用,请安装这个Python脚本:http://peak.telecommunity.com/dist/ez_setup.py,然后通过在C:\<Your python directory>\Scripts\中输入easy\u install来重新尝试该过程。希望这有帮助。在

相关问题 更多 >