Setting up Alexa – Part 2

The second part on a series of setting up Alexa Voice Services on a Raspberry Pi.


In this second part of the Alexa setup I will be installing the software onto my Pi.

Connect to the Pi using ssh.

Move into the “smartmirrorproject” directory

cd smartmirrorproject

Amazon kindly delivers a Java sample application you can pull from GitHub that lets you interact with Alexa.  You don’t have to write all of the code yourself, but you can edit it.  And that just what we’ll do later on.

But first things first.  I say that a lot, don’t I 🙂

Pull the Alexa software onto the Pi by typing

git clone

Amazon delivers an installation script that does all of the hard work (installation work that is) for you.  However, it needs some information.  It needs the keys that were generated for you in the first step of the Alexa configuration.

Change directory into the alexa-avs-sample-app.

cd alexa-avs-sample-app

Open up the installation script by typing


At the beginning of the file you can copy-paste your keys into the placeholders.

The ProductID in our case is “SmartMirror”.  The ClientID and ClientSecret can be found in the security profile on your Amazon Developer Portal.

Ctrl-x Y enter to get out of nano.

Time to start the installation script by typing


It’s an executable file, so it will start automatically.  Next, you are prompted with a number of questions.  I answered “y” to all of them.  One of them is the question if I was going to attach speakers to the 3.5mm jack output of the Pi.  I chose yes, but later on we can change that to re-route the output through the HDMI output should the screen contain speakers.

Installing this will take a while.

For the next steps it’s important you use VNC to see the desktop, and don’t use ssh.

Open a terminal and navigate to

cd smartmirrorproject/alexa-avs-sample-app/samples/companionService


npm start

to start the application.  You will see it is listening on port 3000.

The companion service is responsible for the authentication in this case.  Next, we want to start the Java application that will take care of sending to audio to AVS and receiving it back.

Open a second terminal and type

cd smartmirrorproject/alexa-avs-sample-app/samples/javaclient

then type

mvn exec:exec

This will start a tool called “maven” which will execute a series of commands to start the Java Client application.

When the application starts it will prompt you with a dialog box.

Schermafbeelding 2017-01-07 om 22.23.22.png

Click Yes to open in your default browser.   Pay attention : a new dialog will appear asking you to click OK.  Don’t do that yet.  I repeat.  Don’t do that yet.

In the browser window you will need to provide your developer account credentials.  It will probably ask you to do it twice (using a captcha) and click OK.  After doing so, the window will say “Device Tokens are ready”.

At that time, click OK in the window you couldn’t press OK on a minute ago.

A code will automatically be entered in the java application.

Schermafbeelding 2017-01-07 om 22.25.23.png

Click “listen” to activate Alexa.  Should work. 🙂

Lastly we can activate the wake word engine.  The wake word engine is yet another application you need to start, that constantly listens for the word “alexa”, and if it heres it, it will automatically click the “listen” button for you.  Isn’t that the coolest thing.

Open up a third terminal window, and go to the directory

cd smartimirrorproject/alexa-avs-sample-app/samples/wakeWordAgent/src

The wake word engine comes with 2 different technologies you can use : sensory and kitt_ai.

The first one will stop working after 90 days, so we’ll go with kitty_ai.

Start the process by typing :

./wakeWordAgent -e kitt_ai

Mind the “./” at the beginning.  It’s important.

Once started, you can all Alexa and ask anything you like.

Now here’s the sad part.  These last parts are steps you need to take every single time you restart the Pi.  It requires authentication every time.

Amazon states in its documentation the companion service that is started in the above steps is just a demo service, but it’s possible to create your own application that handles the authentication without human interaction.  That’s what we’ll be trying to do.  That way, Alexa can be started every time the Pi boots.  Things to think about!



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s