How to use Alexa Google Assistant Raspberry Pi Simultaneously, I will say.
To use Alexa Google Assistant Raspberry Pi Simultaneously we have to follow the steps below
Raspberry Pi is a single-board computer that 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. On the other hand, every mobile google assistant comes in-built. Both have their own advantages and disadvantages. So it will be very good if we can run both assistants on the same smart speaker. So let’s start doing Alexa google assistant raspberry pi.
Components Used:(Click to Buy)
Install Raspbian OS on raspberry pi
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 assistant raspberry pi
To Install alexa google assistant 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 alexa google assistant raspberry pi
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 a high CPU (>80%) used for running in the background. So I do not prefer running it on startup. I recommend starting 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.
Final Words on alexa google assistant raspberry pi
If you have Raspberry Pi 3B 3B+ or 4B, you can try this method to turn your Raspberry pi into a smart speaker for home automation. Sometimes you may see difficulty setting up this or it will not execute successfully. The reason behind it is compatibility between Alexa google assistant SDK & the present Raspbian OS version. Maybe there is some bug on the Raspbian build you are using. So update it to the latest version to fix it.
Some times you may get no sound on speakers for Alexa google assistant raspberry pi. To fix it check your default sound device settings. Sometimes we have multiple sound cards installed. So the last installed sound device is set to default by our OS. Then we have to manually select the sound output device to get sound.
Sometimes your voice may not recognized. The reason behind it your mic has issue. Remember one thing, Raspberry Pi 3B doesn’t have support of Mic. We have to use external USB sound card for alexa google assistant raspberry pi.