2017-05-09 2 views
0

Google Assistant SDK 예제에서는 사용자가 Google Assistant에 말하기 전에 입력을 눌러야합니다.Google Assistant SDK 용 Raspberry Pi의 버튼 연결 방법

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 배경 및 자동화 기록이 있습니다.

답변

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

관련 문제