Technology / Tutorials /

Off-The-Shelf-Hacker: Build Your Own Alexa Voice Assistant with a Raspberry Pi

7 Jan 2017 1:46am, by

You know the Amazon Echo, an unassuming cylindrical device that sits on a table, listens for commands and then carries out actions on your behalf. It’s been available for the last year or so, at retail for around $180. You may even have one in your home.

Alexa is the disembodied voice of the virtual assistant that lives inside the Echo. Ask Alexa a question, like “What’s the current temperature in San Francisco?” and after a second or two, the answer comes back in a pleasant, slightly metallic-sounding female voice.

I really hadn’t paid much attention to the Echo or Alexa until my editor recently asked that I look into connecting one to the PancakeBot pancake maker. It turned out that you can create your own “Echo” using a Raspberry Pi.

The LED finally illuminated the inside of my coconut and I think there are lots of awesome Off-The-Shelf Hacker possibilities for this technology.

The Echo uses the Alexa Voice Service (AVS) to interpret words and context, up in the Amazon Cloud. By far, the easiest way to get Alexa running on a Raspberry Pi is to follow the directions on the Alexa GitHub page.

Parts Needed

You’ll only need a handful of parts to make your own Echo-like “Raspi” device. I used a Raspberry Pi model 2, the old familiar hacked Logitech webcam/microphone (from my Steampunk Presentation Machine project), a set of Samsung earbuds for my Galaxy 5 Active phone and a tiny USB WiFi adapter. You’ll also need a 5-volt, 2-amp wall wart to power the Pi.

Plug the webcam (it only uses the microphone part, not the camera) into a USB port and the earbuds into the audio jack. Of course, the store-bought Echo doesn’t use earbuds, so it’s certainly possible to substitute a powered speaker, in their place. I used earbuds for convenience and will switch over to a nice little amplifier and speakers, once I decide on the appropriate Steampunk device for a more permanent voice-assisted installation.

My project also used a USB WiMax WiFi adapter, since wireless isn’t built into the Raspberry Pi model 2. Model 3 users don’t need the adapter because WiFi is integrated on the board.

All the setup work was done from my trusty Linux notebook using ssh. Use the -X option, so new windows will seamlessly pop up on your remote Linux desktop.

rob%  ssh -X pi@

Feel free to hook up and use an HDMI monitor and keyboard/mouse pad combo, if you don’t want to do everything with ssh.

You’ll also need an Amazon Developer Account. Go to the Amazon Developer Services page and create an account. Next, is the software.

Software Needed

By far, the most challenging part of building your own off-the-shelf Echo-like device is loading and configuring the software. Don’t worry, although there are lots of steps, the process is not very hard.

GitHub has a great write-up on the Java and Node.js installation process. Be aware that there is a big install script that runs on the Pi, that will take about a half hour to complete. The instructions were very comprehensive and I only managed to get off track with one minor issue, actually related to starting up the Alexa system on the Pi.

My issue, once you get to the execution part, is that you have to run four different terminal windows, and need to run programs in each one. Window 2 tries to start a web browser and for some reason, my default browser wouldn’t start. When a message box popped up to start a browser I simply copied the “register your device” URL (displayed in the window) and clicked the “No” button. I then pasted the copied URL into the address bar in Epiphany and went merrily to the next step. No big deal.

It would be nice to bring up an operational Alexa, after Pi boot-up, without going through the tedium of the four terminal windows and web browser. Automating the startup process is definitely on the “what’s next” list.

I chose to arbitrarily use the wake-word engine. You could also use the “Sensory” engine. The one seemed to work well.

Practical Usage

Using a Pi-powered personal assistant is easy.

Once everything is running, simply say “Alexa” into the microphone and wait for the tone. Then, ask a question, like “What is the current temperature in San Francisco?” Very shortly, the result will come back along with a summary of the day’s weather report.

I probably spent the first 20 minutes with Alexa, asking all kinds of questions. Occasionally, I’d get a response saying that Alexa didn’t understand the question or that she didn’t have any information on the topic. Sadly, “Dr. Torq” is apparently totally unknown to Alexa.

I’ll certainly need to ramp up my virtual branding. Hmmmm? Will we need virtual branding consultants, in the future? Will recruiters still be around to place those people? Talk about recursive thinking.

Later, I tried listening to Internet radio. I tried “Alexa: Play TuneIn Radio” and after hearing the familiar tone requested one of my favorite radio personalities. Alexa immediately said that she was bringing up a particular radio station with my selected programming. Raising the volume was as easy as uttering “Alexa: volume up.” The latest GitHub builds include many of the normal retail Echo’s features.

It was also interesting to try the IFTTT (If This Then That) service with Alexa. I logged into the IFTTT site and configured the “Alexa, find my phone” applet with my phone number. I then asked Alexa to find my phone. After a couple of seconds, sure enough, the phone rang. How easy is that? IFTTT has a bunch of other applets that could really be useful with Alexa.

There’s a wealth of information on the Amazon Developer site.

Google is getting into the voice assistant game with their Home product, too. I’m eager to see how their Google Assistant service works out.

Next Steps

All of this is just the beginning for voice assisted everything.

I just ran across an article about Whirlpool adding Alexa to its appliances. Could we integrate Alexa or Google Actions into our Off-The-Shelf Hacker projects? Looks like that’s a huge “YES!”

There’s also a GitHub write-up on running Alexa on the CHIP computer. This is definitely on the radar for an upcoming project.

For some reason, the idea of controlling general purpose input/output (GPIO) pins on a Pi, on an Arduino or the ESP8266 devices on my LAN, keep flashing through my mind.

What do you think?

Feature image via Pixabay.

A digest of the week’s most important stories & analyses.

View / Add Comments