srgoogle.py 文件源码

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

项目:CodeLabs 作者: TheIoTLearningInitiative 项目源码 文件源码
def recognize():

    r = sr.Recognizer()
    m = sr.Microphone()

    try:
        with m as source: r.adjust_for_ambient_noise(source)
        print("Escuchando...")
        play('beep.wav')
        with m as source: audio = r.listen(source)
        print("Enterado! Reconociendo...")
        try:
            value = r.recognize_google(audio, language="es-MX")
            if str is bytes:
                print(u"Dijiste {}".format(value).encode("utf-8"))
            else:
                print("Dijiste {}".format(value))
        except sr.UnknownValueError:
            print("Ups! No entendimos")
        except sr.RequestError as e:
            print("Oh oh! Error en la peticion a Google; {0}".format(e))
    except KeyboardInterrupt:
        pass
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号