Sunspot Home

Using Google Assistant to control and read from my LAN devices

More notes for backup and a bad memory - -
These notes will be upgraded at random times
This first hack is WORKING but not yet tidy, , , ,

Objective - Say "OK Google" then a verbal command to control IFTTT linked to the Maker Channel to send GET http requests
to CGI scripts running on linux devices on my home and garden LAN
Then use the Raspberry Pi to perform actions on other LAN devices, Arduinos etc.

NEW!!
I can now run local bash scripts etc by speaking a command and using Google AIY code as in the cardboard kit.
That code is much easier than the full Google Assistant code for a novice like me to use !
So there is now no need for IFTTT to gain verbal control of you LAN devices
- SEE BELOW!

Google Assistant with wake word "OK Google" or "Hey Google" runs on a raspberry Pi with USB microphone and TV speaker or on-board headphone socket to amplifier and speaker.
It is much the same as an Echo Dot but much easier to hack!

The cardboard Google AIY kit given away with the MagPi magazine can only respond to a wake word with a hack (it is designed to use a button).
I find that the hack has a random delay after responding to the wake word and becoming live for a verbal command.
The Google Assistant with built in wake word responds without delay.

I loaded Google assistant onto a Jessie Light Pi as given here -
https://developers.google.com/assistant/sdk/overview
I tried a cheap USB microphone but the recordings were faint and noisy


A Sony PlayStaion 3 USB Microphone (eBay second hand) gave very clear recordings and Google responded when I was a room away

I have yet to test the camera.

SID'S BLOG - add 2 LEDs
https://blog.arevindh.com/2017/05/20/voice-activated-google-assistant-on-raspberry-pi-with-visual-feedback/
Sid shows how to add 2 LEDs - one to show that the wake word is being heard followed by another LED that comes on to show that a verbal command can be spoken

I used IFTTT to link Google Assistant to the Maker Channel to send GET requests to html servers running cgi scripts on my LAN
This is the same as for my Alexa tests shown here -
http://www.sunspot.co.uk/Projects/raspberrypi_LAN_master/Alexa/IFTTT_Maker/IFTTT_Maker.html


The Cardboard AIY kit has software that allows you to control GPIO etc by verbal command.
- I have not yet seen how to do that with this version (hence my use of IFTTT)
Please email me if you know how to control GPIO etc on the master Raspberry Pi using this version!!

But now the AIY (cardboard kit) project allows the use of "OK Google" as a trigger word!

I followed this -
http://eduncan911.com/stem/embedded/aiy-google-assistant-upgrades-may-2017.html
and this -
http://www.androidauthority.com/build-google-assistant-raspberry-pi-770296/

In order to have the Pi run bash scripts I used this for action.py-
http://www.sunspot.co.uk/Projects/raspberrypi_LAN_master/Google_Assistant/action.py.txt

Below the section -

# =========================================
# Makers! Implement your own actions here.
# =========================================
the key line is - 

actor.add_keyword( _('read the data'), SpeakShellCommandOutput( say, "/home/pi/test/bashread.sh", _('there is no data')))

/home/pi/test/bashread.sh is -

#!/bin/bash
read VAR1 < data.txt
echo $VAR1

and data.txt in the same folder contains -
44

I say "OK Google, read the data"
She says "44"

I think that the speech is created locally - it sounds a bit "robot"
So now we can use bash etc to do anything following a verbal command.



    

Please email me if you want to swap notes

SUNSPOT HOME