Home Cyberpunk Build Your Own Alexa with Raspberry Pi

Build Your Own Alexa with Raspberry Pi

by David Rutland
Build Your Own Alexa with Raspberry Pi

Amazon’s Echo series of speakers are straight out of science fiction. Ask one a question and it will find the answer for you. It can make jokes, play music, book dentist appointments, or score cinema tickets.

Depending on how deeply you want to integrate licensed third party hardware into your life, The Alexa/Echo can control your lights, set the thermostat, and open the door for you. It can handle home security too.

Most amazing is the way the Alexa/Echo can blend with your everyday existence. It sits in the corner of the kitchen like an ordinary bluetooth speaker. Innocuous, recording, waiting for the next demand or question on any topic.

“Alexa, how many people died of Coronavirus today?”

“Alexa, secure the doors and windows.”

“Alexa, arm perimeter defense cannons.”

Door-to-door plague vectors.

Alexa Is More Salesperson Than Product

We hate it. Not because it can act as the all-powerful, all-knowing font of all knowledge, completely replacing our need for any sort of human interaction. Not even for its ability to defend our home from visiting pairs of Mormons intent on turning our property into the next Covid-19 hotspot. We love that it will leave their perforated, caffeine-free corpses on the grass by our front gate to be disposed of by the Alexa enabled garden tools we keep in the shed.

No, we hate it because it isn’t ours. We simply have the right to use it. The Echo unit exists only as a gateway to Amazon services. Hell, we can’t even use it as a standard bluetooth speaker to play our own non-Amazon music without routing the data through Amazon’s servers.

In using an Echo, you are dependent on Amazon. The company can remotely turn it off and alter its functions so that your doors are unlocked, your lights are out, and your auto-cannons are powered down. The company can brick the device whenever it suits them. You have no recourse. You can’t even re-purpose the hardware for another project.

The questions surrounding exactly how much privacy you have when there’s a remote monitoring device recording everything you say are too extensive and disturbing to be addressed in this article.

Suffice it to say that your local police department regularly uses Amazon footage to prosecute crime, and there’ll be a forensics team along presently to pick blood-spattered pages from The Best of Brigham Young out of your rhododendron.

As the Echo’s purpose is to tie consumers (a word and concept we very much dislike, but which is appropriate in this context) ever more tightly into the Amazon family, it’s in Amazon’s interest to get their snooptastic shopping portal into as many homes as possible. We suspect they would’ve mailed out units for free if they could have, but people have grown a little wary of unsolicited freebies since a small incident in the eastern Mediterranean around 3,500 years ago. As it is, Amazon loses around $5 per Echo Dot sold. They spent $100 million subsidizing the product during the 2017 Christmas holidays alone.

The fire-sale prices undercut Google’s Homehub and the Apple Homepod to the extent that Echos are now in twice as many homes as Google’s offering. We weren’t even aware Apple’s product existed until we started researching this article.

So of course, they’re going to let you install the software on as wide a range of hardware as they can possibly support.

Cyberpunks Build Their Own Alexa

If you really want Echo functionality without buying an Echo, you can run the voice-controlled assistant on your Android phone, Mac OS, Windows and XBox, and Linux.

We wanted to try it out on our Raspberry Pi because we didn’t fancy having a desktop PC cluttering up the kitchen, and leaving our phones on the surface is to invite snoopers.

The Pi is a bare-bones piece of hardware, little more than a credit card sized naked circuit board with a bunch of ports, holes, and pins into which you can plug whatever you choose.

You’ll need a USB microphone so the unit can hear your instructions and a speaker so that it can talk back to you. A case to make it look more elegant and integrated would be nice. Or you could 3D print something suitable yourself.

We used what we had lying around the place.

After flashing a fresh copy of Raspbian onto our SD card and setting up WiFi and SSH, we followed this tutorial to load our gloriously open-source, privacy-respecting, single-board computer with one of the most privacy-invading pieces of software in the world.

How was it?

It was okay, although for our untechnical selves, setting up a bluetooth speaker on the command line was a bit of a headache. The Pi now functions as an Echo Dot. We can ask it questions; we can stream music from Amazon Prime. If we had any smart gadgets at home, we would be able to control them as easily as if we were running Alexa on genuine Amazon hardware.

Our microphone is a bit shit and makes it seem as if we’re hosting a karaoke party, but low-profile USB microphones with better performance can be bought online.

The gigantic flashing bluetooth speaker adds to the Tokyo Salaryman after-hours theme, but we’re sure you can design something better yourself.

If you're enjoying what you're reading, why not go ahead and sign up for updates from CyberPunks.com?

Open Source Code
Open Source Code

Open Source Software on Open Source Hardware

We didn’t buy a stack of Raspberry Pis so that we could suborn them into being yet more slaves to Amazon’s virtual Stasi. Regardless the quality of the peripherals or how nicely we dress the hardware up in sleek 3D printed cases, any machine running Amazon’s software is an Amazon machine. You may as well purchase an Echo.

