Now that you have everything set up, it's time to use the Google Voice Assistant. Let's put a script on the Pi, run it and look at some of the things it can do.

First make sure you are in the Virtual Environment. If you have exited for some reason such as restarting the Pi, you can get back in by typing:

source env/bin/activate

Running the Google Assistant Script

We wrote a script that will make use of the on-board DotStar LEDs and button on the BrainCraft HAT to make it easier to use the Google Assistant. Below is the full script. You can either save it onto your Pi by copying it below or you can type:


and it will save it directly to the Pi.

Associating your Project ID and Model ID

Google recently made a change that requires you to run a sample script that will associate your Hardware Model ID and Project ID for the main script to work. This step only needs to be done once. To get your Project ID you can open your client_secrets.json file and find it there.

If you saved your Model ID during the Google Setup, you're all set. If not, you can find it by following these steps.

Open the Actions console at Select your Project.

Click the Develop Tab at the top, then select Device Registration, then click on the product name.

Run the following command, swapping out [Your Project ID] and [Your Model ID] with the appropriate values:

googlesamples-assistant-pushtotalk --project-id [Your Project ID] --device-model-id [Your Model ID]

Press Control-C a couple of times to exit the script. Now you're ready to run the project script.

Running the Project Script

To run the main script, type:


Wait a few seconds until the script tells you to press a button and then press the button on the BrainCraft HAT. The lights should turn green, meaning it is waiting for you to give it a command or ask a question.

Phrases to Try

Try asking some of these phrases:

What is the weather?

What movies are playing?

What is your favorite color?

What are the directions to the nearest grocery store?

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

This page (Usage) was last updated on Mar 08, 2024.

Text editor powered by tinymce.