我一直在尝试使用Speech_recognition从我的python程序中的麦克风获取输入
我尝试运行以下代码:-
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)
但是它没有运行。
它说:-
"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__
以退出代码1完成的过程
我该如何解决这个问题???请一些帮助我摆脱这种情况!!!
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!!!