How to put Alexa on Raspberry Pi
Here's how you can build a home-brew Amazon Echo
There are a variety of ways that ingenious hacker types have got Amazon's Alexa to play nice with the Raspberry Pi, but we're going for the simplest method here, which is to install AlexaPi, a ready-built Python client.
First up, you'll need a Pi (ideally a Pi 3 or Zero W for ease of Wi-Fi connectivity), with a minimum 8GB MicroSD/SD card. You'll need to have Raspbian installed and either a keyboard, monitor and mouse or SSH/remote access enabled, and of course a power supply.
You'll also need a USB microphone and a speaker to plug into the headphone jack. The microphones can be picked up cheaply from the usual internet retailers, and the speaker can be improvised from any powered speaker that accepts a 3.5mm line in, which includes anything from a cheap Bluetooth speaker to a kitchen radio or a full spec Hi-Fi system.
Alternatively, you can buy this kit, designed by Google and sold through resellers like The Pi Hut, which includes a speaker and microphone, as well as all the various cables and connectors needed to hook it all up together.
It also includes a cardboard housing and an activation button, allowing you to basically build your own push-button AI assistant. The kit's designed to allow you to build projects with the Google Assistant, but there's no reason you can't also use it to create something with Alexa.
First you'll need to set up an Amazon Developer account, which is a free (albeit click-intensive) process.
Set up an Amazon Developer account
Once you've set up your Amazon Developer Account, log in. Click on the Alexa Tab, then click 'Register a Product Type', and 'Device'. Name your device type and display name, hit next, then on the Security Profile screen, click "Create new profile."
Under the General tab, next to "Security Profile Name" name your profile and fill in the description. Keep these three short and memorable, or note them down, as you'll need them for the final setup. Click Next.
Now note down the Product ID, Client ID, and Client Secret that is auto-generated - you'll need these to set up the Pi.
Next, hit the Web Settings tab > Edit (next to the profile dropdown), and in Allowed Origins, click, "Add Another" and type in: http://localhost:5050.
Click "Add Another," again, then type in http://your.raspberrypi.ip.address:5050 but replace 'your.raspberrypi.ip.address' with your Raspberry Pi's IP address (bold for emphasis).
Then repeat the steps with Allowed Return URLs, ie: click "Add Another" and type in: http://localhost:5050/code, then "Add Another" and add in http://your.raspberrypi.ip.address:5050/code. Hit Next when you're done.
Finally, the Device Details tab. Pick a category, write a description, pick an expected timeline, and enter 0 on the form next to how many devices you will deploy this on. Leave Amazon Music checked as "No", as it won't run on the Pi.
Whew. With that complete, you're ready to step back into the room and get the Pi up and running with Alexa.
Download and install Git
The next step is to install Git, followed by the actual repositories that will power your homebrew Echo. Kick off with the usual safety-first update with the standard command: sudo apt-get install update
Next, install Git, which is the code management tool that you'll need to unpack and run the AlexaPi software, followed by the software itself. Download Git with the command sudo apt-get install git, then type in cd /opt and press Enter to change the directory.
Finally, type in sudo git clone https://github.com/alexa-pi/AlexaPi.git to download the AlexaPi repos.
Set up AlexaPi
Now that you've downloaded the AlexaPi software, it's time to set it up. Type in sudo ./AlexaPi/src/scripts/setup.sh and press Enter.
Another series of questions is your reward - skip through the operating system and device prompts by hitting enter if you're using the Pi, then consider adding AirPlay support. If you've got an iOS device then being able to stream to your AlexaPi is exceedingly handy, but the software download will take a few minutes if selected.
Once that's downloaded (or dismissed), you'll be asked to enter your Amazon developer information from the earlier setup stages above, including Device Type ID and Security Profile Description, as well as the long Profile ID, Client ID, Client Secret numbers.
Finally, authorise your device. This is a one-time setup, so don't worry, you won't need to do this again. On a standard desktop, laptop or tablet, fire up a browser and type in http://your.raspberrypi.ip.address:5050 replacing your.raspberryi.ip.address with your Raspberry Pi's IP address from earlier. This will prompt you to login to your Amazon Developer account, which will in turn display an authorization token.
With that, you're done - the the Alexa voice service is now installed on your Raspberry Pi. The final step is to simply start the service by rebooting the Pi or using the command:
sudo systemctl start AlexaPi.service
All being well, you'll now be able to speak Alexa commands into the mic, and hear responses back through the speaker. If not, first try typing: sudo systemctl status AlexaPi.service to check the status.
If the status log has dbus and pulseaudio errors (which can happen with the stock version of Raspbian) then you'll need to set up system-wide PulseAudio, or use a workaround.
You're now in a brave new world of voice-enabled Pi interaction - enjoy!
(Thanks to the folk who built and maintain AlexaPi)
Four cyber security essentials that your board of directors wants to know
The insights to help you deliver what they needDownload now
Data: A resource much too valuable to leave unprotected
Protect your data to protect your companyDownload now
Improving cyber security for remote working
13 recommendations for security from any locationDownload now
Why CEOS should care about the move to SAP S/4HANA
And how they can accelerate business valueDownload now