Family Encyclopedia >> Electronics

How to Create an Amazon Echo with Raspberry Pi

Many people today use assistive software at home and in the office to help them with their daily tasks. There are many different designs to buy, but did you know you can make your own? Amazon Developer lets you use Alexa software to build your own Amazon Echo with Raspberry Pi.

ContentsMaterialsSign up for an Amazon developer accountCreate your device on Amazon DeveloperCreate your security profileClone the Alexa sample appUpdate the installation script by adding your credentialsRun the installation scriptAll three terminalsTerminal 1Terminal 2Terminal 3Test it

Materials

For this project you will need:

  • The Raspberry Pi 3 or Pi 2 Model B and the Micro-USB power cable
  • Micro SD card (minimum 8GB) – If you don't have an operating system installed, there is an easy-to-use operating system called NOOBS (New Plug and Play Software). The easiest way to get NOOBS is to buy an SD card with NOOBS preloaded.
  • Mini USB 2.0 microphone
  • External speaker and 3.5mm audio cable
  • USB keyboard and mouse and external HDMI monitor
  • Internet connection (Ethernet or WiFi)
  • For a Pi 2 to connect to the internet wirelessly, you need a WiFi wireless adapter. The Pi 3 has built-in Wi-Fi.

Sign-up for an Amazon developer account

If you need an Amazon developer account, create one for free on their page. Read the AVS (Alexa Voice Service) terms and agreements here.

How to Create an Amazon Echo with Raspberry Pi

Read and accept the Application Distribution Agreement.

How to Create an Amazon Echo with Raspberry Pi

Select if you choose to monetize your apps.

How to Create an Amazon Echo with Raspberry Pi

Create your device on Amazon Developer

After registering your Amazon developer account, create an Alexa device and security profile. Note the following parameters carefully during setup:ProductID, ClientID and ClientSecret, as you will need to enter them again later.

From the top menu, select "Alexa Voice Service".

How to Create an Amazon Echo with Raspberry Pi

The "Welcome Developer" screen will appear.

How to Create an Amazon Echo with Raspberry Pi

The first screen asks questions about the product you are building.

1. First, name your device.

How to Create an Amazon Echo with Raspberry Pi

2. Next, enter a Product ID without spaces or special characters.

Note :You will need it later. Save it somewhere.

How to Create an Amazon Echo with Raspberry Pi

3. Select Alexa-enabled device for the product type.

How to Create an Amazon Echo with Raspberry Pi

4. Alexa needs a companion app. Select yes for this question.

How to Create an Amazon Echo with Raspberry Pi

5. Choose Wireless Speakers from the drop-down menu.

6. Type "Raspberry Pi project on Github" in the description box. This is information for AVS and is not visible to others.

7. Check the two options "Touch Initiation" and "Handsfree".

How to Create an Amazon Echo with Raspberry Pi

8. You can upload an image for your device, but let's skip this step for now.

9. Check “no” for questions about commercial distribution and children's products.

How to Create an Amazon Echo with Raspberry Pi

10. Click "Next".

Create your security profile

On this page, you create a new LWA (Login with Amazon) security profile to identify user data and security credentials with this project.

1. Click "Create New Profile".

How to Create an Amazon Echo with Raspberry Pi

2. Create a name for the profile. It could be something like "Alexa Security Profile".

How to Create an Amazon Echo with Raspberry Pi

3. Enter a description for the profile. You can choose "Alexa Security Profile Description".

How to Create an Amazon Echo with Raspberry Pi

4. Click "Next".

5. Amazon generates a Customer ID and Customer Secret for you. These are the other two values ​​you will need later. Keep them nearby.

How to Create an Amazon Echo with Raspberry Pi

6. Enter your Allowed Origins and Allowed Return URLs. We are setting up http and https routes for this project, so type the following in your "Authorized Origins" field - "http://localhost:3000".

7. Click "Add".

8. Type "https://localhost:3000" in the same box where you typed the first one.

How to Create an Amazon Echo with Raspberry Pi

9. Click "Add" again.

10. Do the same for Allowed Return URLs, but enter the following two URLs:

http://localhost:3000/authresponsehttps://localhost:3000/authresponse

11. The page should look like this before you click Finish. Make sure that none of your URLs are still in the field where you entered them. They appear on a gray background once you've added them.

How to Create an Amazon Echo with Raspberry Pi

