How do I get google-assistant-demo to run on boot?
I can run it manually with
$ source /home/pi/env/bin/activate
(env) $ google-assistant-demo
But I want to run it on start up, in CLI Mode or GUI mode. I want it to run inside its virtual environment (venv). All in the background without interfering with any terminal or SSH session.
Using this as a base : https://youtu.be/ohUszBxuQA4?t=774 – thanks to Eric Parisot
However with a few changes.
You will need to download the src file he uses and extract its contents into /home/pi/src/
I did not run gassist.sh
as sudo
as he does in the video, as it gave me the following error:
OpenAlsaHandle PcmOpen: No such file or directory
[7689:7702:ERROR:audio_input_processor.cc(756)] Input error
ON_MUTED_CHANGED:
{‘is_muted’: False}
ON_START_FINISHED
ON_ASSISTANT_ERROR:
{‘is_fatal’: True}
[7689:7704:ERROR:audio_input_processor.cc(756)] Input error
ON_ASSISTANT_ERROR:
{‘is_fatal’: True}
Fix: DO NOT run as sudo
If gassist.sh
gives an error about RPi.GPIO
(the author's script activates GPIO pin 25 when the assistant is listening and so requires RPi.GPIO to be installed within the environment) you need to do https://youtu.be/ohUszBxuQA4?t=580:
$ source /home/pi/env/bin/activate
(env) $ pip install RPi.GPIO
(env) $ deactivate
And then I did sudo nano /etc/profile
and the appended this to the end:
#Harvs was here on 24/06/17
if pidof -x "gassist.sh" >/dev/null; then
echo ""
echo "/etc/profile says:"
echo "An instance of Google Assistant is already running, will not start again"
echo ""
else
echo "Starting Google Assistant..."
echo "If you are seeing this, perhaps you have SSH within seconds of reboot"
/home/pi/src/gassist.sh &
fi
This checks if the assistant is already running and starts it if it is not. Note if your start-up script is called something other than gassist.sh
you will have to edit the above code
And now it works perfectly, inside the virtual environment, and in boot to CLI mode! :)