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.
Here is a quick list of stuff you need before getting started:
- Raspberry Pi (with raspberian installed and micro SD card inserted)
- USB sound card, or a USB mic
- Speaker (For me HDMI and my TV served the purpose)
- HDMI Cable (Setup VNC on Pi and you will not need this steps here)
- A Mouse and Keyboard
- 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 https://developer.amazon.com/login.html here. Once registered you need to add a device. Follow these steps to register you device:
- Login and go to ALEXA tab on your developer dashboard. As shown in the following figure:
- Click on Alexa Voice Services button. As shown in figure below:
- Click on Create a new Device Type link. Following page will open:
- Provide appropriate Device Type ID and Display Name. And then click Next button. Following screen will appear:
- Fill in the required information and then click Next button. Following screen will appear:
- 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:
- Click on Next button and you will see following screen:
- Provide device details information and then click Next button. Following screen will appear:
- Click the Submit button, and you device will be registered and shown on the devices list as follows:
Running services on pi:
- Open a terminal window on raspberry pi and type in the following command:
cd Desktop git clone https://github.com/alexa/alexa-avs-sample-app.git
Above command will download the sample app on the pi. Following figure shows terminal executing git clone command:
- 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 automated_install.sh
Press Ctrl+X and then Y from the keyboard for saving the changes.
- 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:
- 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.
- 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
- The following figure shows startup of authorization utility:
- 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
- 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:
- 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.
- Login page is displayed as shown in the image below:
- 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:
- Click the Okay button. You will be redirected to http://localhost:3000/authResponse page with message “device token ready“.
- Go to java client, you will be presented with following dialog box:
- Click the OK button and Java client will be ready to use as shown in image below:
- 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.