如何让Google智能助理监听LED?

问题描述:

经过长期研究没有任何结果,我试着在这里运气。我最近得到了GA SDK示例,以在我的Raspberry Pi 3上工作。如何让Google智能助理监听LED?

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

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

+0

您正在使用哪个样品的文件? – proppy

+0

@proppy我正在使用python sdk sample for raspberry pi – Jan

+0

哪个版本?和哪个软件包('google-assistant-library'或'google-assistant-grpc')? – proppy

看这里的启动指令样品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/

+0

其中您指的是assistant.py? – Gaurav

+0

好吧,我自己和其他线程的帮助下找到了解决方案。自从你解决了我原来的问题之后,我会将你的答案标记为正确 – Jan