【问题标题】:How to wire a button on Raspberry Pi for Google Assistant SDK如何在 Raspberry Pi 上为 Google Assistant SDK 连接按钮
【发布时间】:2017-05-10 19:50:55
【问题描述】:

Google 助理 SDK 示例要求用户在与 Google 助理交谈之前按 Enter。

我想知道有没有办法将一个按钮连接到一个 RPI GPIO 引脚并让它触发 G.Assistant。

 while True:
        if wait_for_user_trigger:
            click.pause(info='Press Enter to send a new request...')
        continue_conversation = assistant.converse()
        # wait for user trigger if there is no follow-up turn in
        # the conversation.
        wait_for_user_trigger = not continue_conversation

        # If we only want one conversation, break.
        if once and (not continue_conversation):
            break

我想这将是我在连接 GPIO 库时进行更改的区域。

我应该如何实施它?我是 Python 和 Raspberry Pi 的新手。我确实有 Java 背景和自动化历史。

【问题讨论】:

    标签: raspberry-pi google-assistant-sdk


    【解决方案1】:

    这可能会有所帮助:

    ...
    import os.path
    import RPi.GPIO as GPIO
    ...
    CLOSE_MICROPHONE = embbeded_assistant_pb2.ConverseResult.CLOSE_MICROPHONE
    
    GPIO.setmode(GPIO.BMC)
    GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    GPIO.setup(23, GPIO.OUT)
    ...
    while True:
        if wait_for_user_trigger:
            input_state = GPIO.input(18)
            if input_state == True:
                GPIO.output(23, False)
                continue
            else:
                GPIO.output(23, True)
                pass
            #click.pause(info='Press Enter to send a new request...')
    
    ...
    

    参考:https://youtu.be/ImrN404aDcc

    【讨论】:

    • 谢谢劳尔。就是这样。也许关于理查兹的评论,你可以总结一下这些步骤。干杯。
    猜你喜欢
    • 2017-12-31
    • 1970-01-01
    • 1970-01-01
    • 2017-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多