【问题标题】:Unable to recognize the audio in python while using SpeechRecognition使用 SpeechRecognition 时无法识别 python 中的音频
【发布时间】:2020-06-07 15:39:09
【问题描述】:

r = sr.Recognizer()

with sr.Microphone() as source:
    print("speak up:")
    a = r.listen(source)

    try:
        text = r.recognize_google(audio)
        print(text)
    except:
        print("sorry didn't get you")

即使说话后输出仍然是

很抱歉没有找到你

【问题讨论】:

    标签: python-3.x speech-recognition


    【解决方案1】:

    我对这个包很有经验。告诉我这是否适合你......

    def takeCommand():
        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-us')
            print("User said: {query}\n")
    
        except Exception as e:
            print(e)
            print("Google was unable to hear")
            return "None"
    
        return query
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多