Introduction: Smart Speaker With Alexa and Google Assistant
These days, smart assistants are taking the tech world by storm. Amazon’s Alexa and Google’s Assistant are now being embedded within every device, be it car devices, showers, or practically almost everything that was unveiled at CES 2018. But despite all that, the most selling devices sporting these assistants are the company’s own products, that is, the Amazon Echo and the Google Home.
While both the smart speakers are great by themselves, wouldn’t it be great to have the power of them both on one device? Well, now you can. I have created my own guide of how to create your own smart speaker having the capabilities of both Google Assistant and Amazon Alexa. So without any further ado, let’s get right into it.
Step 1: Things You Need:
Step 2: Install the NOOBS Package:
To start off, you’ll first need to set up your Raspberry Pi. To do so, simply download theNOOBS Package, extract it to your microSD card and plug it into your Raspberry Pi. Hook up the USB Keyboard, Mouse, Mic and the Speaker to the Pi and turn it on. You will now get a first time setup. Simply select Debian and install to start the installation of Debian on your Raspberry Pi.
Step 3: Create Your Amazon Developer Account
Now, you need to create your Amazon Developer Account and create a security profile. You can follow these instructions to do so :
Login to Amazon Developer Portal - developer.amazon.com
Click Alexa -> Alexa Voice Service -> Get Started.
Click Create Product.
Fill-in these values and save:-
- On this page you'll provide information about your product.
- Product Name - This is what gets displayed to users when they register an instance of the product with Amazon.
- Product ID - A simple identifier for your product.
- When asked if your product is an app or device, select Device.
- When asked if your product will use a companion app, select Yes.
- For Product Category, select Other, and enter "Rapsberry Pi Project". Note: For a commercial product, you should select the best option available.
- Enter a brief description. For example: My first Pi project.
- When asked how users will interact with your product, select Touch-initiated and Hands-free. Note: For a commercial product, you should select the options that best describe your product's functionality.
- You can skip uploading an image for now. This content is used on the manage your content and devices screen on amazon.com.
- When asked if you will distribute this project, select No. Note: For a commercial product, you should select Yes.
- When asked if this product is for children, select No.Click Next.
On this page we'll create a new Login with Amazon (LWA) security profile. This associates user data and security credentials with one or more products.
Click Create New Profile. Enter a name and description for your security profile, then click Next. For example:
Security Profile Name: Alexa Voice Service Sample App Security Profile.
- Security Profile Description: Alexa Voice Service Sample App Security Profile Description.
Note: These are suggested values. You provide custom information for Security Profile Name and Security Profile Description.
A Client ID and Client Secret will be generated for you.
Enter your Allowed origins and Allowed return URLs. We need to setup http and httpsroutes for our sample project:
- Allowed Origins: Click "Add Another" and then enter http://localhost:3000 in the text field that appears. Then click "Add Another" and enter http://localhost:3000
- Allowed Return URLs: Click "Add Another" and then enter http://localhost:3000/authresponse in the text field that appears. Then click "Add Another" and enter http://localhost:3000/authresponse
You are now ready to generate self-signed certificates.
Enable Security Profile
- Open a web browser, and visit https://developer.amazon.com/lwa/sp/overview.html.
- Near the top of the page, select the security profile you created earlier from the drop down menu and click Confirm.
- For this example, you can enter a fake URL such as http://example.com.
- [Optional] You may upload an image as well. The image will be shown on the Login with Amazon consent page to give your users context.
- Click Save.
Step 4: Create Your Google Developer Account
Step 5: Preparing for Installation
Before Starting the setup
For Google Assistant
1. Download credentials-.json file (refer to this doc for creating credentials)
2. Place the .json file in/home/pi directory
3. DO NOT RENAME THE JSON FILE
For Amazon Alexa
1. Create a security profile for alexa-avs-sample-app if you already don't have one.
Now, run the following commands one by one to clone the GitHub project and make the installer files executable:
sudo chmod +x /home/pi/Assistants-Pi/prep-system.sh sudo chmod +x /home/pi/Assistants-Pi/audio-test.sh sudo chmod +x /home/pi/Assistants-Pi/installer.sh sudo /home/pi/Assistants-Pi/prep-system.sh
First, OS will be updated and upgraded. Thereafter, you will be prompted to select the audio setup. Select “3” from the options. Now, restart the Raspberry Pi.
Step 6: Testing the Audio
Upon reboot, first, check your audio setup by
The script is interactive, just press “y” if you hear the audio, or “n” if you don’t. In case you don’t hear the audio, you need to check the wires.
Step 7: Installing Alexa and Google Assistant
Now that your system is ready, run the following command to start the installer:
The script will now execute. It is a pretty straightforward script, simply follow the on-screen instructions.
IMPORTANT : I have mentioned before in Step 4 that you have to download the credentials.json file. Place it in you home/pi directory. And also you have to make the changes mentioned in the next step when the installation for Google Assistant starts.
Step 8: How to Start Your Assistants After Rebooting You Pi
Once both the assistants have been installed, you’ll be shown a screen as above. Run the commands one by one to authenticate Alexa. Once you’re through with that, follow these steps to start them on boot:
For Google Assistant:
Open a terminal and execute the following one-by-one
For Amazon Alexa:
Open 3 different terminal and execute every command in a different terminal
cd /home/pi/alexa-avs-sample-app/samples/javaclient && sudo mvn exec:exec cd /home/pi/alexa-avs-sample-app/samples/companionService && sudo npm start cd /home/pi/alexa-avs-sample-app/samples/wakeWordAgent/src && sudo ./wakeWordAgent -e kitt_ai
After executing these commands you should be good to go
Step 9: Conclusion
And that’s it. Your 2-in-1 smart speaker is ready. Also, while you can use the entire setup barebones, I decided to wrap things up inside a nice little cardboard box and apply a black chart paper and giving it some final and personal touches. Also, I think I have pretty much included everything you need to install Alexa and Google Assistant, but still, as they say,
No human being is perfect.
If I have made some mistakes or forgotten something please remind me about it in the comments section.