cozmo_voice_commands.py 文件源码

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

项目:cozmo 作者: yp7y-stu 项目源码 文件源码
def hear(source, r, robot):
    audio = r.listen(source)
    try:
        recognized = r.recognize_google(audio)
        print("You said: " + recognized)
        if command_activate in recognized or command_activate.lower() in recognized:
            print("Action command recognized")

            if command_pickup in recognized:
                do_blocks(robot)

            elif command_dance in recognized:
                do_dance()

            elif command_lookatme in recognized:
                do_lookforface(robot)

            elif command_followme in recognized:
                do_lookforface(robot)
                do_followface(robot)

            elif command_takepictureofme in recognized:
                do_lookforface(robot)
                do_takepicture(robot)

            elif command_takepicture in recognized:
                do_takepicture(robot)

            elif command_say in recognized:
                do_say(recognized, robot)

            else:
                print("Command not recognized")

        else:
            print("You did not say the magic word " + command_activate)

    except sr.UnknownValueError:
        print("Google Speech Recognition could not understand audio")
    except sr.RequestError as e:
        print("Could not request results from Google Speech Recognition service; {0}".format(e))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号