Smart Speaker With Alexa and Google Assistant

268

2

5

Posted

Introduction: Smart Speaker With Alexa and Google Assistant

First Time Author Contest 2018

This is an entry in the
First Time Author Contest 2018

Epilog Challenge 9

This is an entry in the
Epilog Challenge 9

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:-

Product Information

  1. On this page you'll provide information about your product.
  2. Product Name - This is what gets displayed to users when they register an instance of the product with Amazon.
  3. Product ID - A simple identifier for your product.
  4. When asked if your product is an app or device, select Device.
  5. When asked if your product will use a companion app, select Yes.
  6. For Product Category, select Other, and enter "Rapsberry Pi Project". Note: For a commercial product, you should select the best option available.
  7. Enter a brief description. For example: My first Pi project.
  8. 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.
  9. You can skip uploading an image for now. This content is used on the manage your content and devices screen on amazon.com.
  10. When asked if you will distribute this project, select No. Note: For a commercial product, you should select Yes.
  11. When asked if this product is for children, select No.Click Next.

Security Profile

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:

Click Update.

You are now ready to generate self-signed certificates.

Enable Security Profile

  1. Open a web browser, and visit https://developer.amazon.com/lwa/sp/overview.html.
  2. Near the top of the page, select the security profile you created earlier from the drop down menu and click Confirm.
  3. Enter a privacy policy URL beginning with http:// or http:// or
  4. For this example, you can enter a fake URL such as http://example.com.
  5. [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.
  6. Click Save.

Step 4: Create Your Google Developer Account

Next up, create a Google Developer Account and enable the Google Assistant API. That is pretty much it for Google.

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:

git clone https://github.com/shivasiddharth/Assistants-Pi

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

sudo /home/pi/Assistants-Pi/audio-test.sh

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:

sudo /home/pi/Assistants-Pi/installer.sh 

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: Make Your Assistants Auto Start on Boot

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 make them auto start on boot:

  • Pi 3 and Pi2 users, open the gassistpi-ok-google.service in the /home/pi/Assistants-Pi/systemd folder and add your project-id and model-id in the indicated points.
  • Pi Zero users, open the gassistpi-push-button.service in the /home/pi/Assistants-Pi/systemd folder and add your project-id and model-id in the indicated points.
NOTE: Remove the single quotation marks when you enter your project-ID and Model-ID. A new folder named ´Model ID` will be created and it will provide you your model ID.

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.

Share

Recommendations

  • Epilog Challenge 9

    Epilog Challenge 9
  • Gluten Free Challenge

    Gluten Free Challenge
  • First Time Author Contest 2018

    First Time Author Contest 2018
user

We have a be nice policy.
Please be positive and constructive.

Tips

1 Questions

Where can I find the model ID please help.

0

When you start your installation for Google Assistant, and have provided it with the name of your .json file you downloaded from your Google developer account, the installation for Google Assistant will start (do not rename that file or it will not work). After 30 seconds or so, a text file name model id will be created in your home/pi directory. It will provide you your model id. Hope this helped.

Comments

Sorry guys, I forgot to add some crucial information when I first posted this instructable. I have updated it, so it should work well and good now.