On the 13th of March, we hosted a casual knowledge sharing session around the Google Assistant API’s and a do-it-yourself Google Assistant device. Together with our colleagues we built no less than 3 fully operational Google Assistants
One of the main objectives was to introduce the Raspberry Pi and additional hardware like the Voice-HAT, which stands for “Hardware Attached on Top”. Also understanding the concepts of Machine Learning and Artificial Intelligence applied within ‘smart assistants’ like Google Home, Siri or Alexa was something we wanted to achieve.
To be able to build a Google Assistant, we needed both hardware and software components. We did some preparations on forehand, so the participants wouldn’t have to waste too much time on downloading Linux distributions and configuring the Raspberry Pi in terms of Wi-Fi connectivity and remote access via SSH and VNC.
After a short introduction to the project, the two teams started by assembling the different components. Most components can be connected easily by using the provided connector cables and attaching the Voice-HAT to the Raspberry’s GPIO pins. However, two wires of the 8 Ohm speaker needed to be screwed onto the connector on the Voice HAT.
The casing will be made out of card board, so we had to use our folding skills to build the box to house all electronical components.
But off course our own human hardware needs input and energy as well, so we had a Pizza break before continuing with the software part of the project.
So, the hardware part is now done and we can continue by inserting the Micro-SD card with the Raspbian Linux operating system distribution. This Micro-SD card was prepared, and pre-configured to connect with our QforIT Wi-Fi network automagically. Also the VNC-service and SSH-service were enabled, so external access to both the graphical interface as the command line is possible. To be able to connect easily, we configured static IP-addresses on the Raspberry Pi’s.
When the operating system has been booted up, we will perform some checks to determine if all hardware has been assembled correctly. To do so, we will run a prepared Python script check_audio.py. This script will try to play a test sound over the Voice-HAT and connected speaker. Also the user will be asked to record a test message which will then be replayed by the device, so both the microphones and the speaker are tested.
The real magic happens within the Google Cloud Platform. Voice Recognition will be done by sending audio fragments to Google’s servers via the Google Assistant API’s. First we log in to the Google Cloud Platform dashboard, to create a new project.
The project we create will be named ‘Voice Kit’, the next step is to enable the Google Assistant API.
The Google Assistant client on our Raspberry Pi needs to connect to this API, but to do so, it will need to authenticate with the proper credentials. The Google Cloud Platform dashboard allows us to create a credentials-file for downloading to the client.
After downloading the Json credentials file to the home directory on the Raspberry Pi, we need to reboot the system. The startup procedure of the Raspberry Pi has been configured so it will automatically start all necessary Voice Kit services and the credentials file will be loaded. After the system has been rebooted, we have a working Google Assistant!
Interacting with the Assistant is easy, just press the arcade button on top and start talking, or just say ‘Hey Google’ and ask questions like:
– ‘What is the weather forecast?’
– ‘Can you sing me a song?’
– ‘What is the latest news’