AttributeError: __enter__ while trying to take input from microphone

假装没事ソ 提交于 2020-02-25 06:40:43

问题


I had been trying to take input from microphone in my python program using speech_recognition

I try to run this code: -

import speech_recognition as sr
import pyaudio
r = sr.Recognizer()
with sr.Microphone as source:
    audio = r.listen(source)
    text = r.recognize_google(audio)
    print(text)

But it does not run.

It says: -

"C:\Users\Bravo Six\AppData\Local\Programs\Python\Python37-32\python.exe" "D:/BROTEEN/Works/Python/VALINI/speech testing.py"
Traceback (most recent call last):
  File "D:/BROTEEN/Works/Python/VALINI/speech testing.py", line 9, in <module>
    with sr.Microphone as source:
AttributeError: __enter__

Process finished with exit code 1

How can I solve this problem??? Please some help me get out of this situation!!!

I Ctrl + clicked on the sr.**Microphone**, wherein I saw that it said it throws an attribute error when pyaudio 0.2.11 or later is not installed. So I installed it using cmd, but the problem still sustains... HELP!!!


来源:https://stackoverflow.com/questions/58842210/attributeerror-enter-while-trying-to-take-input-from-microphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!