0% found this document useful (0 votes)
65 views12 pages

Building Google Assistant With Raspberry Pi: Installation Manual

This document provides instructions for building the Google Assistant on a Raspberry Pi, including hardware requirements like a Raspberry Pi model, SD card, and audio equipment. It describes setting up the Google API, registering a device model, installing the SDK and sample code, running authentication, and configuring the Google Assistant to start at boot. The instructions are broken into steps covering registration, authorization, installation, configuration, and testing to enable the Google Assistant functionality on the Raspberry Pi.

Uploaded by

JANVI
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
65 views12 pages

Building Google Assistant With Raspberry Pi: Installation Manual

This document provides instructions for building the Google Assistant on a Raspberry Pi, including hardware requirements like a Raspberry Pi model, SD card, and audio equipment. It describes setting up the Google API, registering a device model, installing the SDK and sample code, running authentication, and configuring the Google Assistant to start at boot. The instructions are broken into steps covering registration, authorization, installation, configuration, and testing to enable the Google Assistant functionality on the Raspberry Pi.

Uploaded by

JANVI
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 12

Building Google Assistant with raspberry Pi

Installation Manual

 The Google Assistant is a virtual assistant powered by artificial intelligence and developed
by Google that is primarily available on mobile and smart home devices.
 The Google Assistant can engage in two-way conversations.

Hardware Requirements
1. Raspberry Pi Model A/B/B+
2. SD Card
3. Ethernet Cable / Wi-Fi
4. Power Supply
5. USB Microphone
6. Speakers

 Software Requirements

1. Raspbian Stretch OS
2. Google Account

Configure and Test Audio


 Attach USB Microphone and Speakers to Raspberry Pi.
 After connection, test it to ensure audio is working or not.
Follow below tutorial to configure and test audio
https://drive.google.com/open?id=1gexNOv_zK1jqRpeyCn7JKU6Tpud2Vn82

1|Page Manorama Darekar,Gurukul College.


Note that…
 If recording and playback are working, then you are done configuring audio.
 If not, check that the microphone and speaker are properly connected.
 If this is not the issue, then try a different microphone or speaker.

Step 1: Registering the Google API


1. Before we get started with setting up the Google Assistant code on the Raspberry Pi itself, we
must first register and setup oAuth access to Google’s Assistant API. To do this, you will need to
have a Google account already.

Once you have your Google account ready, go to the following web address.
https://console.cloud.google.com/project

2. Once you have logged into your account, a dialog


box appears, in which select your Country and for the two
radial boxes, we selected ‘No‘ to wanting email updates and
‘Yes‘ to agree to their terms of service.

3. Click on Create Project Link.

2|Page Manorama Darekar,Gurukul College.


4. Enter Project Name and Click on Create

The project creation process can take some time. You should receive a notification in the top
right-hand corner of the screen when it’s complete. If it doesn’t automatically appear after some
time, try refreshing the page.

5. Once it has appeared, click the project name.

6. On the side menu, select API's & Services

7. In Dashboard Option, Click on Enable


API's & Services

3|Page Manorama Darekar,Gurukul College.


8. Search for Google Assistant API in Library
Section

9. Click on Enable Button

10. Now in APIs & Services Page, Select Credentials


Option.

11. Switch to the oauth consent screen

Enter name in Project Name shown to users

Click on Save

4|Page Manorama Darekar,Gurukul College.


12. Click on Create Credentials button

13. In the drop-down menu,


Click on oauth Client ID

14. Set the Application Type to Other,


You can also change the name for client ID.
Or keep default as it is.

Click on Create button.

5|Page Manorama Darekar,Gurukul College.


15. Now Download the Credentials file for our newly created oauth credential.

Downloaded file will be saved under /home/pi/Downloads folder.


Step 2: Account Settings
Now, go to the URL https://myaccount.google.com/activitycontrols, and activate the following
activity controls to ensure that the Google Assistant API works correctly.

 Web & App Activity


 Location History
 Device Information
 Voice & Audio Activity

