pandora.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:pandora 作者: ryzokuken 项目源码 文件源码
def listen(recognizer, message='Say Something'):
    with speech_recognition.Microphone() as source:
        print(message)
        audio = recognizer.listen(source)
    try:
        return recognizer.recognize_google(audio).lower()
    except speech_recognition.UnknownValueError:
        try:
            return recognizer.recognize_sphinx(audio).lower()
        except speech_recognition.UnknownValueError:
            print("Pandora could not understand audio")
        except speech_recognition.RequestError as e:
            print("Sphinx error; {0}".format(e))
    except speech_recognition.RequestError as e:
        print("Could not request results from Google Speech Recognition service; {0}".format(e))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号