Google Voice Kit Autostart

Struggling to have your Google Voice Kit start automatically after a reboot? This post might help you.

My dad and I picked up the Google Voice Kit as a weekend project. This is a prototyping kit that enables you to use Google Assistant API and natural language processing in your applications.

The kit is powered by a Raspberry Pi 3, includes a 3″ wired loudspeaker and Voice HAT stereo microphone and accessory boards, an LED illuminated arcade button, and various connectors. All that fits in a nifty folded cardboard cube.

I breezed through the physical assembly. Downloading and burning the latest Voice Kit SD image with Etcher to a microSD card also went without a hitch.

I used the wrong USB powersupply for my Pi and was stumbled why the Raspberry Pi would continuously reboot. Turned out the power supply would not provide enough voltage (~ 5V) and Pi didn’t like it. Swapping out the power supply resolved the issue.

Next step was to hook up a VNC Viewer to it so I could ditch the keyboard, mouse, and the HDMI connection. Click the round Pi button at the top left corner, then go to Preferences -> Raspberry Pi Configuration. Select the Interfaces tab, then Enable VNC, and close with OK. Make a note of the Pi’s IP address. (Hover over WiFi icon at the right top corner and you will see the IP address displayed in a tooltip.) Download the VNC Viewer and you should now be able to connect to the Pi wirelessly!

The instructions in the book (Step 13 on page 45) tell you to run

src/assistant_library_demo.py

but the path needs to be corrected to

src/examples/voice/assistant_library_demo.py

After that, everything worked great. The device immediately came to live and began responding to my questions! However, every time I would turn it off (for example to move it from one room to another), I would need to VNC to it once again and start the above program… far from ideal.

However, making the above utility start automatically proved challenging. There were quite a few suggestions and even videos online on how to do this, but none had worked for me. I summoned the help of my dad who is an experienced engineer and can fix nearly anything.

Here is what you need to do to make Google Assistant start automatically at boot.

Make a copy of the assistant_library_demo.py script and save it as main.py by running the below commands from the Terminal window:

cd /home/pi/AIY-projects-python/src/examples/voice
cp assistant_library_demo.py main.py

As super user, create and save the following file using  nano or vim text editors:

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

Insert the following content into it:

[Unit]
Description=Google Assistant
After=network.target ntpdate.service

[Service]
Environment=DISPLAY=:0
Type=simple
ExecStart=/home/pi/AIY-projects-python/src/examples/voice/main.py
Restart=on-failure
User=pi
Group=pi
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=google_assistant

[Install]
WantedBy=multi-user.target

(The entries here that make it all work are the “After” instruction that starts the assistant service only  after the network is up, and the “Environment” instruction that allows it to run headless without a display.)

If you are running the Google Assistant from the terminal, first stop it by pressing Ctrl+C. Then enable and start the new service:

sudo systemctl enable google_assistant.service
sudo service google_assistant start

Re-run the second line with “stop” instead of “start” to shutdown the service. You can also use “status” command to check on the service’s status. It comes handy when you are not sure whether the service is running.

1 thought on “Google Voice Kit Autostart

  1. In the original instructions was the following command:
    # Create the symlink
    sudo ln -s `pwd`/assistant_grpc_demo.service /lib/systemd/system

    Is ‘pwd’ literal or to be replaced with my actual password. I assumed the latter and started the service; ti worked just fine. However, after I rebooted, the connection to the kit via SSH is refused.

Leave a Reply

Your email address will not be published. Required fields are marked *