【问题标题】:Python speech_recognition doesn't understand me and returns UnknwonValueErrorPython speech_recognition 不理解我并返回 UnknwonValueError
【发布时间】:2020-12-31 01:00:08
【问题描述】:

如果我在终端中运行 Speech_recognition 模块,它仍然无法理解我并返回(糟糕!无法理解)。

import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source:
    r.adjust_for_ambient_noise(source, duration=2)
    audio = r.listen(source)                   
try:
    print("You said " + r.recognize(audio))
    
except Exception as e:
    print(e)

【问题讨论】:

    标签: python python-3.x speech-recognition


    【解决方案1】:
      r = sr.Recognizer()
    with sr.Microphone() as source:             #Microphone recognizer 
        print("Listening....")
        r.pause_threshold = 1                   #use for recognizer hold
        r.energy_threshold=1000
        audio = r.listen(source)                #use for listen
    
    try:                                        #try use for by chance any error bypass
        print("Recognizing.......")
        query = r.recognize_google(audio, language="en-in") #This is use for language 
        print(f"User Said : {query}\n")
        speak("okay")
    except Exception as e:
        print(e)
        print("Say that again Please......")
        speak("Say that again Please")
        return "None"
    return query
    

    【讨论】:

    • 请不要只发布代码 sn-p 作为您的答案。它可以帮助用户更轻松地了解您的解决方案以吸引投票。
    猜你喜欢
    • 2016-02-05
    • 1970-01-01
    • 1970-01-01
    • 2020-04-17
    • 1970-01-01
    • 2022-11-18
    • 1970-01-01
    • 1970-01-01
    • 2013-07-22
    相关资源
    最近更新 更多