from aiy.cloudspeech import CloudSpeechClient import dialogflow_v2 as dialogflow import neopixel import time import board pixels = neopixel.NeoPixel(board.D12,30) print('setup...') client = CloudSpeechClient('/home/pi/cloud_speech.json') session_client = dialogflow.SessionsClient() session = session_client.session_path('XXXXX', 12345) def getDialogResponse(text): text_input = dialogflow.types.TextInput(text=text, language_code='EN') query_input = dialogflow.types.QueryInput(text=text_input) response = session_client.detect_intent(session=session, query_input=query_input) text = response.query_result.fulfillment_text return response while True: print('Listening...') spokenText = client.recognize() if spokenText is None: print('You said nothing.') else: print(spokenText) response = getDialogResponse(spokenText) responseText = response.query_result.fulfillment_text responseIntent = response.query_result.intent.display_name if responseIntent == 'Default Fallback Intent': print('All good') pixels.fill((0, 255, 0)) time.sleep(0.5) pixels.fill((0, 0, 0)) else: pixels.fill((255, 0, 0)) time.sleep(0.5) pixels.fill((0, 0, 0))