Voice assistants are a fun, intuitive way to interact with devices, but most options require specialized hardware and don’t allow for a lot of customization or tinkering. This is where Amazon Alexa shines. Amazon provides the API for using Alexa, allowing integration with custom devices to open a wide range of opportunities for both DIY/PoC and enterprise solution. In this tutorial, we’ll show you how we created an open solution to turn any Linux-based device into an Amazon Echo. Since Raspberry Pi is the most popular board for IoT projects, we decided to use it in our setup, but any Linux system can run the demo.
Below you’ll find the latest version of an Amazon Alexa virtual device project (version 1.1). This project aims to provide the ability to bring Alexa to any Linux device, including embedded systems like Raspberry Pi boards.
At the end, you will be able to build a voice-activated, digital home assistant, which will answer a multitude of questions, read books, play music, tell jokes, provide weather, and even more.
The binary release is packed into a snap package, which is a perfect way to deliver this project.
How to Add Alexa to a Raspberry Pi:
- You need to create your own Alexa Device on the Amazon developer portal.
Add http://alexa.local:3000/authresponse to the Allowed Return URLs and http://alexa.local:3000 to the Allowed-Origins.
- Connect an audio device: a microphone and speakers to your device. It could be a USB headset for example.
- Install the PulseAudio snap:
sudo snap install --devmode pulseaudio
- Install the Alexa snap from the store:
sudo snap install --channel beta alexa
- Open http://alexa.local:3000 in a web browser on a local device or a device on the same network.
Note: the app provides an mDNS advertisement of the local domain alexa.local. This is very helpful for using with monitorless devices.
- Fill in the device credentials that were created during step 1, click ‘log in’.
Note: the voice detection threshold is a float value for adjusting voice detection. The smaller the value, the easier it is to trigger. You may need to adjust it for your mic and voice.
- Fill in your Amazon credentials.
- Now you can speak with Alexa. The app uses voice activation, so say ‘Alexa’ and the phrase that you want to say to her. The app will make a beep via the speakers when it hears the ‘Alexa’ keyword and starts recording.
- Enjoy Alexa without the need to buy special hardware 🙂
Written by Nikolay Khabarov, Senior IoT Architect at DataArt.