AttributeError:\uu在尝试从麦克风获取输入时输入\uuuu

2024-10-01 00:21:56 发布

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

我在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!!!



Tags: 代码textimportsourceaswithitaudio