• Skip to primary navigation
  • Skip to main content
  • Skip to footer

Miguel Ángel Antolín Bermúdez

Personal portfolio & Blog

  • Home
  • Blog & posts
You are here: Home / Engineering / how to / Google assistant on Raspberry pi

Coding, Engineering, how to, Raspberry Pi / 28th January 2018

Google assistant on Raspberry pi

Running Google Assistant on a Raspberry Pi turns it into a fully self-hosted smart speaker you control completely. This Google Assistant Raspberry Pi guide covers audio device configuration, obtaining OAuth credentials, and running the assistant for the first time.

Google Assistant Raspberry Pi: what you need

  • Raspberry Pi 2 or 3 (Pi 3 recommended for the extra CPU headroom)
  • USB microphone
  • Speaker via 3.5 mm jack or USB
  • A Google account with access to the Google Cloud Console

Step 1 — Configure audio devices

List available recording devices and note the card and device numbers for your USB microphone:

arecord -l

List playback devices:

aplay -l

Create ~/.asoundrc, replacing <card> and <device> with your values from above:

pcm.!default {
  type asym
  capture.pcm "mic"
  playback.pcm "speaker"
}
pcm.mic {
  type plug
  slave { pcm "hw:<card>,<device>" }
}
pcm.speaker {
  type plug
  slave { pcm "hw:<card>,<device>" }
}

Test playback:

speaker-test -t wav

Record and play back a 5-second clip to confirm the microphone works:

arecord --format=S16_LE --duration=5 --rate=16000 --file-type=raw out.raw
aplay --format=S16_LE --rate=16000 out.raw

Step 2 — Create a Google Cloud project

  1. Go to the Google Cloud Console and create a new project.
  2. Enable the Google Assistant API for that project.
  3. Go to APIs & Services → Credentials and configure the OAuth consent screen.
  4. Click Create Credentials → OAuth client ID. Choose Desktop app and give it a name.
  5. Download the resulting JSON file — this contains your client ID and secret.

Step 3 — Install the Assistant SDK

Copy the downloaded JSON to your Pi, rename it to assistant.json, and place it in /home/pi/. This is the last configuration step for your Google Assistant Raspberry Pi setup. Then:

git clone -b voicekit https://github.com/google/aiyprojects-raspbian.git ~/voice-recognizer-raspi
cd ~/voice-recognizer-raspi

scripts/install-deps.sh
sudo scripts/install-services.sh
ln -s assistant_library_with_local_commands_demo.py src/main.py

sudo apt-get install python3-dev python3-venv
python3 -m venv env
env/bin/python -m pip install --upgrade pip setuptools

source env/bin/activate
python3 src/main.py

Your Google Assistant Raspberry Pi is now authorised. The first run prints an authorisation URL. Open it in a browser, grant permissions, and paste the code back into the terminal. Your credentials are saved locally — you will not need to repeat this.

Once authorised, say “Ok Google” and ask your new assistant a question. You now have a fully self-hosted Google Assistant running on a Raspberry Pi. This project is based on the Google AIY Voice Kit. More tutorials on the blog.

Filed Under: Coding, Engineering, how to, Raspberry Pi Tagged With: Google assistant, google-assistant,raspberry-pi,python,gpio,voice,smart-home,sdk, GPIO, Python, Raspberry

Footer

Find me at

  • GitHub
  • LinkedIn

Recent Posts

  • Git for solo developers: the workflow that actually works
  • Self-hosting Vaultwarden on a VPS: your own Bitwarden server
  • Docker on a Raspberry Pi: running containers on ARM
  • WireGuard VPN on a Raspberry Pi: replace OpenVPN in 15 minutes
  • Claude Code on Mac: the complete setup guide

© 2026 · Made with ❤️ in Seville