如何使LED指示灯在Google Assistant收听时点亮? [英] How can I get an LED to light on Google Assistant listening?

查看:263
本文介绍了如何使LED指示灯在Google Assistant收听时点亮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

After a long research without any results, I'm trying my luck here. I recently got the GA SDK sample to work on my Raspberry Pi 3.

现在,当助手正在收听时,我想点亮连接的LED.我知道如何执行此操作,但是我不知道在Assistant示例代码中将LED的代码添加到何处.他们网站上的文档说它在grpc代码中,但我对此一无所知.

Now I would like to light my connected LED when the Assistant is listening. I know how to do this, but I don't know where to add the code for the LED in the Assistant sample code. The documentation on their website says it's in the grpc code, but I don't know any more than that.

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

Any advice on where to add the LED code?

推荐答案

在此处 https://github.com/googlesamples/assistant-sdk-python/blob/master/google-assistant-sdk/googlesamples/assistant /library/hotword.py

您可以使用事件来编写GPIO逻辑以打开/关闭LED. 像这样-

You can use the events to write your GPIO logic to turn on/off the LED. Something like this -

`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/

这篇关于如何使LED指示灯在Google Assistant收听时点亮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