Raspberry Pi is a single board computer which is also an IoT device. Using this you can use a Linux desktop and also do awesome IoT projects. We all know Alexa is a powerful virtual assistant made by Amazon. In the other hand, every mobile google assistant comes in-built. Both has its own advantages and disadvantages. So it will be very good if we can run both assistants on the same smart speaker.
In this post I will show you how to Simultaneously Run Alexa And Google Assistant On Raspberry Pi 3B+.
Components Used:(Click to Buy)
Install Raspbian OS
First of all, we have to install the latest Raspbian OS in our Raspberry Pi 3B+. I already a dedicated post for this. Please visit the following post for the guide of Raspbian OS Installation.
Install Alexa & Google
To Install Alexa & Google on Raspberry Pi, Follow these posts.
Do not make those two to run on startup as said on those posts using crontab.
Now we have to make a python file in any directory. I am creating a file names “assistant.py” inside home directory.
Now make that file executable by going to properties of the file and make all 3 options to anyone.
Now we have to paste the following code in the file and save it.
os.system("nohup bash /home/pi/Desktop/alexa.sh > /dev/null 2>&1 &")
os.system("nohup bash /home/pi/Desktop/google.sh > /dev/null 2>&1 &")
Here we are basically calling those two shell scripts (made in Alexa & google assistant posts) on the desktop using python 3. Here scripts will run in background and output will be ignored.
Start on Boot
To run Alexa & Google assistant both on startup, we have to add this python file into crontab. To do this first run the following command.
After this add the following line in last line.
@reboot python3 /home/pi/assistant.py
Now Save it by pressing Ctrl+O & exit it by Ctrl+X.
From now, after every startup of Raspbian OS, Alexa & Google Assistant will start automatically and run Simultaneously.
You will notice high CPU (>80%) usage for running in background. So I do not prefer running it on start up. I recommend start it manually from mobile using VNC remote session.
To disable automatic startup, just remove the line you added in crontab & you will be done.
For asking question to Google assistant say “OK Google” followed by your question.
To ask question to Amazon Alexa say “Alexa” followed by your question.
Watch Video Tutorial