Introduction: Alexa Pi: a Homemade Amazon Echo

Picture of Alexa Pi: a Homemade Amazon Echo

Do you want a cool, useful, and easy to do project that can be completed in a weekend? Well then this is the project for you! In this tutorial I will be guiding you on how to make your very own Alexa Pi

Step 1: What Is an Alexa Pi?

Picture of What Is an Alexa Pi?

The Alexa Pi project is a raspberry pi that is running amazons "Alexa voice services" and a wake word agent service to make a (nearly) fully functioning Amazon Echo for less than $50. The reason I say nearly is because it does not have the capability to use Amazon Music, but there are other alternatives to use for that such as airplaying your music to it.

Step 2: Things You Will Need

Picture of Things You Will Need

1. A Raspberry Pi 3(raspberry pi 2 will work but I recommend the Pi 3 because it is a lot faster)
2. Speaker that you can plug into the pi's audio jack
3. USB microphone(I'm using a PlayStation eye but I found that a USB webcam with a microphone also works)
4. Micro USB for power
5. Heat sinks
6. 8gb micro sd card

Step 3: Setting Up Your Pi

Picture of Setting Up Your Pi

The first thing we will need to do is set up our Pi with raspbian. For this build you will need to download an image of raspbian Jessie(which you can get at this link: )
Once you have downloaded the image you will need to flash the micro SD card. To do this follow this tutorial on the raspberry pi website:

Once you have flashed your sd card eject it and put it in your Pi and power it up. Once the raspberry pi has booted up and you are on the desktop you are going to need to connect the Pi to your wireless network.
When you have connect to your wireless network go to preferences and click on audio then click select controls and select pcm. Then click on the top bar and click on your microphone and click on select controls and click on microphone.

Step 4: Setting Up Your Amazon Development Account

Picture of Setting Up Your Amazon Development Account

Go to https://devloper.amazon.com
Then create/login to your Amazon developers account. Click on the Alexa tab, then click register an new product and check off device. Then set your device type and name( I chose alexapi for both) Then Click Next.
On the Security Profile screen, slick “Create new profile.”
Under the General tab, next to “Security Profile Name” name your profile. Do the same for the description. Click Next.
Make a note of the Product ID, Client ID, and Client Secret that the site generates for you.
Click the Web Settings tab, then click the Edit button next to the profile dropdown.
Next to Allowed Origins, click, “Add Another” and type in: https://localhost:3000.
Next to Allowed Return URLs, click “Add Another” and type in: https://localhost:3000/authresponse Click Next when you’re done.
The Device Details tab is next. It doesn’t matter much what you enter here. Pick a category, write a description, pick an expected timeline, and enter a 0 on the form next to how many devices you plan on using this on. Click Next.Finally, you can choose to add in Amazon Music here. This does not work on the Pi powered device, so leave it checked as “No.” Click Save.
Now you have created your account we can move on to the next step

Step 5: Downloading the Source Code

Picture of Downloading the Source Code

First go into terminal and type "sudo apt-get update"
When that is completed type in "sudo git clone https://github.com/alexa/alexa-avs-sample-app.git
This part is when you will want to ssh to your pi so that you can easily put in your developer info without any mistakes.
When that is done type in "cd Desktop/alexa-avs-sample-app"
Then type "Sudo nano automated_install.sh"
And put in your client Id, client secret, and product id from the Amazon developer account.
Then type sudo bash automated_install.sh
This can take anywhere from 30 mins to 1 and a half hours to finish and if it asks if you want to replace any thing just say yes

Step 6: Running the Alexa Program

Picture of Running the Alexa Program

For this we will need to open three separate terminal windows.
In the first one type in "cd Desktop/alexa-avs-sample-app/samples"
Then type "cd companionService && npm start"

In the second window type in "cd Desktop/alexa-avs-sample-app/samples"
Then type "cd javaclient && mvn exec:exec"
When the box asking you is you want to open the link in your browser click yes. After you get the window saying your connection isn't safe click on advanced options and click continue to URL. Then fill in your credentials and press ok and wait until it says device tokens ready. Then go back to the java window and press ok and you should see you token in the box.

Now in our third and final terminal window we are going to run our wake word agent. There are two agents but only one works. So what we are going to do is type in "cd Desktop/alexa-avs-sample-app/samples"
Then type in "cd wakeWordAgent/src && ./wakeWordAgent -e sensory"
Now your Alexa Pi should be up and running

Step 7: Setting Up Your Pi for Music AirPlay

Picture of Setting Up Your Pi for Music AirPlay

Type in "sudo apt-get install git libao-dev libssl-dev libcrypt-openssl-rsa-perl libio-socket-inet6-perl libwww-perl avahi-utils libmodule-build-perl" and press Enter. This installs different software you’ll need.

Press Y when prompted and wait for everything to download and install.

Type in "git clone https://github.com/njh/perl-net-sdp.git" and press Enter. This is required for the newest version of AirPlay’s software. The next few commands build and install this software.

Type in "cd perl-net-sdp" and press Enter.

Type in "perl Build.PL" and press Enter.

Type in "sudo ./Build" and press Enter.

Type in "sudo ./Build test" and press Enter.

Type in" sudo ./Build install" and press Enter.

Type in CD .. and press Enter.

Now you’ll grab shairport, the DIY Airport software. Type in "git clone https://github.com/hendrikw82/shairport.git" and press Enter.

Type in cd shairport and press Enter.

Type in Make and press Enter.

Type in ./shairport.pl -a AlexaPi and press Enter.

Now you will be able to stream music to your Alexa pi

Step 8: PS3 Eye Microphone Problems

so i had so trouble setting up my PS3 eye microphone with the raspberry pi but i ended up going to these 2 websites for help on how to set it up. I'm not great at explaining what i did(in fact i'm not sure what i did) but here are the 2 websites to look at if you are using the PS3 eye as your microphone.

