如何在python中修复Recogniser.listen()以进行语音识别

时间:2019-07-14 12:39:10

标签: python

我使用了下面的代码段,但是当通过麦克风进行输入时,它似乎没有监听。

import speech_recognition as sr

r = sr.Recognizer()

with sr.Microphone() as source:
    r.adjust_for_ambient_noise(source, duration=10)
    print("Say something ")
    audio = r.listen(source) 

    try:
        test = r.recognize_google(audio)
        #print("you said :" + test)
        print("you said: {}".format(test))
    except:
        print("sorry could not hear you")

0 个答案:

没有答案