Next you'll 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.
These guides 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. In either case, make sure to install the 32-bit Lite version of Raspberry Pi OS.
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.
cd ~ sudo apt-get update sudo apt-get install -y python3-dev python3-venv pulseaudio 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.
A recent change to a Google SDK dependency requires rust to be installed and the version of rust included in apt-get is too low of a version to work. To install a more recent version, use the following commands:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
After it finishes running, you'll need to add it to your path:
export PATH=$PATH:/home/pi/.cargo/bin source "$HOME/.cargo/env"
Install the Authorization library:
pip3 install --upgrade google-auth-oauthlib[tool]
Install the SDK with:
sudo apt install -y portaudio19-dev libffi-dev libssl-dev pip3 install --upgrade google-assistant-library git clone https://github.com/adafruit/assistant-sdk-python.git cd assistant-sdk-python/google-assistant-sdk/ pip install . cd
Install Additional Libraries:
pip install --upgrade pyaudio sounddevice tenacity google-assistant-grpc google-api-python-client adafruit-circuitpython-dotstar
Generating an OAuth Token
Before we can run the script, we need to generate an OAuth Token. Run the following command:
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 Continue link.
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 Continue.
Finally, you will be given an Authorization Code. Click on the Copy icon and it will get copied to your clipboard.
Your Pi should now be all ready to go.
Text editor powered by tinymce.