Google Voice Kit review
Google recently launched its Assistant API for the Raspberry Pi, and a couple of weeks ago I wrote about how to build your own digital assistant with a Raspberry Pi. My instructions were based in part on the “Voice Kit”, a hardware and software solution which demonstrates how to get a natural language recognizer up and running with a Raspberry Pi and the Google Assistant.
The Voice Kit was given away for free with the May 2017 edition of MagPi, the official Raspberry Pi magazine, but it was sold out in hours. At the time I wasn’t able to get hold of a Voice Kit, but I used it as the basis for my own digital assistant. After I published the instructions Google contacted me and kindly offered to send me a Voice Kit! So here is my review of the Google Voice Kit.
What you need
To build your own digital assistant you will need:
- A Google Voice Kit
- A Raspberry Pi 3 (plus a microSD card, a mouse, and a keyboard etc)
- A small headed screwdriver (for connecting the speaker to the terminal)
- Some scotch tape to stick the microphone board to the box
The Voice Kit is a combination of hardware and software for the Raspberry Pi. The hardware part consists of a special audio board called the Voice HAT which connects to a supplied speaker as well as a microphone board. There are some classic hardware bits and pieces like an arcade button, a micro-switch, a lamp, and a bunch of connectors.
The Voice Kit comes with a cardboard frame and box, in a similar style to the DIY Google cardboard VR headset. The first step is to assemble all the pieces, connect up the various boards, and fold the cardboard pieces to make the box.
Full assembly instructions can be found over at the AIY project website. Having done it myself, I would say the trickiest part is putting together the arcade button, the lamp, and the micro-switch. But if you study the photos carefully you will succeed!
The next thing to do is download the Voice Kit microSD card image for the Raspberry Pi. You can download it directly from Google’s AIY Project site. Once the .img.xz file has been downloaded you need to write it to the microSD card using a card writing utility. The Etcher.io tool is a good choice for this as it is available for Windows, macOS, and Linux. You don’t need to uncompress the image file. Etcher will take care of that for you.
Insert the microSD card into your Pi, connect it to a TV/monitor and hook up a mouse and keyboard. After booting you will see the standard Pixel desktop, however the background has been changed to feature the AIY Projects logo.
There are a number of tasks that now need doing:
- Click on the Raspberry symbol at the top left of the display. Move to Preferences and then click on Raspberry Pi Configuration. In the program go to “Interfaces” and enable SSH. Press OK.
- Click on the Wi-Fi symbol at the top right of the display (near the clock) and then click on your Wi-Fi network. Enter the passphrase as appropriate. If you want to set a fixed IP address then right-click on the same Wi-Fi symbol and click on Wireless & Wired Network Settings. In the program pick your network card (wlan0 for the wireless interface) from the drop down menu and then fill in the desired IP address and router etc.
Now it is time to run Google’s test scripts to make sure that everything is working. On the desktop there are three files for checking your configuration, double click on “Check audio” and follow the on screen prompts. If you can hear the sound being played and you are able to record your voice then you have the audio working.
Don’t bother with the Check Cloud script as it doesn’t work as expected, however you should verify that your Pi has Internet connectivity using the Check WiFi script.
In order for the Google Assistant to work your Pi needs to be configured to work with Google’s cloud services. Full details of how you do this can be found on the Voice Kit website, but here is a quick summary:
- On the Raspberry Pi, open up an internet browser and go to the Cloud Console.
- Create a new project.
- In the Cloud Console, enable the “Google Assistant API”.
- In the Cloud Console, create an OAuth 2.0 client by going to API Manager > Credentials
- Click Create credentials and select OAuth client ID. Note that if this is your first time creating a client ID, you’ll need to configure your consent screen by clicking Configure consent screen. You’ll need to name your app (this name will appear in the authorization step).
- In the Credentials list, find your new credentials and click the download icon on the right.
- Find the JSON file you just downloaded (client_secrets_XXXX.json) and rename it to assistant.json. Then move it to /home/pi/assistant.json
- In the dev terminal type: systemctl stop voice-recognizer
- Go to the Activity Controls panel and switch on the following: Web and app activity, Location history, Device information, Voice and audio activity.
You should now have everything you need to run Google Assistant on your Raspberry Pi. All you need to do is run the following command from the dev terminal:
Note: The first time you run main.py a web browser will open and you will need to login to Google to give permission for the Raspberry Pi to access the Google Assistant API.
Press the arcade button (and let go, there is no need to hold it) and say something to Google. Try:
- Who is the prime minister of the United Kingdom?
- What year was Richard the 3rd born?
- How many passengers where there on the Mayflower?
It is also possible to configure the Voice Kit to run the recognition service automatically. This means that the Voice Kit can be disconnected from the monitor, mouse, and keyboard and left to act as a standalone unit with just a power connection.
To start the voice recognition service type:
- sudo systemctl start voice-recognizer
You can stop the service by entering:
- sudo systemctl stop voice-recognizer
To make the service start automatically on boot, then run:
- sudo systemctl enable voice-recognizer
The Voice Kit has been built in such a way that the trigger mechanism can be changed. The source code for the trigger mechanisms is found in ~/voice-recognizer-raspi/src/triggers/*.py and you can add your own modules. As an alternative Google has provided a way to activate the assistant using a clap of the hands rather than by pressing the button.
To change the activation trigger manually you need to start the application with the -T flag. As another example:
- python3 src/main.py -T clap
Once you have the basic Raspberry Pi based Google Assistant running then the next step is to customize it yourself. Google has lots of documentation about how you can extend the assistant using Google’s cloud services. There is even an example where you can you turn on and off an LED using your own custom voice commands.
Overall the Voice Kit is a great tool for hobbyists and professional developers alike. For the former it is a great way experiment with Google’s Cloud services, with Python and with the Raspberry Pi. For the latter it is a fast way to develop product prototypes based on Google’s services.
If you build anything cool with the Voice Kit please let us know in the comments below!