In this instructable I’ll show how to build a DIY Google AI Assistant using a Raspberry Pi, USB Speaker and USB microphone. I’ll also show how to make the sleek hardwood box it’s housed in.
I’m assuming a basic knowledge of the linux operation system, raspberry pi and unix command line. If your new to raspberry pi there are plenty of good getting started tutorials here https://www.raspberrypi.org/help/ and on instructables (:
If your not interested in woodworking. You can easily substitute the wooden box for something simpler, like a cardboard box or a plastic project box.
- Raspberry Pi 3 Model B: https://www.adafruit.com/product/3055
- Mini USB microphone: https://www.adafruit.com/product/3055
- Mini USB speaker: https://www.adafruit.com/product/3055
- Raspberry pi power adapter
- Raspberry pi micro SD card with Raspian OS installed
- 330ohm resistor
- 3mm warm white LED
- bread board prototyping wires
- electrical tape
Materials needed for the box:
- 10mm aluminum tube
- Tasmanian oak was used for the wood. Each board measured 24x9x1.2cm
- Wood finishing oil, I used Danish oil.
- 2mm wood screws
- 30mm wood screws
- soldering iron
- tenon saw
- hand router
- bench chisel and mallet
- sand paper
- drill press
- electronics perfboard was used as a template for the speaker holes
- flat file
Step 1: Watch the Build Video
Watch this build video to get an idea on what is involved. If you like my video please, like it, leave a comment and subscribe to my channel (: https://www.youtube.com/user/andii1701
Step 2: Setup the Raspberry Pi
Connect the pi to a keyboard, monitor and mouse. Boot it up. Now configure network and ssh access. There is a good guide here: https://developers.google.com/assistant/sdk/develop/python/hardware/setup
Note Raspberry PI's do not have real time clocks so you will need to either setup NTP or manually set the time with the command:
$ date -s '2014-12-25 12:34:56'
not doing so can cause SSL errors later.
Once network is setup update you pi’s operating system by following this guide: https://www.raspberrypi.org/documentation/raspbian/updating.md
(Optional) Compile python3.6 on the raspberry pi
The default python3 install on the raspberry pi is python3.4, I wanted a more modern python, so I downloaded and compiled python3.6 from source http://bohdan-danishevsky.blogspot.com.au/2017/01/building-python-360-on-raspberry-pi-3.html
Step 3: Configure Google Cloud
The google assistant SDK needs to talk to it's API in google cloud. This process involves creating a google cloud project, enabling the assistant API, generating a client secret and downloading that secret json blob to the pi. There are detailed instructions here: https://developers.google.com/assistant/sdk/develop/python/config-dev-project-and-account
Step 4: Configuring the Assistant Python Software on the Pi.
If you just want a bear bones google assistant running on follow this guide: https://developers.google.com/assistant/sdk/develop/python/run-sample.
However if you want to add a LED or extend it in other ways git clone this library and follow the instructions to get it running:
$ git clone https://github.com/googlesamples/assistant-sdk-py...
$ cp -r assistant-sdk-python/google-assistant-sdk/googlesamples/assistant/library new-project
$ cd new-project
[Follow the instructions in README.rst to get it going]
You should now have a working Google assistant running on the Pi.
Step 5: Getting the Assistant to Turn on the LED
Solder the 330ohm resistor to the negative terminal of the LED and wire it up according to the above diagram. I used PIN3 for ground and PIN18 for positive.
Python has an excellent library for controlling GPIO pins called Rpi.GPIO. Install this library into your virtual env:
$ pip install RPi.GPIO
Before messing around with the assistant's code, I'd suggest following this guide to make sure the LED works first:
Adding GPIO code to the google assistant was quite straight forward. Download the attached patch and apply it with:
$ patch -p0 < hotword.py.patch
If the patch applied correctly the LED should turn on after "OK Google" and turn off after the assistant finishes.
Step 6: Building the Box
Now the google assistant and LED are working you can now make the box.
I sawed the timber to length 24cm and planed down the ends to match each other. Using a marking gauge I marked a rectangle on the inner face of each board that was 1/4” in from each side. I then chiseled and hand routed out this area to a depth of about 6mm. I place the pi between the boards regularly to check the gap distance. If you don't have a hand router, you could use an electric router or make a simple one.
Note I should have left raised platforms in the corners of the trench for the aluminum spacers to sit on. The wood screws had very little wood on the front board to bite into. It was enough, just!
This is not shown on the video. On the back board I cut out a deeper area around the PI’s USB ports. This extra trench depth came to about 9mm. This allowed the boards to end up closer together, providing a more sleek look.
Step 7: Drill Speaker Holes
Using a speaker as a size guide, I masked out an area of holes on an electronics perfboard with tape. I then used this perfboard as a drill template by taping it to the board. Make there is enough room at the back to place the pi and two speakers. I’d do a mock electronics layout first.
Using a 1mm drill bit carefully drill out the speaker grill. (This will take some time :)
Step 8: Layout Electronics
Layout all electronics. Drill pilot holes for the Pi and screw it in place using the 2mm wood screws. Place the speakers over the grills and figure out how long the USB cord needs to be. A long usb cord will not fit in the box. Cut the cord to length and re-solder it to the usb controller. Everything can now be connected and placed. Hot glue the speakers in place. I placed the USB controller board under it’s usb cables near the Pi’s USB hub. I also used a bit of electrical to cover it so no shorts occur.
Drill a 3mm hole for the LED. Place it in the hole and wire it up. Note I had to cut 2mm off each black pin connector on the breadboard wires so they will fit in the box. Cover the exposed wires and resistor with electrical tape to prevent shorts.
Step 9: Make Aluminium Spacers and Finishing the Box
Using 10mm aluminium tube, I cut the spacers to length 23mm with the hack saw (same height as the Pi). Then cleaned up the cuts with the flat file. Place the spacers in the corners and put the back board in place, make sure you are happy with how wide the gap is.
Using the spacers as a guide mark a drill hole at the centre of each spacer. In the back piece drill pilot holes for the case screws. Do a mock assembly and secure it together with tape. Using the depth guide on the drill press, drill shallow pilot holes on the front board by drilling though the back board pilot holes. BE VERY CAREFUL not to drill through the front board!
Counter sink the back drill holes with a counter sink bit.
You can now screw together the box. Be careful to choose the correct length wood screws. I got lucky, the 30mm wood screws were just long enough. It might be worth taking the box to the hardware store so you can find the correct screws.
Finishing the box
I sanded the box smooth and used a camera dust remover to blow out the dust from the speaker grill and electronics. I finished the box with danish oil, carefully dabbing it on around the speaker grill so the holes to do not get clogged.
Congratulations your done! BTW google assistant have tonnes of easter eggs you can discover (:
Step 10: Extending the Google Assistant
Extending the assistant is an instructable in itself. So I'm not going to cover it in detail here. But I'll point you in right direction. The simplest way to extend the assistant is to write apps in the ittt.com (If this then that) service. ittt.com is a online service you can create simple web apps that automatically perform various tasks. The google assistant can be wired up to this service.
Another way to extend the assistant is by extending the python client. I did not look into this in detail but this link is worth looking at: https://developers.google.com/assistant/sdk/develop/python/next-steps
Step 11: Conclusion
VikramS24 made it!