如何让 LED 在 Google 智能助理监听时点亮?

How can I get an LED to light on Google Assistant listening?

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

的 GA SDK 示例

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

关于在何处添加 LED 代码有什么建议吗?

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

您可以使用事件编写您的 GPIO 逻辑来打开 on/off 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/