Google Assistant on Raspberry Pi

Configurare noua (How To)

Situatie

Step 1: Install Operating System

  1. Download Raspberry Pi OS Lite (no desktop required)
  2. Flash it using Raspberry Pi Imager or Balena Etcher
  3. Enable SSH (optional but recommended):
    • Place an empty file named ssh in the boot partition
  4. Boot your Raspberry Pi and connect:
ssh pi@raspberrypi.local
Step 2:  sudo apt update && sudo apt upgrade -y

Step 3:  Plug in your microphone and speaker, then run:

arecord -l
aplay -l

Test recording:

arecord test.wav
aplay test.wav

If you hear playback, your audio setup is working correctly.

Step 4: Enable Google Assistant API

  1. Go to Google Cloud Console
  2. Create a new project
  3. Enable the Google Assistant API
  4. Create credentials:
    • OAuth Client ID
    • Choose “Desktop App”
  5. Download the JSON credentials file to your Raspberry Pi

Step 5: Install Google Assistant SDK

Install dependencies:

sudo apt install python3-dev python3-venv python3-pip portaudio19-dev libffi-dev libssl-dev -y

Create a virtual environment:

python3 -m venv env
source env/bin/activate

Install required Python packages:

pip install –upgrade pip setuptools wheel
pip install google-assistant-sdk[samples]
pip install google-auth-oauthlib

Step 6: Authenticate

Run:

google-oauthlib-tool –client-secrets YOUR_FILE.json \
–scope https://www.googleapis.com/auth/assistant-sdk-prototype \
–save –headless

Follow the provided link, log in, and paste the authentication code back into the terminal.

Step 7: Run Google Assistant

Test the assistant:

googlesamples-assistant-pushtotalk –project-id YOUR_PROJECT_ID

Press Enter, speak your command, and the assistant should respond.

Step 8: Enable Hotword (“Hey Google”)

The official SDK does not currently support native hotword detection, but you have two options:

Option A: Push-to-talk

  • Use keyboard input or a physical button to trigger listening

Option B: Third-party wake word engines

  • Snowboy (deprecated but still usable)
  • Porcupine (recommended alternative)

Step 9: Auto-Start on Boot

Create a systemd service:

sudo nano /etc/systemd/system/googlepi.service

Example configuration:

[Unit]
Description=Google Assistant[Service]
User=pi
WorkingDirectory=/home/pi
ExecStart=/home/pi/env/bin/googlesamples-assistant-pushtotalk –project-id YOUR_PROJECT_ID
Restart=always

[Install]
WantedBy=multi-user.target

Enable and start the service:

sudo systemctl enable googlepi.service
sudo systemctl start googlepi.service

Solutie

Tip solutie

Permanent

Voteaza

(0 din 1 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?