Amazon Alexa on the Raspberry Pi

More and more people rely on language assistants like Alexa to perform simple everyday tasks such as setting timers, playing weather forecasts or switching lights on and off.

But can you also use Amazon’s speech recognition without Alexa? Yes! With a Raspberry Pi, a microphone and some programming skills. Below you will learn how to install Amazon Alexa on the Raspberry Pi.

The Project

Suitable for: Beginner

Time required: 45 min

Budget: 50€

What you need: Raspberry Pi 2 (or higher), SD card, USB power supply, USB microphone, speaker with 3,5mm jack connector

Prerequisite: possession of mouse, keyboard, screen, Internet access and Amazon account

Set up Raspberry Pi and find out IP address

If you already own a Raspberry Pi and you already know the IP address of your Raspberry Pis, you can skip this step. If this is not the case, you can download the current operating system from the https://www.raspberrypi.org/downloads/ website. You will find many detailed instructions on how to set it up on the Internet, which is why we do not want to go into it further in this How-To. Start your Raspberry Pi and open the terminal first. Enter the following command: ifconfig

Now you can read the IP address as shown in Figure 1. You should make a note of the address, as it will be needed later.

IP-Adresse
Figure 1: Find out IP address of Raspberry Pi

Set up Amazon Developer account

Before you continue with the Raspberry Pi, you need an Amazon Developer Account (Developer Account). To do this, open the following page: https://developer.amazon.com/de/

Amazon-App
Figure 2: Amazon Appstore
Einloggen
Figure 3: Log in or create an account

Click on the “Sign in” button at the top right and create a developer account.

Voice-Service
Figure 4: Alexa Voice Service

After creating the account, log in and create a security profile. To do this you need to go to the Alexa tab, then to Alexa Voice Service and then to Get Start. On this page, go to Products then Create Product. Now you will see a form that you have to fill out.

Fill in the empty fields as followed:

– Product name: AlexaPi
– Product ID: AlexaPi
– Select: Device with Alexa built-in
– Select: NO
– Product category: Smart Home
– Letter product description: RaspberryPiAlexa
– Choose: Hands-free, Far-field
– Here you can upload a picture (optional)
– For the remaining questions, select: NO

Then confirm with NEXT.

Now you can create your personal security profile. Proceed as follows:

– Security Profile Name: AlexaPi
– Security Profile Description: AlexaPi
– Copy the three ID´s and save them in a .txt file (will be useful later)
NEXT

IDs speichern
Figure 5: Saving ID’s in a text document

If you scroll down, you will find two lines called Allowed origins and Allowed return URLs. To fill these lines, you need the IP address of your Raspberry Pis.
Now add the URLs listed one after the other.

For Allowed origins:

– https://<<< your.ip address >>:5050
– http://<< your.ip-adresse >>:5050
– https://localhost:5050
– https://localhost:5050

For Allowed return URLs:

– https://<<< your.ip address >>:5050/code
– https://<<< your.ip address >>:5050/code
– https://localhost:5050/code
– https://localhost:5050/code

Replace all << your.ip address>> with the correct IP address of the Raspberry Pi’s.
If you have successfully added all URLs, it should look like Figure 6.

URLs hinzufügen
Figure 6: Add URL’s

Under Capabilities you can check the boxes as shown in Figure 7.

Capabilities
Figure 7: Setting for Capabilities

Starting the installation

Before you start with the installation of Alexa, you should copy the previously saved text file with ID´s to the Pi. A USB stick would be useful.

Open the terminal on the Raspberry Pi again and enter the following commands:

1. First we have to go to the /opt directory: cd /opt
2. Download git: sudo apt-get install git
3. Now copy the AlexaPi folder from the Github: sudo git clone https://github.com/alexa-pi/AlexaPi.git
4. Installation: sudo ./AlexaPi/src/scripts/setup.sh

Then follow the instructions in the terminal.

Before the end of the installation you will be asked for the Device Type ID and Security Profile Description, to which you have to answer both with AlexaPi.

Then the terminal will ask for Security Profile ID, Client ID and Client Secret. Simply copy the IDs from the text file. Confirm with Enter.

IDs einfügen
Figure 8: Add URL’s

Next, open your browser on your PC and enter the URL in the URL bar:

https://<<<your.ip-address>>:5050

Then click on Allow and select Germany in the next step.

Success Meldung

Leave a Reply

Your email address will not be published. Required fields are marked *