2017-05-09 7 views
0

Google Assistant SDKの例では、Google Assistantと話す前にユーザーがenterキーを押す必要があります。Google Assistant SDK用のRaspberry Piのボタンの接続方法

RPI GPIOピンの1つにボタンを配線し、G.アシスタントをトリガーする方法があるのだろうかと思っていました。

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のバックグラウンドと自動化履歴があります。

答えて

0

これは役立つかもしれない:

... 
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

+1

おかげラウルを。それはまさにそれです。おそらくリチャーズのレビューに関しては、手順を要約することができます。乾杯。 – VBaarathi

関連する問題