Build Your Own Raspberry Pi Amazon Echo

Hello, Alexa Voice Service.
20 minutes

The Amazon Echo and Echo Dot are one of the hottest gifts of the 2017 holiday season. This year, instead of buying one, you can make your own!

In this guide, we'll be using a Raspberry Pi 3 and Amazon's Alexa Voice Service (AVS) software to create our very own Amazon Echo for a fraction of the price.

Why create my own DIY Amazon Echo?

In addition to learning (and building something really cool!), a DIY Echo can be less expensive than purchasing a prebuilt one. Additionally, you can build it into really cool enclosures like our Amazon Echo Furby.

Raspberry Pi 3Raspberry Pi 3 ×1
Raspberry Pi 3 case ×1
USB microphone ×1
MicroSD card, 32GB ×1
Raspberry Pi power supply, 2A ×1
Speakers ×1
HDMI cable ×1

Howchoo is reader-supported. As an Amazon Associate, we may earn a small affiliate commission at no cost to you when you buy through our links.

The first thing we need to do is set up our Raspberry Pi to run the Alexa Voice Service. To do that, I recommend installing a fresh instance of Raspbian Stretch on your Pi. Thankfully, there's already a Howchoo guide on this! Check out "How to install Raspbian Stretch on the Raspberry Pi".

The project we'll be using also supports Raspbian Jessie and Wheezy. Of course, you can use either of those versions if you prefer old things!

Before we continue, we'll need to create an Amazon Developer account so we can register our usage of the Alexa Voice Service.

In the top right corner of the page, there is a "Sign In" button. Click that and at the bottom of the next page you'll see a "Create your Amazon Developer account" button. Click it and continue following the prompts until your registration is complete...

Congratulations, you're an Amazon Developer! Feel free to brag about it to your friends.

Next, we'll need to create a new AVS product. To do this, navigate to the Alexa Voice Service homepage and click the "Create Product" button at the top right of the page.

You'll find yourself staring at a big, scary form with a scrollbar but, don't worry, it's actually very simple to fill out!

  1. Product Name is used to identify your product to humans. I used "Howchoo Alexa Project".
  2. Product ID is used to identify your product to robots. Only use alphanumeric characters for this field (no spaces). I used "howchooalexa".
  3. When asked if your product is an app or device, select Device.
  4. When asked if your product will use a companion app, select Yes.
  5. For Product Category, select whatever you think is most appropriate for your usage. I selected "Computing".
  6. For Product Description, feel free to enter whatever you think is appropriate. This identifies the usage of your product to Amazon.
  7. When asked how users will interact with your product, select Touch-initiated and Hands-free.
  8. You can skip uploading an image for now.
  9. When asked if you will distribute your product commercially, select No.
  10. When asked if children under the age of 13 will use your product, select No.

Click "Next".

You'll be taken to a new page to create a new LWA (Login with Amazon) security profile. Click the "CREATE NEW PROFILE" link in the center of the page.

Two new fields will be created, "Security Profile Name" and "Security Profile Description". These fields are to help you identify the purpose of different security profiles that you've created. Feel free to enter whatever you like here to help you identify this security profile with this project.

Click "Next".

You will be brought to a new form containing a "Client ID" and "Client secret" field. Copy these and save them somewhere easily accessible. We'll be using them in a following step.

In the "Allowed origins" field add the following two URLs:

http://localhost:3000
https://localhost:3000

In the "Allowed return URLs" field add the following two URLs:

http://localhost:3000/authresponse
https://localhost:3000/authresponse

Check the box to agree to the "AVS agreement" and the "AVS Program Requirements" and click "Finish".

The last step before the fun stuff is to enable your newly created LWA security profile. At the top of the page, select the security profile you just created and click "Confirm".

You will be presented with yet another form with a field called "Content Privacy Notice URL". Just enter any domain name starting with http:// or https://, such as http://example.com.