There are better alternatives available, and we’re not talking about using another megacorp’s data-mining software either. The Raspberry Pi was created to run open source code on open source hardware and goddamn it, that’s what we’re going to do.

Mycroft AI was designed to be as privacy respecting as it’s possible for a constantly listening virtualized assistant to be. It runs on pretty much anything. We have a couple of Raspberry Pi Model 4s, but it will just about stagger along on 2015’s Pi 2. You can dump it onto an Android handset if you have some fluency with Android development tools. For Windows and MacOS, you’ll need to spin up a VM. But for most Linux distros, installation is as simple as cloning the mycroft-core repo to your system and running a shell script. You can even run Mycroft from a docker container.

For us, the easiest option was to download a customized Mycroft/Raspbian image file with the rather cute name of Picroft and flash it to the Pi’s MicroSD card.  We shouldn’t need to mention it, but this will destroy the contents of the SD card.

After we logged in through SSH, Picroft gave us the option of accepting help in setting up the system or ” Nope, just get me a command line and get out of my way!” We’re not masochists, and we chose the semi-automated route.

Setup was smooth, and our hardware was detected with minimum fuss or input from us. We clicked through the defaults and created an account on mycroft.ai without reading the terms and conditions.

Just kidding, we always read the T&Cs. We were ready to go.

Because here’s the thing: although Mycroft is hosted locally and doesn’t need to connect to the central Mycroft servers, it makes life a lot easier if you let it–at least, when you’re starting out on your Mycroft journey. It means you can download and install skills auto-magically through a web interface rather than cloning them manually and editing conf files to make them run. Voice recognition and synthesis is also a lot quicker. It’s up to you.

“Hey Mycroft, tell me a joke.”

“Hey Mycroft, remind me to take the dog out.”

“Hey Mycroft, how do you mix a Gin Fizz?”

It’s pretty fricking awesome.

For entertainment, you can have it linked to your premium Spotify account, your Pandora account (not available in the UK), or connect it to your own Emby server. We quickly downloaded the Emby deb and installed it on our spare Pi. This was in addition to the Nextcloud instance and three WordPress sites it’s already running. We gave it access to our 14GB music library. It worked flawlessly, albeit with a few semantic misunderstandings. Frankly, we were amazed.

Currently, there isn’t a skill to play music from your Amazon Prime Music account. Given the objectives of the people who code Mycroft’s skills, there’s unlikely to be one soon. But there’s nothing stopping you from writing your own.

If you’re the kind of person who wants to control their thermostat by a voice command or turn the lights to disco seduction mode without getting out of bed, Mycroft has you covered. It works with the open source Home Assistant, Mozilla WebThings Gateway, and the Wink system.

Most of these skills aren’t core. They’re written by ordinary people who identify a need, write the code, and share it for other people to use. It’s a community, and that’s nice.

Is Mycroft Better Than Alexa?

As a polished product, the answer has to be a resounding “Hell no.” Amazon hardware is quality, it’s unobtrusive, and disappears quietly into the flock wallpaper. Mycroft seems to run best on whatever bits and pieces you have cluttering up your living room.

It doesn’t integrate nicely with Amazon services either. At least, it won’t until someone sees the need to write the code to make it do so.

The author exists permanently in disco-seduction mode
The author exists permanently in disco-seduction mode

But fundamentally, Mycroft/Picroft is your own machine, and that’s important. No, it currently can’t place phone calls or control your lawnmower, but it will if someone (perhaps you) writes the code for it to do so.

And whatever you tell Mycroft to do, it will keep to itself and never tell a soul.

“Mycroft, find me some narrated lesbian horse porn.”

We mentioned earlier that we signed up for an account on mycroft.ai. We didn’t have to. We chose to. During the signup process, we were asked if we would allow samples of our voice to be used to train the Mycroft software to be better. By default, the option is set to “no,” and we chose to leave it that way. But, it’s an option we can reconsider later.

We also clicked through 5,120 words of terms of use in addition to a 1,970 word privacy policy, both of which are fairly concise and straightforward by the standards of tech legal documents. We did read them and didn’t find anything egregiously alarming. However, we’re not going to spell out what’s in there; as with everything, it’s up to you to read them yourself.

Mycroft is what its users make it. Currently, the skills on offer are basic, but there’s no corporate owner dictating what it can and can’t be allowed to do. It will read fairytales to your kids. We’re already examining the code to persuade it to interface with the literotica sci-fi section.

With the right skillset, you can program a disco and automate your life. Install it in your car and pretend you’re Michael Knight. Us? We’re saying goodnight to Mycroft and recycling the hardware into something else.

Hey, chum. These posts don't write themselves. If you wanna stay in the know, it's gotta be a two way street.*

Leave a Comment

You may also like