https://renatocunha.com/blog/2012/04/playstation-e...

https://me.m01.eu/blog/2014/07/an-asoundrc-alsa-co...

Step 9: Congratulations You Now Have a Fully Function Alexa!

Congrats! you made it through. To activate your Alexa all you have to do is say "Alexa" and wait for a ding noise. Now At this point you might want to know what you can do with your alexa pi, so here are a few links that will help you with your question.

https://www.alexaskillstore.com/

https://www.cnet.com/how-to/the-complete-list-of-a...

https://www.reddit.com/r/amazonecho/comments/31oj8...

http://fieldguide.gizmodo.com/everything-you-can-s...

Step 10: Future Stuff

Releasing a script for download so that the Alexa will automatically boot after loss of power.

Controlling appliances such as lights, fans, locks, and possibly 3D printers.

Step 11: Feedback

Do you have any feed back you would like to share for this instructable? i'd like to know what i can improve. ex. did the alexa pi work for you, were there pictures i could have added? that kind of thing, feel free to post it in the comments section. Thanks

Comments

mattrussll (author)2017-09-25

Thanks for the help!

Can you tell me the command to open and edit the ALSA config? I tried to follow what was done in the link you recommended, but I could not find the .asoundrc file.

Sorry my Linux skills are a little basic...

mrblank5 (author)mattrussll2017-09-26

It should be sudo nano /etc/.asoundrc if anything is in the file delete it and paste in the stuff from earlier. If that doesn't work tell me and I'll check my commands and get back to you

mattrussll (author)2017-09-19

I really want to get my ps3 eye working for this. can you please try to remember what you did! I'm stuck....

mrblank5 (author)mattrussll2017-09-20

Just use the second link and past it into your ALSA config. Delete evrey thing else in it and just past that. Reply if it worked or not. I'd don't think the first link actually did anything

mrblank5 (author)mrblank52017-09-20

