Introduction: Google Assistant on Raspberry Pi and Respeaker 4 Mic Array Hat Using Gassist PI

All Respects and credits to shivasiddharth for his contribution to Github, i have just replicated it to showcase my build with the Respeaker 4 hat.

Objective of this project is to make google assistant by making use of a Raspberry pi 3 board.

Materials required will be :-

1. Raspberry Pi3

2. wifi dongle if you are using older boards, new ones come with onboard wifi and bluetooth.

3. USB mic

4. Optionally you can use a mic array hat like respeaker (i have used it in this current project)

5. 2.5 amps , 5 volt charger

6. Speakers

7. 32 GB SD card

Step 1: Install Raspbian Latest Version on the Raspberry Pi

Follow the below steps for installing Raspbian

Official images for recommended operating systems are available to download from the Raspberry Pi website Downloads page.
Alternative distributions are available from third-party vendors

. If you're not using Etcher (see below), you'll need to unzip .zip downloads to get the image file (.img) to write to your SD card. Note: the Raspbian with Raspberry Pi Desktop image contained in the ZIP archive is over 4GB in size and uses the ZIP64) format.

To uncompress the archive, a unzip tool that supports ZIP64 is required. The following zip tools support ZIP64: 7-Zip (Windows)The Unarchiver (Mac)Unzip (Linux)Writing an image to the SD card

You will need to use an image writing tool to install the image you have downloaded on your SD card.

Etcher is a graphical SD card writing tool that works on Mac OS, Linux and Windows, and is the easiest option for most users. Etcher also supports writing images directly from the zip file, without any unzipping required.

To write your image with Etcher: Download Etcher and install it.Connect an SD card reader with the SD card inside.Open Etcher and select from your hard drive the Raspberry Pi .img or .zip file you wish to write to the SD card.Select the SD card you wish to write your image to.Review your selections and click 'Flash!' to begin writing data to the SD card.

Once done , pop the SD card into the PI and connect the power supply. you will see the boot up process and the new stretch desktop will be displayed.

A wizard will take you through rest of the settings like , Locale settings, WIFI etc. Make sure you enable VNC and SSH interfaces along with the I2C interface or use sudo raspi-config in the terminal if you are used to the terminal commands.

If you are using a USB mic make sure you plug it in before you boot the PI . Or if You are using the Mic array hat you will need to fix the hat on the GPIO pins before the power is put on.

Step 2: Make Your Pi Ready for Update

now open a terminal window and give the following commands

Make sure you are in the /Home/Pi directory

sudo apt-get install git
git clone

Update OS and Kernel

sudo apt-get update
sudo apt-get install raspberrypi-kernel

Then Restart the PI

In this example i have used Respeaker hat to configure the drivers give below commands one by one.

git clone
cd ./seeed-voicecard/

sudo ./

sudo reboot speaker-test

Step 3: Creating Project in the Google Cloud

You will need to have a gmail account for this.

1. Refer to the detailed instructions in the google assistant sdk tutorials to create a project and link the model id of the prototype you are developing .

URL 1 . Google Developers page

URL 2. Device Registration with Model ID

Setting up the Google API for Raspberry Pi Google Assistant
1. First, we have to register and set up a project on the Google Console Actions dashboard .

2. After logging in to your Google account, you will see following window. Click on Add/Import Project.

3. On next screen, you have to enter the Project Name and click on Create Project.

4. Now, go to the Google developers console in the new tab and search for Google Assistant API. Before you go ahead and press the Enable button make sure that you have your project selected. Then click on Enable.

5. Now, open the previous tab of Google console and scroll down to the bottom of the screen. You will find an option Device Registration, click on it.

6. On the next screen, Click on Register Model. After this, you need to set a Product Name, Manufacturer name and set a Device Type. These names can be anything as you want. Write down the Device Model Id, as we will need this later in the process. Now, click on Register Model.

7. Next screen will be for Download Credentials. To get this credentials file click the Download OAuth 2.0 credentials. This file is very important so, keep it somewhere safe. Now, click on Next.

8. You can select any traits that you need, but in our case we don’t need any of these so we just clicked the Skipbutton as shown below.

9. Once everything is done, you will have following screen.

10. Now, go to Activity Controls page. Here you have to activate the following activity controls to ensure that the Google Assistant API work fine. Web & App Activity, Location History, Device Information, Voice & Audio Activity

11. Again, go to Google developers console . Click on Credentials on the left side of dashboard. Click on OAuth consent screen.

12. Fill your Gmail id and any name to the Product name and Save it.

Now, we have done with the Google API setup.

2. Place the credentials.json file in/home/${USER}/ directory DO NOT RENAME

3. Place the oauth credentials file also in the /home/Pi Directory

Point 2 and 3 are mandatory else the project will not work.

Next , we had cloned the Gassist PI project in our pi , but we have to make some files executable and install them

Follow below commands

sudo chmod +x ./GassistPi/scripts/

sudo ./GassistPi/scripts/

This execution will take around 30 mins depending on your internet speed

Post that in the command line you will be prompted for an authoization key , an url will be shown just above it , copy it in the browser, it will open google authentication page. Select your appropriate account and click on allow.

Once the key is generated , copy it and paste in the terminal window where script has stopped.

After successful authentication, the Google Assistant Demo test will automatically start. At the start, the volume might be low, the assistant volume is independent of the Pi volume, so increase the volume by using "Hey Google, Set volume to maximum" command.

To Make the assistant start on boot up or headless start follow the below commands

go to your pi home directory

type in the below commands and press enter

sudo chmod +x ./GassistPi/scripts/

sudo ./GassistPi/scripts/

sudo systemctl enable gassistpi-ok-google.service
sudo systemctl enable gassistpi-push-button.service

sudo systemctl start gassistpi-ok-google.service
sudo systemctl start gassistpi-push-button.service

Now once all process is complete , you can restart the PI . On boot up the Assistant will start automatically and greet you with "HI".

If the install process fails and you get segmentation fault or registration error , you may need to check out the project linking is done correctly in the google cloud and device registration steps.

Reboot the PI and Enjoy

Step 4: 3d Printed Case

The attached image i got it printed , i have placed the pi , and a speaker inside this. it works great :)

Electronics Tips & Tricks Challenge

Participated in the
Electronics Tips & Tricks Challenge