12. Once you click "Finish", this screen will appear. Your project has been created and is ready to be installed.

How to Create an Amazon Echo with Raspberry Pi

Clone the Alexa sample app

1. Open Terminal.

How to Create an Amazon Echo with Raspberry Pi

2. Type the following:

cd Desktopgit clone https://github.com/alexa/alexa-avs-sample-app.git

Update the installation-script by adding your credentials

Before running the install script, update the script with the credentials you saved from Amazon:ProductID, ClientID, ClientSecret.

1. Type the following in Terminal:

cd ~/Desktop/alexa-avs-sample-appnano automated_install.sh

2. When it runs, this screen appears. Use the arrows on your keyboard to navigate and replace the ProductID, ClientID and ClientSecret fields with your values.

How to Create an Amazon Echo with Raspberry Pi

The changes should look like this:

ProductID="Your Device Name"ClientID="amzn.xxxxx.xxxxxxxxx"ClientSecret="4e8cb14xxxxxxxxxxxxxxxxxxxxxxxxxxxxx6b4f9"

3. Type Ctrl + X to quit the script. Type Y then Enter to save your changes.

Run the installation script

To run the script, open Terminal and run the following commands.

cd ~/Desktop/alexa-avs-sample-app. automated_install.sh

While running this script, you will be asked to answer a few simple questions. These are to ensure that you have completed all necessary setup on Amazon before installing the program.

How to Create an Amazon Echo with Raspberry Pi

Installation takes about 30 minutes, so grab a snack.

Once installed correctly, your terminal window will look like the following image.

How to Create an Amazon Echo with Raspberry Pi

The three terminals

You need to complete three steps to run the Alexa app. Each of them must run in a separate terminal window, and you must run them in the correct order.

There were some programs I needed but didn't have. I installed these programs over time. In case you have the same problem, I've included a note about it at each step.

Terminal 1

This window runs the web service to authorize your app with AVS (Alexa Voice Service)

Open Terminal and type the following commands:

cd ~/Desktop/alexa-avs-sample-app/samplescd companionService &&npm start

Note :npm is a package manager for the JavaScript programming language. If it's not available when you run the command, you can get it here.

When the scripts are finished, the window looks like this, showing that Pi is listening on port 3000.

How to Create an Amazon Echo with Raspberry Pi

Do not close this window. It must remain open during the following steps.

Terminal 2

This window communicates with AVS.

Type the following in another terminal window.

cd ~/Desktop/alexa-avs-sample-app/samplescd javaclient &&mvn exec:exec

Note :mvn is short for Apache Maven. If you don't have it, click here to get started.

When you run the client, a dialog box appears saying:"Please register your device before..."

Click Yes.

How to Create an Amazon Echo with Raspberry Pi

With some browsers, you will receive a warning that the connection is not secure. Skip it by clicking the "advanced" button. Then, on the next screen, click "Switch to localhost (unsafe)".

Now login to Amazon using your developer credentials.

The next screen asks for permission to use the security profile you created earlier for the device you are registering. Click OK.

How to Create an Amazon Echo with Raspberry Pi

You will be redirected to a URL starting with "https://localhost:3000/authresponse" which looks like the following image.

How to Create an Amazon Echo with Raspberry Pi

Return to the open dialog box and click the OK button. The client is now able to accept requests from your Alexa device.

Keep the terminal open and the voice service dialog open.

How to Create an Amazon Echo with Raspberry Pi

Terminal 3

This window installs the app that wakes up Alexa using her wake word. Skip this if you don't want to use voice to launch Alexa.

Open a new terminal window and use one of the following commands to bring up a wake word engine using Sensory or KITT.AI.

To use the Sensory Awakening Word Engine, type:

cd ~/Desktop/alexa-avs-sample-app/samplescd wakeWordAgent/src &&./wakeWordAgent -e sensory

To use the KITT.AI wake word engine, type:

cd ~/Desktop/alexa-avs-sample-app/samplescd wakeWordAgent/src &&./wakeWordAgent -e kitt_ai

Test it

Speak to Alexa by saying the wake word "Alexa". Wait for the beep before giving your command. For example, try it by saying "Alexa". Wait for the beep, then ask, "What time is it?" »

If it responds correctly, you have a working Alexa device!

Check out Amazon's Alexa webpage for more ideas. This Alexa can do everything an Echo can do!