Introduction
This article demonstrates how to build and set up Pi-powered Google Assistant, also known as Google Home. This is early adoption of integrating Google Home to the Raspberry Pi.
Google Assistant
Google Home speakers enable the users to give voice commands to interact with services through Google's personal assistant software called Google Assistant.
Equipment List
- Raspberry Pi 2 or 3
- Micro SD Card
- USB Microphone
- Speakers
Step 1
Register and set up a project on the Google Action console. You must have logged into your Google account and you will be greeted with the following screen to create a new project. Here, our project name is Ras-Pi and then, click the "Create" button.
Navigate to the credentials page and enable the Google Assistant API before you go to select the project.
Select OAuth consent screen and create a new application with a name same as the project name.
Click the drop-down button and select the client ID.
After that, select the application type. This is the Linux operating system, so select the "Other" option.
Provide the code for client ID and client secret.
Step 2
Download the JSON file in Raspberry Pi. The download location is "home/pi/Downloads".
Go to the following link https://myaccount.google.com/activitycontrols to enable the voice and audio activity.
Step 3
- sudo apt-get install python3-dev python3-venv
Set up the Python IDE.
Upgrade the Python setup tool and activate.
- env/bin/python -m pip install --upgrade pip setuptools --upgrade
- source env/bin/activate
Download the following library for Google Assistant.
- python -m pip install --upgrade https:
Install the Google Authentication Library tool.
- python -m pip install --upgrade google-auth-oauthlib[tool]
Step 4
Obtaining an authentication key, replace the idxxx with your client Id file.
- google-oauthlib-tool --client-secrets /home/pi/Downloads/client_secret_client-idxxx.json --scope https:
Google APIs provide the authorization link. Then, browse the given link to generate the authorization key.
Copy this code and switch to your application and paste.
- Enter the authorization code : XXXXXXXXXXXXXXXX
Output
If you ask a question, the Assistant will reply.
See the EventType for details on all events and their arguments.
"What time is it?" -> "The time is 9:02 PM"
or
"Set a timer" -> "Okay, for how long?" ->
"5 minutes" -> "Sure, 5 minutes, starting now!"
Summary
Finally, we have successfully created a DIY Google AI Assistant using Raspberry Pi.