Voice activated Google Assistant on Raspberry Pi with visual feedback

How to enable Ok google in Google Home running on raspberry pi.

Add visual notifications

It allows us to understand what is the current state of our Raspberry Pi assistant

Blue Light : Google  Assistant is listening.

Red :Ligh : Google Assistant is saying something.

Schematics 

Coding part

Clone the Google SDK git repository  to home directory .

Now edit the hotword.py file

 

sudo nano /home/pi/assistant-sdk-python/google-assistant-sdk/googlesamples/assistant/library/hotword.py

Modify the contents [ changes/ additions are highlighted ]

Install RPI GPIO in virtual environment 

pip3 install RPi.GPIO

Testing 

Run as a Service

Make sure that you are in virtual environment 

(env) pi@raspberrypi:~ $

else run

source /home/pi/env/bin/activate

 

We need to create an shell script to enable virtual environment “hotword.sh “

nano /home/pi/assistant-sdk-python/google-assistant-sdk/googlesamples/assistant/library/hotword.sh To run as a service you need to create a service file in /lib/systemd/system/ folder

sudo nano /lib/systemd/system/assistant.service Enable and start service

sudo systemctl start assistant.service

Check Status of the service

sudo systemctl status assistant.service

Enable service

sudo systemctl enable assistant.service

All cotents are also in Gist: https://gist.github.com/arevindh/ae50e18394625747e6beae600b10e374

Enable GPIO in env
pip3 install RPi.GPIO

USB Sound Card Adapter
https://goo.gl/Y3RYTq

 

4 thoughts on “Voice activated Google Assistant on Raspberry Pi with visual feedback”

  1. Hey bro im getting this error pls help
    OpenAlsaHandle PcmOpen: No such file or directory
    [1418:1432:ERROR:audio_input_processor.cc(756)] Input error
    ON_MUTED_CHANGED:
    {‘is_muted’: False}
    ON_START_FINISHED
    ON_ASSISTANT_ERROR:
    {‘is_fatal’: True}
    [1418:1434:ERROR:audio_input_processor.cc(756)] Input error
    ON_ASSISTANT_ERROR:

  2. hey, nice overview but i’m a very basic beginner.. i was wondering if you could add the terminal commands inbetween each code block. I’m aware of the first one but not sure where to put the blocks 2 & 4 of code. i see block 3 is in the terminal.

  3. Thanks – it works as you say but I do get this at the start-
    =============================================================
    (env) [email protected]:~ $ google-assistant-demo
    OpenAlsaHandle PcmOpen: Device or resource busy
    [1001:1014:ERROR:audio_input_processor.cc(756)] Input error
    ON_MUTED_CHANGED:
    {‘is_muted’: False}
    ON_START_FINISHED
    ON_ASSISTANT_ERROR:
    {‘is_fatal’: True}
    [1001:1016:ERROR:audio_input_processor.cc(756)] Input error
    ON_ASSISTANT_ERROR:
    {‘is_fatal’: True}
    =============================================================
    then it works but prints out nothing new.
    (The printouts were useful on the original)

    2nd issue
    I would love to control other GPIO on command like in the AIY cardboard software.
    (I can run that with usb microphone and external speaker on a Pi3)
    Can you say how to add thet to your code?

Leave a Reply

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