Hey there folks, happy weekend! Hope this post finds you well. This is a follow up to my previous post on how to make your own Amazon Alexa / Echo device from a Raspberry Pi.
First, an Apology for the Cliff Hanger
I left you hanging at the end of that post, and I’m very sorry about that. It was a Friday morning at almost 4 a.m., and I was ready for bed. So, here we are on the weekend! I’ve now had the chance to do some further validation and documentation in testing our DIY Amazon Alexa / Echo from a Raspberry Pi.
The samples I’ve provided aren’t super in depth, but serve as proof of concept.
Recap: Where We Left Off
Here’s where we were at the end of the last article:
The first terminal will set Alexa up to be listening on port 3000 (remember the local host URLs from earlier?) The second window deals with setting up a Java client and logging into Amazon with the Security profile we set up. Logging in and confirming will enable you to initiate the connection to Alexa, paving the way for the third terminal, which enables the wake word detection and actual running of the Alexa service. Woohoo! I’ll update with examples later.
I’ve booted up our trusty Raspberry Pi back up, and opened 3 command line terminals.
Preparing for Test
1. Companion Service
First item of business, is to run the companion service, first command line terminal. Type the below:
cd Desktop/alexa-avs-sample-app/samples/companion service && npm start
After returning the above line of code, successful output should end with, “Listening on Port 3000” and “Successfully retrieved registration code for xxxxxxx / xxxxxxx ”
Below, steps 1 & 2 combined since I was a bit slow on thinking to photograph in the moment. 🙂
2. Java Client / Authorizing Device
The second piece for testing here is the Java client and authorizing the device with Amazon. (Remember the security profile setup from the previous How to Build Article?) In the second command line terminal, type the following:
cd Desktop/alexa-avs-sample-app/samples/javaclient && mvn exec:exec
A few things should happen here, outside of Matrix-like code waterfalls. First, a window prompting you to login to Amazon to enable the security profile for your device should appear. Second, after you click through to the browser (or paste URL into browser), you should see a log-in screen like the below. Enter your credentials, approve access, and close the window after you see a screen that displays the message, “device tokens ready”
After you’ve completed the above steps, you should have a window (slightly hidden in the center, photo above) with a bearer token and a button to listen. At this point, I just ran a simple test saying, “hello” and Alexa said, “hello” back. We’re almost there!
3. Wake Word Detection / Connecting to AVS Client
The final piece is connecting to the AVS client and enabling wake word detection, which means we don’t have to press the “Listen” button every time we want to do something. Last piece of command line!
cd Desktop/alexa-avs-sample-app/samples/wakeWordAgent/src && ./wakeWordAgent -e kitt_ai
After the script runs, the last line of code output should read, “Connected to AVS Client”. You’re now ready to use Alexa.
Below is one of the quick tests I ran on Pi Alexa. Si
mple time check and request for a joke. Now we’re cooking with gas!
Building an Alexa has been a very instructive process. I don’t know about you, but I’m ready for actual skill development now. Stay tuned as I recap the changes through my first Alexa skill, a remix of the Space Geek sample, and begin working through more advanced skills and concepts such as analytics integration. Cheers!