Step 3: Register the Device Model


1. Now open https://www.console.actions.google.com
Select your Project (created in previous step), Or Even you can also create your new project with
this link.

6|Page Manorama Darekar,Gurukul College.


2. Scroll Down to get Device Registration Option, Click on Device Registration.

3. Click the Register Model button to continue.

4. Set Product Name as a simple descriptor

Set Manufacturer Name as anything (because it


doesn’t hugely matter)

Set the Device Type as Speaker (as it matches with


our current project)

Note down this Device Model Id for later use.

Click on Register Model


Click on Next, then Click on Save Traits.

7|Page Manorama Darekar,Gurukul College.


Step 4: Install the SDK and Sample Code on Raspberry PI
1. Update Raspberry Pi

2. Create a directory, and then Copy credential file (downloaded in previous step) to your
directory (with new name credentials.json)

3. Install Python3 and the Python 3 Virtual Environment to our Raspberry Pi.

$ sudo apt-get install python3-dev python3-venv #for Python 3

4. Install the package's system dependencies

$ sudo apt-get install portaudio19-dev libffi-dev libssl-dev

8|Page Manorama Darekar,Gurukul College.


5. Enable python3 as our virtual environment variable

$ python3 -m venv env

6. Install the latest versions of pip and the setuptools.

$ env/bin/pip install setuptools --upgrade

7. Get into this new Python environment that we have set up

$ source env/bin/activate

8. Now Install all the packages that we need to install the Google Assistant Library

$ python -m pip install --upgrade google-assistant-library

$ python -m pip install --upgrade google-assistant-sdk[samples]

9. Install the Python authorization tool on Raspberry Pi

$ pip install --upgrade google-auth-oauthlib[tool]

10. To run the installed Google Authentication library, use following command.

$ google-oauthlib-tool --client-secrets /path/to/client_secret_client-id.json --scope


https://www.googleapis.com/auth/assistant-sdk-prototype --scope
https://www.googleapis.com/auth/gcm --save --headless

9|Page Manorama Darekar,Gurukul College.


This command will generate a URL, Right Click on above URL, Copy it.

You will need to go to in your web browser, Paste above URL in address bar.

On this screen login to your Google account, if you have multiple accounts make sure you
select the one you set up your API key with.
Click on Allow

11. Copy the authentication code and paste it back into your terminal and press enter.

10 | P a g e Manorama Darekar,Gurukul College.


12. if the authentication was accepted, you received a message credentials saved

Step 5: Run the Sample Code


Finally, we have finished setting up everything we need to run the Google Assistant sample on
our Raspberry Pi. Run the software by running the following command on your Raspberry Pi.

$ googlesamples-assistant-pushtotalk --project_id my-dev-project --device_model_id


my-model-id

Use Project ID and Model ID created in previous steps.

11 | P a g e Manorama Darekar,Gurukul College.


Using the Google Assistant on the Raspberry Pi
 Now that we have finally fully authorized our Raspberry Pi as Google Assistant.
 So for next time login, if you want to run the Google Assistant software without having to
go through the entire tutorial, follow above steps
 Start a new terminal session and set it into virtual environment.(source env/bin/activate)
 To start up the push to talk sample, run the googlesamples-assistant-pushtotalk command,
this time we do not need to write in the project id or the device id as these were cached
when we first utilized the push to talk tool.
$ source env/bin/activate
$ googlesamples-assistant-pushtotalk

Getting the Google Assistant to start up on boot


Up to this time, you have got your Google Assistant up and running
Now you will likely want to get it to start up on boot rather than having to go to the effort of entering
the commands every time.
The easiest way to achieve this is to create a service for it. This service will allow the Google assistant
to run in the background on the Raspberry Pi and easily allow us to retain control over it.
Please follow below tutorial
https://drive.google.com/open?id=1dYSHka8jSAOaCrhGaKNQ28lA9GHaO8BY

That's all!!!
Thank you….

12 | P a g e Manorama Darekar,Gurukul College.

You might also like