https://me.m01.eu/blog/2014/07/an-asoundrc-alsa-config-for-the-ps3-eye/

Paste this into .asoundrc

jayfmn (author)2017-06-01

I got it working, have you developed the restart auto wake up script yet? Also, when I am installing Shairpoint, I enter "perl Build.PL" & it errors out. it says it is missing 2 files. Makefile.PL & META.yml. I can do most of the rest OK, but when I try to launch it it fails. Jay

mrblank5 (author)jayfmn2017-06-04

I'm not really sure. Try re installing, I haven't used that feature in a while because I got some nice Sonos speakers which can be controlled with the pi. Hope it works out, I'm glad you got the Alexa working!

unger (author)2017-03-31

what are you using to stream music then???

EricK102 (author)2017-01-12

The bearer token isn't showing up. Also, my DSN says 123456789.

mrblank5 (author)EricK1022017-01-14

first question: did you get the amazon error page or were you able to put in your credentials? you might have put in your developer details in incorrectly, i suggest that you repeat step 5 but ssh to your raspberry pi. this way you can copy and paste your developer details without the chance of messing up.

bderry71 (author)2017-01-09

I'm getting a compile error from GPIOWakeWordEngine.cpp that wiringPi.h is not found. Any idea how to fix? This is on an RPI3.

bderry71 (author)bderry712017-01-09

Figured it out, needed to load the wiringpi package using apt-get then it compiled correctly. Now I have to wait for Amazon to fix their side as it's giving an error when I do the second launcher and try to authorize the device.

mrblank5 (author)bderry712017-01-10

The error is with the developer account and you might need to set up another device and try again. I came across this problem and that's what I tried but I'm not sure. If you have any more questions look up Alexa Pi and there are multiple github forums where people can answer your questions.

mrblank5 (author)bderry712017-01-09

I know in the instructable it says only one wake word agent works but I have since figured out that they both work and I was doing something wrong. Try cd Desktop/Alexa-avs-sample-app/samples
Then do cd wakeWordAgent/arc && ./wakeWordAgent -e kitt_ai

mrblank5 (author)mrblank52017-01-09

I'll be home in an hour or so and I'll check my files and if you're still having the problem I'll post the wiringPi.h file in the Instructables for you to download and put on the Pi. Hope it works out

NickP31 (author)2016-12-19

at this step

Then type "cd javaclient && man exec:exec"

I get a No manual entry for exec:exec. any idea what i could've done wrong

NickP31 (author)NickP312016-12-19

now i'm thinking its supposed to be mvn exec:exec

mrblank5 (author)NickP312016-12-31

do you have any feed back on this instructable? id like to know what i can improve. ex. did the alexa pi work for you, were there pictures i could have added? that kind of thing

mrblank5 (author)NickP312016-12-19

Yes it is supposed to be mvn, sorry it must have autocorrected and I just didn't fix it. Just change man to mvn

GuillaumeJ12 (author)2016-12-09

will a B+ work ?

mrblank5 (author)GuillaumeJ122016-12-09

Yes, it does work but I got errors with sensory saying it had illegal instruction and it also functions very slowly on the B+. There might be another way but if there is I don't know of it.

12Samzo34 (author)2016-12-08

What is the word that triggers it? Thanks

mtbike2 (author)12Samzo342016-12-08

"Alexa"

mrblank5 (author)2016-12-08

https://github.com/alexa/alexa-avs-sample-app/issues/375 if you have trouble with sensory not recognizing the wake word look at this

mrblank5 (author)2016-12-08

The wake word is "Alexa"

About This Instructable

14,434views

143favorites

License:

Bio: Trombonist, Bassist, Guitarist, Drummer, Future engineer.
More by mrblank5:Alexa Pi: A Homemade Amazon EchoUsing a Kindle Fire as a monitor for your Raspberry piSimple homemade capacitive touch stylus
Add instructable to: