Introduction: Raspberry Pi Amazon Echo
The Amazon Echo is a brilliant piece of technology. It's a fantastic AI that not only can it do the basics such as answering questions, scheduling events, and playing music, but it can also control your home’s smart electronics such as TV’s, phones, computers, and even refrigerators. However, you can't really expand the device itself much.
The Raspberry Pi is the most suitable piece of hardware for this project, because it is one of the most versatile components on the consumer market, considering it’s $35 price tag. Using the Pi instead of the Amazon hardware gives users the advantage of customizing their hardware. With the Echo Dot, users can plug in their own speaker, and that’s about it. They cannot tweak the hardware, software, or peripherals. What you see, is essentially what you get. With a Pi, you can install your own far-field microphone or speaker.
If you wish, you can switch the Raspberry Pi to something else at any time, the Alexa software does not permanently turn the Pi into an Echo. If I get bored of Alexa, I can switch my Pi into a retro game emulation machine, personal VPN, music server etc. All of this is as easy as buying a Raspberry Pi, downloading, and running the Alexa software.
Step 1: Gathering Materials
The great thing about this project is that you can use the cheapest or most expensive materials you want. I just used spare stuff lying around my house, and it worked fine.
- Raspberry Pi (3 B+ recommended)
- A MicroSD card for storage (preferably around 8GB)
- An audio input (microphone, USB) and output device (speakers, can be 3.5mm or HDMI, I'll be using 3.5mm).
- Any cheap WiFi adapter (USB) OR Ethernet cable
- A microUSB cable for power (If you have an android phone, you can most likely use your phone charger for this)
- A keyboard and mouse (both USB)
- Case w/ heatsink (The Pi is a computer after all, you probably want it safe and properly cooled)
Step 2: Setting Up Your Pi
Since this is a project about setting up Alexa, and not the Raspberry Pi itself. I'm going to assume you've already booted your Pi with NOOBS and installed an operating system and connected it to the internet.
If you haven't set up your Pi or don't know how to click here.
Before we proceed, connect all of the peripherals to the Pi to make sure they work.
What to Connect and How to Know if They Are Working
- Connect the USB mouse and keyboard to the USB ports on the Pi
- You will know they are working if you can move the mouse and can type things
- Connect the USB microphone to an open USB port
- You can test your Mic to see if it's working by using the Aslamixer, mine worked fine after plugging in
- If you're using 3.5mm, connect your speaker to the 3.5mm port.
- You can also test your speaker in Aslamixer
- If you're using a USB WiFi adapter, plug that into an open USB port. If you're using Ethernet, plug your cord into the Ethernet port,
- You should be able to see it's working by looking at the bottom right of your screen, there will be a blue internet connection symbol. If it's all grayed out, you are not connected to the internet.
All of these should be working before going further, if not, the folks at raspberrypi.org are a great help!
Step 3: Registering Your Raspberry Pi With Amazon
Go back to your normal computer, and create an Amazon developer's account.
Now I know what you're thinking, creating accounts is super annoying. Don't worry, if you already have an Amazon account then you have a developer's account. Just go to developer.amazon.com and register!
Steps for Registering Your Raspberry Pi with Amazon as an Alexa Device
- Log into your developer account
- Click on the "Alexa" tab
- Click on "Alexa Voice Service"
- Under the "Register a Product Type" dropdown, select device.
- Under "Device Type ID" and "Display Name", choose a name for your Raspberry Pi device. Use this name for both your Device ID and Display Name
- Record this in a document of some sort, I used Google Docs.
- Click next
- In the "Select Security Profile" dropdown, choose "Create a new profile"
- For your "Security ID" and "Security Profile Description" you can put anything, but I'd recommend using the same name you used for your Display Name.
- Record this in your document
- You will now see three different values: Security Profile ID, Client ID, and Client Secret
- Record all of these in your document
- Navigate to the "Web Settings" tab
- Click edit
- On "Allowed Origins" click "Add Another"
- Enter https://localhost:3000 into the text field
- On "Allowed Return URLs" click "Add another"
- Enter https://localhost:3000/authresponse into the text field
- Click next
- In Category, select "Other"
- Under "Description" you can put anything you want
- For the next two questions, choose "No"
- Click submit
Now it's time to go into your Raspberry Pi and set up Alexa!
Step 4: Clone/Install the Echo Service
In this step, we're going to be cloning/installing the Alexa program from Amazon's official GitHub page.
Steps for Cloning/Installing Alexa
On your Pi desktop, open up the terminal by pressing:
Navigate to your desktop (or whichever directory you want to install Alexa in) using the command:
Clone Alexa by typing in the command:
git clone https://github.com/alexa/alexa-avs-sample-app.git
Once the cloning sequence is complete, navigate to your Alexa directory by typing in the command:
Before beginning the install sequence, we're going to have to edit some install parameters using the nano text editor in terminal. Open up the document in which you recorded all of your device's information.
You can edit the install file by typing in the command:
Since this is in the terminal, you can use your mouse to navigate. Don't be scared, the arrow keys work just fine! You're going to need to type in your ProductID, ClientID, and Client Secret into the appropriate fields.
You need to make sure these values are entered right after the "=", and make sure these values are EXACT.
Save and close nano by typing:
Navigate back to your Alexa directory, and start the install sequence by typing:
This is going to take a while, but we're almost done!
Step 5: Running the Alexa Companion App
The next step is to run the Alexa companion service. We're going to have to make sure she is listening to port 3000, which is the port we assigned Alexa when registering our Pi with our developer's account
Steps for Running the Companion App
Navigate to Alexa's companion service directory by typing in the command:
In order to open up communications for Alexa, we're gonna have to use a program called Node. Node is installed by default with the Alexa app. We're going to start Node by typing the command:
*IF THERE IS SOME SORT OF ERROR WITH NODE YOU MIGHT NOT HAVE IT INSTALLED CORRECTLY. IF THIS HAPPENS TYPE IN THE COMMAND:*
sudo apt-get npm
You should see a "Listening on port 3000" message in your terminal, that means Node is doing its job! Next, we're going to "build" the Alexa app with a program called Maven (another default Alexa app). This just means we're going to be starting it up.
Step 6: "Building" the Alexa App
We're going to be using another terminal tab to build Alexa. On the top of your terminal window, select the "Tabs" button and click "New Tab"
Again, "building" is just the technical term that Maven uses. We are not building or programming anything.
Maven is another tool that comes with the Alexa app we downloaded earlier, so you shouldn't have to worry about installing it.
Steps for "Building" Alexa
In your new terminal tab, navigate to your javaclient folder in your Alexa directory by typing in the command:
In order to start the Maven service we're going to type in the command:
This takes a couple of seconds, but the message you should see is:
*IF YOU GET A MESSAGE THAT SAYS
THEN MAVEN WAS NOT INSTALLED CORRECTLY, YOU CAN FIX THIS BY TYPING IN THE COMMAND:*
sudo apt-get install mvn
If the build was a success, an authentication window should pop up on your screen.
An Amazon window should pop up
Another java window should pop up, DO NOT click "Ok" just yet.
*IF AN AMAZON WINDOW DID NOT SHOW UP, OR YOU'RE GETTING PAGE ERRORS, YOU NEED TO CHECK YOUR DEVICE PARAMETERS SET EARLIER.
- PRODUCT ID
- CLIENT ID
- CLIENT SECRET
YOU MAY ALSO HAVE TO CHECK YOU'RE WEB SETTINGS SET EARLIER
THEY SHOULD BE
ALEXA WILL NOT WORK IF THESE ARE NOT CORRECT*
In the Amazon window, enter your account info. Amazon will then give you your device token info. Copy and paste that into the java window
You may now click "Ok".
We're almost done! Now it's time to get this wake word going!
Step 7: Turning on the Wake Word Service
The great thing about Amazon's Alexa is that she's constantly listening! In order to enable this service, we're going to have to start it manually.
Steps for Starting the Wake Word Service
Navigate to your Wake Word agent directory by typing the command:
Start the service by typing the command:
./wakeWordAgent -e kitt_ai
And now you're done! Your bootleg Alexa is now up and running!
Try asking her some simple questions; start every query with "Alexa" so she knows when to listen
Anandneu12 made it!
We have a be nice policy.
Please be positive and constructive.