Click "Save".

Now we're ready for the fun part! Plug a monitor and keyboard into your Raspberry Pi, give it some power, and open a new terminal window.

If you don't have a monitor/keyboard setup and you aren't sure how to log into your Raspberry Pi, consult the following guide on "How to log in to a Raspberry Pi via SSH".

When you're setup, clone the Alexa sample app repository from GitHub by running the following command:

cd ~ && git clone https://github.com/Howchoo/alexa-avs-sample-app.git

Now we need to update the Alexa sample app install script with the product information we obtained in steps 3 and 4. In the same terminal window we opened in the previous step, run the following commands:

cd alexa-avs-sample-app
sudo nano automated_install.sh

At the top of this file, you will see three variables "ProductID", "ClientID", and "ClientSecret". Each of these variables corresponds with a piece of information we obtained above. Update these values and press "Ctrl+X", followed by the "Y" key, followed by the "Enter" key to save the changes.

Finally, run the following command to initiate the installation process:

. automated_install.sh

You will prompted with several questions regarding terms & conditions, Amazon registration status, language preferences, and audio output. Be sure to select Yes when asked if you'd like to use the "wake word engine".

After answering all the prompts, the installation will begin. Go grab a cup of coffee, because this will take a few minutes.

For this step, we will need to make use of the Raspbian desktop environment. If you don't have a monitor/keyboard setup, you can log into your Raspberry Pi with a VNC client.

Once you're all set up, run the following commands to start the AVS companion service:

cd ~/alexa-avs-sample-app/samples/companionService
npm start

Leave this terminal window open for the following steps.

Initiate the process of registering your Raspberry Pi with Amazon

Next, we'll need to register our physical Raspberry Pi device with Amazon. To do this, open a new terminal window and enter the following commands:

cd ~/alexa-avs-sample-app/samples/javaclient
mvn exec:exec

After a few moments a window like the one above will pop-up. Copy the URL in the dialog window to your clipboard and click Yes. A new dialog window will pop-up, but just ignore it for now.

Shortly after, a new web browser window will be opened for you.

Complete the device registration process

In your new browser window you'll likely be presented with a message like the one above. Just click "ADVANDED" in the bottom left corner, scroll drown and follow the link called "Proceed to localhost".

You will be redirected to a secure Amazon login screen. Enter the login credentials you created in step 2 to continue. Don't be alarmed if you're asked to login a second time with a Captcha test. Just oblige and be thankful that we still live in a world where humans are better than computers at something.

Lastly, click OK on the dialog window that opened at the end of the previous step. You should now see that the "access token" field of the AVS window is filled. If so, Alexa is now at your command!

To make sure everything is working, let's send Alexa a test command! Click the big microphone button in the AVS window and say "What is the mass of the Sun in grams?".

If Alexa responds "1,989,100,000,000,000,000,000,000,000,000,000 grams" then congratulations, you did it!

If she doesn't respond, you may have missed a step or don't have a microphone setup. If Alexa said a completely different number, then you're probably in a different solar system! In any case, send your SOS to the comment section below...

If you want to be able to interact with Alexa by just speaking to her, then you'll need to enable a wake word engine. To do this, open a new terminal window and enter the following commands:

cd ~/alexa-avs-sample-app/samples/wakeWordAgent/src/
./wakeWordAgent -e sensory

Now you can "wake" and interact with Alexa just by saying her name!

The Alexa Voice Service and do anything a regular Amazon Echo can do! From setting alarms and reminders, to controlling smart home devices, to telling you useless astronomy facts, the possibilities are virtually endless.

If you didn't already know, you can expand Alexa's basic capabilities by installing new skills. Check out Amazon's Skill gallery.

To install your first skill, just say "Alexa, install Jeopardy"!

Zach Zach (248)
55 minutes

Jasper is an open-source voice-control platform that runs on a variety of systems, including the Raspberry Pi.