Next we want to setup all of the packages on the Raspberry Pi. If you haven't done so already, take a look at our Adafruit BrainCraft HAT - Easy Machine Learning for Raspberry Pi guide if you are using the BrainCraft HAT.

If you are using the Voice Bonnet, you'll want to follow the setup steps in our Adafruit Voice Bonnet guide.

This will take you through all the steps needed to get the Raspberry Pi updated and the BrainCraft HAT or Voice Bonnet all set up to the point we need to continue.

Upload the client-secret.json OAuth 2.0 Credentials file that you downloaded in the Google Setup section to your Raspberry Pi and place it in your home directory. We're going to assume this is located at /home/pi. If it differs, please change any commands accordingly.

Next we're going to check that we have the required packages and setup a Virtual Environment.

Download: file
cd ~
sudo apt-get update
sudo apt-get install python3-dev python3-venv
python3 -m venv env
env/bin/python -m pip install --upgrade pip setuptools wheel
source env/bin/activate

Once you are done with that, your prompt should see (env) to the left to indicate you are in a Virtual Environment.

Download: file
sudo apt-get install portaudio19-dev libffi-dev libssl-dev
python -m pip install --upgrade google-assistant-sdk[samples]

Install the Authorization library.

Download: file
python -m pip install --upgrade google-auth-oauthlib[tool]

Generating an OAuth Token

Before we can run the script, we need to generate an OAuth Token. Run the following command:

Download: file
google-oauthlib-tool --scope https://www.googleapis.com/auth/assistant-sdk-prototype --save --headless --client-secrets ~/client_secret.json

The script should provide a URL to visit to generate the token. Go ahead and copy and paste the URL into a web browser.

You may run into an alert that says your app isn't verified. Go ahead and click on the Advanced link.

That will expand the dialog. Click Go to Quickstart (unsafe) or whatever you decided on for a project name.

After all that, it will come up with a confirmation dialog with your account name and the permissions that you are granting. Go ahead and click on Allow.

Finally, you will be given an Authorization Code. Click on the Copy icon and it will get copied to your clipboard.

Paste the Authorization Code back into the script and the token will be generated and saved.

Your Pi should now be all ready to go.

This guide was first published on Oct 21, 2020. It was last updated on Oct 21, 2020.

This page (Device Setup) was last updated on Nov 06, 2020.