Andrew Jones
Published © CC BY-NC-SA

Raspberry Pi Google Assistant With Sleek Wood Box

l built a DIY Google AI Assistant using a Raspberry Pi, USB Speaker and USB microphone.

IntermediateFull instructions provided9 hours10,717
Raspberry Pi Google Assistant With Sleek Wood Box

Things used in this project

Hardware components

Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
×1
Adafruit usb speaker
×1
usb microphone
×1
Resistor 330 ohm
Resistor 330 ohm
×1
LED (generic)
LED (generic)
×1

Software apps and online services

Raspbian
Raspberry Pi Raspbian
Assistant SDK
Google Assistant SDK

Story

Read more

Code

hotword.py.patch

Diff
Used to patch hotword.py to control the LED via the GPIO pins.
--- hotword.py.old	2017-08-04 19:16:18.699604629 +1000
+++ hotword.py	2017-07-02 00:56:30.749997722 +1000
@@ -27,6 +27,12 @@
 from google.assistant.library.event import EventType
 from google.assistant.library.file_helpers import existing_file
 
+import RPi.GPIO as GPIO
+import time
+GPIO.setmode(GPIO.BCM)
+GPIO.setwarnings(False)
+GPIO.setup(18,GPIO.OUT)
+
 
 def process_event(event):
     """Pretty prints events.
@@ -39,12 +45,18 @@
     """
     if event.type == EventType.ON_CONVERSATION_TURN_STARTED:
         print()
+        GPIO.setup(18,GPIO.OUT)
+        print("LED on")
+        GPIO.output(18,GPIO.HIGH)
+        
 
     print(event)
 
     if (event.type == EventType.ON_CONVERSATION_TURN_FINISHED and
             event.args and not event.args['with_follow_on_turn']):
         print()
+        print("LED off")
+        GPIO.output(18,GPIO.LOW)
 
 
 def main():

Credits

Andrew Jones

Andrew Jones

1 project • 19 followers
Maker, youtuber and woodworker

Comments