Amazon Alexa on Raspberry Pi

Recently I ended up with Raspberry Pi. This little piece of hardware is very powerful and I decided to try it out. Very first thing I did was installed an operating system on my Pi. Here is the link which I followed while installing Raspberian.

Hardware required:

Here is a quick list of stuff you need before getting started:

  1. Raspberry Pi (with raspberian installed and micro SD card inserted)
  2. USB sound card, or a USB mic
  3. Speaker (For me HDMI and my TV served the purpose)
  4. HDMI Cable (Setup VNC on Pi and you will not need this steps here)
  5. A Mouse and Keyboard
  6. A power adapter for Pi

Connect USB keyboard, mouse, sound card (or mic ), HDMI, and power adapter. Connecting the power adapter will boot raspberry pi. Once the boot is completed we are good to go.

Registering the device:

An developer account is required for this step. Create an account by registering your self here. Once registered you need to add a device. Follow these steps to register you device:

  1. Login and go to ALEXA tab on your developer dashboard. As shown in the following figure:amazon_dev_dashboard.PNG
  2. Click on Alexa Voice Services button. As shown in figure below:alexa home.PNG
  3. Click on Create a new Device Type link. Following page will open:register device
  4. Provide appropriate Device Type ID and Display Name. And then click Next button. Following screen will appear:securityprofile
  5. Fill in the required information and then click Next button. Following screen will appear:sec_profile_details
  6. Note down above details as you will need them later. Click on Web Settings tab and then click the Edit button. Then click on Add Another link of Allowed Origin pane and type https://localhost:3000. Then repeat above step for Allowed Return URLs pane and type https://localhost:3000/authResponse as shown in the images below:
  7. Click on Next button and you will see following screen:devcie details page
  8. Provide device details information and then click Next button. Following screen will appear:device capabilities
  9. Click the Submit button, and you device will be registered and shown on the devices list as follows:registered device

Running services on pi:

  1. Open a terminal window on raspberry pi and type in the following command:
    cd Desktop
    git clone

    Above command will download the sample app on the pi. Following figure shows terminal executing git clone command:clone command

  2. Once sample app is downloaded, we are ready to add Amazon services security credentials to the sample app so that it is able to authenticate itself with Amazon services. Use the following commands to add security credentials:
    cd ~/Desktop/alexa-avs-sample-app

    nano commandsecprofiledetails

    Press Ctrl+X and then Y from the keyboard for saving the changes.

  3. Above command will update the installation script file. Now we are ready to run the installation script. Use the following command to run the installation script:

    install services

  4. This installation will take time, so sit back and relax. It will install third party utilities along with sensory and kitt_ai. Using these utilities you can invoke alexa voice services using the word ‘Alexa’. Once installation is done we are ready to start the client and talk to alexa. For this we need minimum of two terminals, but if you want to use wake word utilities then you can run them from third terminal window.
  5. In first terminal window we will run the web-services authorization utility. Use the following command to start authorization:
    cd ~/Desktop/alexa-avs-sample-app/samples
    cd companionService && npm start
  6. The following figure shows startup of authorization utility:started Companion service
  7. Next step is to start client app, open another terminal window and type the following command:
    cd ~/Desktop/alexa-avs-sample-app/samples
    cd javaclient && mvn exec:exec

  8. When the client is started for the first time it will ask for authentication. When above command executes completely a dialog box is displayed as shown in the image below:login_register_dialog_client
  9. Click Yes button. It will open browser window as shown in the image below. Click on ADVANCED link located left of Back to safety button. Then click on the Proceed to localhost (Unsafe) link.
  10. Login page is displayed as shown in the image below:amazon_login_page
  11. Type in your Amazon developer account credentials. And the click the Sign in using our secure server button. Dev authorization page is displayed as shown in image below:terms_and_conditions_page
  12. Click the Okay button. You will be redirected to http://localhost:3000/authResponse page with message “device token ready“.
  13. Go to java client, you will be presented with following dialog box:avs-click-ok.png
  14. Click the OK button and Java client will be ready to use as shown in image below:client started
  15. Click the Tap to speak to alexa button and say “Who’s the weather in New Delhi” or “What is Google”.

Note: You might get some errors when you click Tap to speak to alexa button. Keep an eye on the terminal window. If any error appears then go to Start -> Preferences -> Audio preferences. Select your sound card and select Microphone, Capture Microphone and Audio Gain options from the configure dialog box. I did a hit and trial to make it work.

You can also start wake word utilities using the following commands:

Sensory wake word utility:

cd ~/Desktop/alexa-avs-sample-app/samples
cd wakeWordAgent/src && ./wakeWordAgent -e sensory

KITT.AI’s wake word utility:

cd ~/Desktop/alexa-avs-sample-app/samples
cd wakeWordAgent/src && ./wakeWordAgent -e kitt_ai

You can add your own skills to alexa and perform custom actions for example ask alexa to switch on you lights, switch on TV and what ever you think is possible.


5 thoughts on “Amazon Alexa on Raspberry Pi

    • Hi puneet I did not faced this issue. But it seems like it’s a permission issue. Run the install command with sudo it should work. And yeah one more thing I cloned my code on desktop it might be the reason I didn’t ran into this issue.


  1. What i don’t realize is in reality how you’re now not actually a lot more neatly-liked than you might be right now.

    You are very intelligent. You understand therefore considerably relating to this matter, made me in my opinion consider
    it from numerous numerous angles. Its like men and women don’t seem to be involved until it’s
    something to do with Girl gaga! Your own stuffs great. At all times take care of it up!


  2. Oh my goodness! Amazing article dude! Thanks, However I am experiencing
    difficulties with your RSS. I don’t understand why I am unable to join it.
    Is there anyone else having similar RSS problems?

    Anybody who knows the answer will you kindly respond? Thanx!!


  3. Hi there very cool web site!! Man .. Excellent ..
    Amazing .. I will bookmark your website and take the feeds additionally?
    I’m glad to seek out a lot of useful information here within the
    submit, we need develop more strategies on this regard, thanks for sharing.
    . . . . .


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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s