The Google Home is useful to have around the home.It is a beautiful device with built-in Google Assistant — A state of the art digital personal assistant by Google. It can play media, save your reminders and notes, tell you the length of your commute, do home automation.It can be placed anywhere at your home and it will do some amazing things for you, but, it’s an expensive proposition if you’re not sure you’ll use it. Good news though, you can make a fully-functional one using a Raspberry Pi.
By the end of this guide, you’ll have a fully functioning Google Home that responds to your voice commands. Otherwise, it’s an Assistant with all the features of Google Home. Which means it can do unit conversions, play media, check scores, read audio books to you, check the weather, and tons more. It will also work with a variety of home automation devices like smart light bulbs, so you can control them with your voice. Like the real Google Assistant, your DIY Google Home can be linked up to add more features, like adding to-dos to Evernote or to get a notification on your phone when the timer goes off.
You'd Need:
All the things gathered, connected and plugged in, Let's get it started.
arecord -l
pi@raspberrypi:~ $ arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
You can see that your USB device is attached to card 1 and the device id is 0. Raspberry Pi recognizes card 0 as the internal sound card, that is, bcm2835 and other external sound cards as external sound cards named card 1, card 2 and following...
sudo nano /etc/asound.conf
pcm.!default {
type asym
capture.pcm "mic"
playback.pcm "speaker"
}
pcm.mic {
type plug
slave {
pcm "hw:1,0"
}
}
pcm.speaker {
type hw
card 0
}
ctl.!default {
type hw card 0
}
This will set your external mic (pcm.mic) as the audio capture device (pcm!.default) and your inbuilt sound card (card 0) as the speaker device.
sudo nano .asoundrc.
sudo raspi-config
Front Left, Front Right
speaker-test -t wav
arecord --format=S16_LE --duration=5 --rate=16k --file-type=raw out.raw
aplay --format=S16_LE --rate=16k out.raw
Our hardware is set.
sudo apt-get update
sudo apt-get upgrade
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
python -m pip install --upgrade google-assistant-library
(env) python -m pip install --upgrade google-auth-oauthlib[tool]
(env) google-oauthlib-tool --client-secrets "JSON_FILE_PATH" --scope https://www.googleapis.com/auth/assistant-sdk-prototype --save --headless
InvalidGrantError
then an invalid code was entered. Try again.
Please go to this URL: https://...
Enter the authorization code:
pip install RPi.GPIO
cd /home/pi
sudo nano main.py
sudo nano google-assistant-init.sh
#!/bin/sh
/home/pi/env/bin/python3 -u /home/pi/main.py
sudo chmod +x google-assistant-init.sh
You can run google-assistant-init.sh to initiate the Google Assistant any time.
sudo nano /home/pi/.config/lxsession/LXDE-pi/autostart
@lxterminal -e "/home/pi/google-assistant-init.sh"
sudo nano /etc/profile
sudo /home/pi/google-assistant-init.sh
What exactly is different about this Home Pi? Nothing, except expenses. The end result is basically the same, you can activate your DIY Google Home by saying the wake word “Ok Google/ Hey Google,” and the device works just like a real Assistant.You can do many daily activities with your Google Home. If you want to perform your custom tasks like turning off the light, checking the door, you can do it with integrating Google Actions in your Google Assistant. If you have any trouble with starting the Google Assistant, leave a comment below. I will try to resolve them as much as I can.