如何在Google智能助理上收听LED指示灯?

时间:2017-05-27 17:24:48

标签: python grpc google-assistant-sdk

经过长时间的研究没有任何结果,我在这里试试运气。我最近得到了GA SDK样本,可用于我的Raspberry Pi 3.

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

有关添加LED代码的位置的任何建议吗?

1 个答案:

答案 0 :(得分:1)

查看此处的热门词汇示例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/