简体   繁体   English

属性错误:模块“ speech_recognition”没有属性“ Recognizer”

[英]Attribute error:module 'speech_recognition' has no attribute 'Recognizer'

I downloaded a speech recognition from pypy. 我从pypy下载了语音识别。

It was 3.6.0 version and extracted it in Lib folder inside python folder. 它是3.6.0版本,并将其提取到python文件夹内的Lib文件夹中。 Its name was something speechrecognition 3.6 and I changed it to speech_recognition and then it was not showing an error like "no such module", but inside that, there was another folder with the same name so I changed it also and now even though it has Recognizer folder it says: 它的名字叫Speechrecognition 3.6,我将其更改为Speech_recognition,然后没有显示类似“ no such module”之类的错误,但是里面有另一个同名文件夹,所以即使它已经Recognizer文件夹显示:

AttributeError: module 'speech_recognition' has no attribute 'Recognizer' AttributeError:模块“ speech_recognition”没有属性“ Recognizer”

Please help, I am new to python. 请帮助,我是python新手。

Code: 码:

import speech_recognition as sr
import pyaudio 
# Record Audio
r = sr.Recognizer()
with sr.Microphone() as source:
    print("Say something!")
    audio = r.listen(source)

# Speech recognition using Google Speech Recognition
try:
    # for testing purposes, we're just using the default API key
    # to use another API key, use `r.recognize_google(audio, 
key="GOOGLE_SPEECH_RECOGNITION_API_KEY")`
    # instead of `r.recognize_google(audio)`
    print("Speech was:" + r.recognize_google(audio, language = "en-us", 
show_all=False))
except sr.UnknownValueError:
    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))

I had the same error and found the solution with the help of the StackOverflow community here . 我遇到了同样的错误,并在此处的StackOverflow社区的帮助下找到了解决方案。

The error was that my file name was also speech_recognition and python was checking the file instead of the library. 错误是我的文件名也是speech_recognition,而python正在检查文件而不是库。 Changing my file name solved the problem. 更改我的文件名解决了该问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 语音识别:AttributeError:模块“ speech_recognition”没有属性“ Recognizer” - Speech Recognition: AttributeError: module 'speech_recognition' has no attribute 'Recognizer' Python语音识别:AttributeError:模块“ speech_recognition”没有属性“ Recognizer” - Python Speech Recognition: AttributeError: module 'speech_recognition' has no attribute 'Recognizer' Python 语音识别:AttributeError:模块“speech_recognition”没有属性“record” - Python Speech Recognition: AttributeError: module 'speech_recognition' has no attribute 'record' 为什么在 VSCode 中成功导入模块语音识别时实例化“识别器”时会出现 Python 错误? - Why am I getting a Python error when instantiating a 'Recognizer' while successfully importing module speech_recognition in VSCode? 如何使用 Speech_recognition 修复模块导入错误? - How to fix Module Import Error with speech_recognition? 使用语音识别模块 PYTHON 中的麦克风()时出错 - Error using Microphone() from speech_recognition module PYTHON Python语音识别:'模块'对象没有属性'麦克风' - Python Speech Recognition: 'module' object has no attribute 'microphone' ModuleNotFoundError:没有名为“ speech_recognition”的模块 - ModuleNotFoundError: No module named 'speech_recognition' python speech_recognition模块占用麦克风 - python speech_recognition module occupies microphone Python Speech_recognition pyaudio错误 - Python speech_recognition pyaudio error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM