Easy Voice Activated Design with Amazon Alexa

Published By

We'll show you how to add the power of Amazon Alexa to your design using Conexant’s AudioSmart 2-Mic kit and the Raspberry Pi 4 so you can quickly and easily prototype for the new wave of voice activated IoT applications.

If you’ve ever wanted to quickly and easily build smart home device prototypes that offer an ideal voice user experience, Conexant's AudioSmart 2-mic development kit is for you.

AudioSmart™ 2-Mic Development Kit for Amazon AVS features Conexant’s CX20921 Voice Input Processor with embedded hands-free voice processing technology and preloaded with the Alexa™ wake word.

Basically this means you can develop cool new projects that can be commanded just by using your voice. Here's what you're going to need to get started:

The AudioSmart 2-Mic Development Kit

The Raspberry Pi 4 with a minimum 8GB SD card and NOOBS pre-installed or downloaded.

A power supply.

A USB keyboard and mouse.

An external HDMI Monitor.

An external speaker with 3.5mm audio cable.

An internet connection using Wi-Fi or Ethernet.

Follow along with the video tutorial to see step-by-step instructions, which are outlined below.

Hardware Set Up

We’ll start by setting up all the hardware, so we’ll first connect the audio jack on the Pi to the line on the dev board.

Then we’ll take the microphone module and connect this to the dev board where it says MIC 1.

Next connect the Micro USB from the 2-mic that says J1 USB to a USB port on the Pi.

Now we’ll connect the ground pin on the dev board, which should be at section P2, pin 15, to the Pi at GPIO pin 14. From there, we will connect the GPIO1 at section P2, pin 14 from the dev board, to the Pi at GPIO pin 13.

We’ll then take the powered speaker and connect it to the 2-mic on J3.

And then we will connect the mouse and keyboard to the Raspberry Pi, which would then be connected to an external HDMI monitor.

Finally, we just need to power the Pi with a Micro-USB cable, which you can just plug in to your computer, and use the power supply to power up the 2-mic. Flip the switch on the 2-Mic and the dev board and Pi should all be powered up.

Software Set Up

RP4 set-up:

Now that all the hardware is set up, let’s move on to the software portion.

What we’ll need to do first is to install Raspian Jessie on our Raspberry Pi. You could either have a micro SD that has been pre-installed with NOOBS or download the latest version of NOOBS here: downloads.raspberrypi.org/NOOBS_latest.

Downloading might take a while, so in the meantime make sure to format the SD card to either FAT or FAT32 by using an SD card formatter program that you can find online. Once the files have been downloaded, extract the files and drag all of them from the extracted NOOBS folder to the SD card.

With the NOOB files in the SD card, insert the micro SD card into the micro SD slot on the Pi. Power up the Pi if you haven’t yet –you should see it boot up on the monitor. You’ll see a window with a list of operating systems to install, but for us, we’ll just install Raspbian Jessie.

The installation process might take some time, so feel free to grab a snack.

Once that’s done, the Pi should be running smoothly on your monitor. Two things to do right away is to go to preferences and change your keyboard settings to what you’re familiar with. You should then connect to the internet.

Register with Amazon

The next thing you need to do is register for an Amazon developer account on developer.amazon.com. I recommend doing this portion on your Pi’s desktop since you’ll need to be copying and pasting some long code numbers.

Once you’ve got an Amazon developer account, you’ll need to create an Alexa device and security profile. Go to the Alexa tab and click on “get started” on the Alexa voice service. You’ll then see a drop down that says, “Register a product” where you’ll find "Device". In this window, you’ll just give a simple identifier for your product on the “Device Type ID,” which will be needed later, and a display name in the developer portal, which will be displayed to users when they register the product with Amazon. You can use "Testing" for this first display name. Then click "next", which will take you to the security profile.

Click on the security profile drop down and choose “Create a new profile.” Enter a name and description for your security profile and description. We used “Testing Voice App”. Click next, and you’ll be generated a Client ID and Client Secret, which you’ll be using later.

Now you’ll click on the “Web Settings" Tab. Be sure that the security profile you just created is selected in the drop-down menu, then click the “Edit” button.

In “Allowed Origins,” click “Add Another” and then enter https://localhost:3000, and on “Allowed Return URLs,” click “Add Another” and enter https://localhost:3000/authresponse. Then click next.

Here, you’ll find the device details, which you can fill out yourself, then click "next".

The last step for the registration will be to enable the security profile. You’ll need to open up a web browser and visit https://developer.amazon.com/lwa/sp/overview.html. On the top of the page, select the security profile you created earlier from the drop down menu and click "confirm". You need to enter a privacy policy URL beginning with http:// or https://, for demonstration purposes we used a fake URL such as http://example.com. Click "next" and the next screen will display your client ID and client secret where you’ll need to save these values. You're all registered!

Setting Up the Raspberry Pi

Now let’s go back to the Pi. First, you'll need to open up a terminal and type the following:

cd Desktop

and then type this line:

git clone https://github.com/alexa/alexa-avs-sample-app.git

Now you'll need to update the install script with the credentials we got from Amazon, which we’re the ProductID, ClientID, and ClientSecret. So we’ll type the following in the terminal first:

cd ~/Desktop/alexa-avs-sample-app

and then type:

nano automated_install.sh

It’ll take you to a screen where you’ll need to paste the values for ProductID, ClientID, and ClientSecret. Type ctrl-X and then Y and then press enter to save the changes.

Now we’ll have to run the automated script, which will install all the required project files. So open up a terminal again, and then run these commands:

cd ~/Desktop/alexa-avs-sample-app

chmod +x automated_install.sh

. automated_install.sh

You’ll be asked some questions so just go through them. And once it starts, you might want to grab a good snack again for the next 30 mins.

Once the installation is complete, you’ll have to run these next three commands in three separate terminals.

For terminal 1, we’ll type this command in to bring up the web service, which will be used to authorize your sample app with AVS:

cd ~/Desktop/alexa-avs-sample-app/samples/companionService && npm start

It should just run automatically and the server should now be running on port 3000.

Open up a new terminal and you should type the following command to run the sample app, which will communicate with AVS:

cd ~/Desktop/alexa-avs-sample-app/samples/javaclient && mvn exec:exec

A window should pop up to register your device, where you can just click yes. If at this point it does not pop up, that means that the installation process wasn’t successful. Make sure your internet does not have some kind of firewall, because the window won’t pop up if that’s the case. You’ll need to run the automated install script that we did a few minutes ago to fix this problem if it occurs.

If you didn’t have any problems, a window will pop up where it says that your connection is not private. All you have to do is go to advance and then click on “Proceed to localhost.” You’ll be taken to an Amazon login, where you can enter your Amazon credentials. You’ll be then taken to a Dev Authorization page. Click “Okay” to confirm that you’d like the device to access the security profile created earlier. This will take you a window where it should say “Device tokens ready.”

Now return to the Java application and click “Okay,” which now means that the client is ready to accept Alexa requests.

On the last terminal, you can decide whether to select the low-power or high-performance embedded wake word engine. For low-power, type in these commands on the terminal:

cd ~/Desktop/alexa-avs-sample-app/samples/wakeWordAgent/src

sudo ./wakeWordAgent -e gpio

or for high-performance, type this command on the terminal:

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

Whichever you choose, this should be the last step, and you finally have a working hands-free AVS prototype! This is a starting point for you to start making hands-free prototypes for whichever command you wish. It’s up to you to see how creative you can get!

As always, check back on Arrow.com to see the latest content for new and popular dev boards and kits.


See related product

RASPBERRYPI4 4GB | 4 Model B

Raspberry Pi Foundation Embedded System Development Boards and Kits View

See related product

Keyboard & Mouse Set | 1738

Adafruit Industries Keyboard and Mouse Combos View

See related product

71764756 | OKdo Multihead Pi 4 Power Supply 5.1V/3A

Raspberry Pi Foundation External Plug-In Adapters View

 

Latest Videos

Sorry, your filter selection returned no results.

We've updated our privacy policy. Please take a moment to review these changes. By clicking I Agree to Arrow Electronics Terms Of Use  and have read and understand the Privacy Policy and Cookie Policy.

Our website places cookies on your device to improve your experience and to improve our site. Read more about the cookies we use and how to disable them here. Cookies and tracking technologies may be used for marketing purposes.
By clicking “Accept”, you are consenting to placement of cookies on your device and to our use of tracking technologies. Click “Read More” below for more information and instructions on how to disable cookies and tracking technologies. While acceptance of cookies and tracking technologies is voluntary, disabling them may result in the website not working properly, and certain advertisements may be less relevant to you.
We respect your privacy. Read our privacy policy here