小编Vin*_*mar的帖子

Python,语音识别卡在“正在听...”

代码停留在监听(audio=r.listen(source)行)并且不会超出它。没有错误消息或其他任何内容。

我的代码:

import speech_recognition as sr

def takeCommand():
    '''
    It takes user's voice as input
    '''
    r=sr.Recognizer()
    with sr.Microphone() as source:
        print("Listening...")
        r.pause_threshold = 1
        audio=r.listen(source)

try:
    print("Recognizing...")
    query = r.recognize_google(audio, language="en-in")
    print(f"Recognized Command: {query}")

except Exception as e:
    print(e)
    print("I didn't recognize what you said please repeat")
    return "None"

return query


takeCommand()
Run Code Online (Sandbox Code Playgroud)

python speech-recognition

0
推荐指数
1
解决办法
8156
查看次数

标签 统计

python ×1

speech-recognition ×1