Multiple Custom Wakewords Activation of Google Assistant

Voice activate Google Assistant SDK on Pi using multiple custom wakewords. Works on Pi 3 and Pi Zero W.

This has been implemented using Snowboy for the hotword service. For some “Mysterious” reason, the assistant.start_conversation of the SDK does not seem to work for forcefully initiated custom wakewords. So I have used the gRPC for custom wakewords and SDK for “Hey Google” wakeword.

Works with Pi3 as well as Pi Zero Pi Zero – forked and modified from warchildmd's repo (https://github.com/warchildmd/google-assistant-hotword-raspi)

Features:

  • Headless auto start on boot with multiple wakeword activation trigger.
  • Locally Control GPIOs without IFTTT, API.AI, ACTIONS.
  • Startup audio and audio feedback for wakeword detection.
  • Safe shutdown RPi using voice command.

Features coming soon:

  • Mute button.
  • Neopixel indicator without Arduino.

This is implemented in Python2 so your existing Google Assistant may not work. So please start by making a fresh copy of latest Raspbian.

Install Audio Config Files

  • Update OS and Kernel
sudo apt-get update  
sudo apt-get install raspberrypi-kernel  
  • Restart Pi
  • Choose the audio configuration according to your setup. (Run the commands till you get .bak notification in the terminal)

3.1. USB DAC users:

sudo chmod +x /home/pi/GassistPi/audio-drivers/USB-DAC/scripts/install-usb-dac.sh
  
sudo /home/pi/GassistPi/audio-drivers/USB-DAC/scripts/install-usb-dac.sh 

3.2. AIY-HAT users:

sudo chmod +x /home/pi/GassistPi/audio-drivers/AIY-HAT/scripts/configure-driver.sh
  
sudo /home/pi/GassistPi/audio-drivers/AIY-HAT/scripts/configure-driver.sh  
sudo chmod +x /home/pi/GassistPi/audio-drivers/AIY-HAT/scripts/install-alsa-config.sh  
sudo /home/pi/GassistPi/audio-drivers/AIY-HAT/scripts/install-alsa-config.sh 

3.3. USB MIC AND HDMI users:

sudo chmod +x /home/pi/GassistPi/audio-drivers/USB-MIC-HDMI/scripts/install-usb-mic-hdmi.sh 
sudo /home/pi/GassistPi/audio-drivers/USB-MIC-HDMI/scripts/install-usb-mic-hdmi.sh 

3.4. USB MIC AND AUDIO JACK users:

sudo chmod +x /home/pi/GassistPi/audio-drivers/USB-MIC-JACK/scripts/usb-mic-onboard-jack.sh
  
sudo /home/pi/GassistPi/audio-drivers/USB-MIC-JACK/scripts/usb-mic-onboard-jack.sh 

3.5. CUSTOM VOICE HAT users:

sudo chmod +x /home/pi/GassistPi/audio-drivers/CUSTOM-VOICE-HAT/scripts/custom-voice-hat.sh
  
sudo /home/pi/GassistPi/audio-drivers/CUSTOM-VOICE-HAT/scripts/custom-voice-hat.sh  
sudo chmod +x /home/pi/GassistPi/audio-drivers/CUSTOM-VOICE-HAT/scripts/install-i2s.sh  
sudo /home/pi/GassistPi/audio-drivers/CUSTOM-VOICE-HAT/scripts/install-i2s.sh 

Those Using HDMI/Onboard Jack, make sure to force the audio:

sudo raspi-config  

Select advanced options, then audio and choose to force audio.

Those using any other DACs or HATs install the cards as per the manufacturer's guide and then you can try using the USB-DAC config file after changing the hardware IDs.

  • Restart Pi.
  • Check the speaker using the following command:
speaker-test -t wav  

Continue After Setting Up Audio

  • Download credentials—>.json file
  • Place the .json file in/home/pi directory
  • Rename it to assistant—>assistant.json
  • Using the one-line installer for installing Google Assistant and Snowboy dependencies Pi3 and Armv7 users use the “gassist-installer-pi3.sh” installer and Pi Zero users use the “gassist-installer-pi-zero.sh” installer. Snowboy installer is common for both.

4.1 Make the installers executable:

sudo chmod +x /home/pi/GassistPi/scripts/gassist-installer-pi3.sh
sudo chmod +x /home/pi/GassistPi/scripts/gassist-installer-pi-zero.sh 
sudo chmod +x /home/pi/GassistPi/scripts/snowboy-deps-installer.sh    

4.2 Execute the installers (Run the snowboy installer first. Don't be in a hurry and Don't run them in parallel, Run them one after the other:

sudo  /home/pi/GassistPi/scripts/snowboy-deps-installer.sh 
sudo  /home/pi/GassistPi/scripts/gassist-installer-pi-zero.sh 
sudo  /home/pi/GassistPi/scripts/gassist-installer-pi3.sh    
  • Copy the Google Assistant authentication link from terminal and authorize using your Google account.
  • Copy the authorization code from browser onto the terminal and press enter.
  • Move into the environment and test the google assistant according to your board.
source env/bin/activate  
google-assistant-demo 
googlesamples-assistant-pushtotalk
  • After verifying the working of assistant, close and exit the terminal.

Headless Autostart on Boot Service Setup

  • Make the service installer executable:
sudo chmod +x /home/pi/GassistPi/scripts/service-installer.sh 
  • Run the service installer:
sudo /home/pi/GassistPi/scripts/service-installer.sh
  • Enable the services: Pi3 and Armv7 users enable both the services for custom wakewords. Pi Zero users enable snowboy services alone:
sudo systemctl enable gassistpi-ok-google.service 
sudo systemctl enable snowboy.service
  • Start the service: Pi3 and Armv7 users start both the services for custom wakewords. Pi Zero users start snowboy services alone:
sudo systemctl start gassistpi-ok-google.service 
sudo systemctl start snowboy.service   

Restart and enjoy!

Voice Control of GPIOs and Pi Shutdown

The default GPIO and shutdown trigger word is “trigger” if you wish to change the trigger word, you can replace the ‘trigger'in the main.py(src folder) and assistant.py(snowboy folder) code with your desired trigger word.

Similarly, you can define your own device names under the variable name var.

The number of GPIO pins declared should match the number of devices.

For NeoPixel Indicator

  • Replace the main.py in src folder with the main.py from Neopixel Indicator Folder.
  • Reboot
  • Change the Pin numbers in the given sketch according to your board and upload it.

Source: Multiple Custom Wakewords Activation of Google Assistant


About The Author

Muhammad Bilal

I am highly skilled and motivated individual with a Master's degree in Computer Science. I have extensive experience in technical writing and a deep understanding of SEO practices.

Leave a Comment

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

Scroll to Top