1

经过长时间的研究没有任何结果,我在这里试试运气。我最近获得了 GA SDK 示例,可以在我的 Raspberry Pi 3 上运行。

现在我想在助手收听时点亮我连接的 LED。我知道如何做到这一点,但我不知道在助手示例代码中在哪里添加 LED 的代码。他们网站上的文档说它在 grpc 代码中,但我不知道更多。

关于在哪里添加 LED 代码的任何建议?

4

1 回答 1

2

在此处查看启动指令示例https://github.com/googlesamples/assistant-sdk-python/blob/master/google-assistant-sdk/googlesamples/assistant/library/hotword.py

您可以使用这些事件来编写您的 GPIO 逻辑来打开/关闭 LED。像这样的东西-

`def process_event(event):
    if event.type == EventType.ON_CONVERSATION_TURN_STARTED:
        print()
        GPIO.output(25,True)
    if (event.type == EventType.ON_CONVERSATION_TURN_FINISHED and
            event.args and not event.args['with_follow_on_turn']):
        print()
        GPIO.output(25,False)
    if (event.type == EventType.ON_RECOGNIZING_SPEECH_FINISHED and
            event.args and not event.args['with_follow_on_turn']):
        print()`

这是图书馆的文档 - https://developers.google.com/assistant/sdk/reference/library/python/

于 2017-06-05T20:44:23.397 回答