-
Notifications
You must be signed in to change notification settings - Fork 9
Conexant4Mic Raspberry Pi
This guide provides step-by-step instructions for setting up an Alexa prototype using a Conexant AudioSmart 4-Mic Development Kit for Amazon AVS and a Raspberry Pi. It demonstrates how to access and test AVS using the Conexant development kit, our Java sample app (running on the Raspberry Pi), a Node.js server for authorization (running on the Raspberry Pi), and a third-party wake word engine that responds to "Alexa" (running on either the Development Kit or the Raspberry Pi).
When finished, you'll have a fully functioning AVS prototype that uses Conexant's development kit as an audio front end.
Before you get started, let's review what you'll need:
- Conexant AudioSmart 4-Mic Development Kit for Amazon AVS - Buy
- Raspberry Pi 2 - Buy at Amazon - Pi 2
- Micro SD Card (Minimum 8 GB) - You need an operating system to get started. NOOBS (New Out of the Box Software) is an easy-to-use operating system install manager for Raspberry Pi. The simplest way to get NOOBS is to buy an SD card with NOOBS pre-installed - Raspberry Pi 8GB Preloaded (NOOBS) Micro SD Card. Alternatively, you can download and install it on your SD card (follow instructions here).
- External Speaker with 3.5mm audio cable - Buy on Amazon
- A USB Keyboard & Mouse, and an external HDMI Monitor to connect to the Raspberry Pi.
- Internet connection (Ethernet or WiFi)
This guide assumes that you've already setup your Conexant AudioSmart 4-Mic Development Kit for Amazon AVS. If you haven't setup your Development Kit, see the TBD When assembled, your setup should look like this:
Using NOOBS
Next we’ll need to install Raspbian Jessie on our Raspberry Pi. The easiest way to do that is by downloading NOOBS.
What is NOOBS? NOOBS is an easy operating system installer which contains Raspbian. It also provides a selection of alternative operating systems which are then downloaded from the internet and installed.
NOTE: If you have a micro SD card that came with NOOBS pre-installed, make sure it has Raspbian Jessie available as one of the install options. If not, follow the steps below to download the latest version of NOOBS.
- Download the latest NOOBS zip file - downloads.raspberrypi.org/NOOBS_latest
- Format the SD card using SD Formatter
- After your SD card has been formatted, drag all the files from the extracted NOOBS folder and drop them onto the SD card.
- Insert your micro SD card with NOOBS pre-installed into the micro SD card slot on your Pi.
- Plug in your USB keyboard and mouse.
- Connect your monitor using the HDMI port.
-
Plug in the USB power cable to your Pi.
-
Your Pi will boot, and a window will appear with a list of different operating systems that you can install.
-
Tick the box next to Raspbian and click on Install. Make sure it is Debian Jessie, and not Debian Wheezy.
-
Raspbian will run through its installation process. Note: This may take a while - get a cup of coffee (maybe brew a pot -- tea is an acceptable alternative).
-
When the installation is complete, the Raspberry Pi configuration menu (raspi-config) will load. Here you can set the time and date for your region and enable a Raspberry Pi camera board, or even create users. You can exit this menu using Tab on your keyboard to move to Finish.
-
Once rebooted, login to your Pi. The default login for Raspbian is username pi with the password raspberry
NOTE: To load the graphical user interface at any time type startx into the command line.
More info: raspberrypi.org
Using Win32DiskImager
- Format the SD card. This can be done by going to the ‘Computer’ folder and right clicking on the SD card. Click ‘Format…’ to display the format options. When reformatting, make sure the File system is FAT32 or FAT.
-
Use a Raspbian OS using kernel 4.4. The latest Raspbian OS can be found at the following location: https://www.raspberrypi.org/downloads/raspbian/
-
Unzip and write the downloaded image to the SD card using Win32DiskImager. This tool can be found at the following link: https://sourceforge.net/projects/win32diskimager/
-
Next, use Win32DiskImager to write the image to the SD card
Select the image file by clicking the Folder icon and select the device drive, making sure to point to the correct device. Click Write to write the image to the SD card. After the image has finished writing, put the SD card into the RPi.
- Once the SD card has the OS loaded, continue to the next sections.
NOTE: You will be using the Terminal utility on your Raspberry Pi to install the utilities you need for this AVS walkthrough. Terminal comes preinstalled on the Raspberry Pi, and you can get to it from the Desktop. You can learn more about Terminal here.
Unless you already have one, go ahead and create a free developer account at developer.amazon.com. You should review the AVS Terms and Agreements here.
Follow the steps here to register your product and create a security profile.
Make note of the following parameters. You'll need these in Step 5 below.
-
ProductID
(also referred to as Device Type ID in the Amazon Developer Portal), -
ClientID
, and ClientSecret
Important: Make sure your Allowed Origins and Allowed Return URLs are set under Security Profile > Web Settings (see Create a device and security profile).
- Allowed Origins: https://localhost:3000
- Allowed Return URLs: https://localhost:3000/authresponse
Open a terminal window and type the following:
git clone https://github.com/conexant/alexa-avs-sample-app.git
Before running the install script, you'll need to update it with the credentials you got in step 4 - ProductID
, ClientID
, ClientSecret
. Type the following in terminal:
cd ~/alexa-avs-sample-app
nano automated_install.sh
Paste the values for ProductID
, ClientID
, and ClientSecret
that you got in Step 4.
The changes should look like this:
ProductID="RaspberryPi2"
ClientID="amzn.xxxxx.xxxxxxxxx"
ClientSecret="4e8cb14xxxxxxxxxxxxxxxxxxxxxxxxxxxxx6b4f9"
Type ctrl-X and then Y, and then press Enter to save the changes to the file.
Now you're ready to run the automated install script. It will install all required dependencies, and wake word engines from Sensory and KITT.AI.
Note: The install script will install all project files in the folder that it is executed.
To run the script, open terminal and navigate to the folder where the project was cloned. Then run the this command:
cd ~/alexa-avs-sample-app
chmod +x automated_install.sh
. automated_install.sh
You'll be prompted to answer a few simple questions. These help to ensure that you've completed all necessary prerequisites before continuing.
When the wizard starts, go grab another drink - it takes about 30 minutes.
Note: Confirm that the AVS is configured before installing the kernel.
The linux kernel necessary for the 4-mic kit is located at rpi-linux .
After building and installing the driver, confirm that the /boot/config.txt file has the following parameters added:
dtoverlay=rpi-cxsmartspk-usb
dtoverlay=i2s_mmap
dtparam=i2c_arm=on
program_usb_boot_mode=1
Note: To ensure audio playback is through the driver just built, the default audio device should be disabled. Make the following change to the /boot/config.txt file.
dtparam=audio=off
Note: After the /boot/config.txt file is changed, reboot the device.
Now that installation is complete, you'll need to run five commands in 5 separate terminal windows:
- Terminal Window 1: for LED functionality on the 4-mic setup
- Terminal Window 2: to run the web service for authorization
- Terminal Window 3: to run the sample app to communicate with AVS
- Terminal Window 4: to run the wake word engine which allows you to start an interaction using the phrase "Alexa"
- Terminal Window 5: to run the recordingAgent, which sends audio content continuously to the client
Note: These commands must be run in order.
Open a new terminal window and type the following command to run the LED server for the 4-mic setup.
cd ~/alexa-avs-sample-app/samples/tLED && sudo python tLEDServer.py
Open a new terminal window and type the following commands to bring up the web service which is used to authorize your sample app with AVS:
cd ~/alexa-avs-sample-app/samples/companionService && npm start
The server is now running on port 3000 and you are ready to start the client.
First, configure the .asoundrc file with the correct settings. Note: This step is necessary to ensure correct audio playback and recording
cd ~/alexa-avs-sample-app/samples
cp ~/leftarc ~/.asoundrc
Open a new terminal window and type the following commands to run the sample app, which communicates with AVS:
cd ~/alexa-avs-sample-app/samples/javaclient && mvn exec:exec
Let's walk through the next few steps relevant to Window 3.
-
A window should pop up with a message that says -
Please register your device by visiting the following URL in a web browser and following the instructions: https://localhost:3000/provision/d340f629bd685deeff28a917. Would you like to open the URL automatically in your default browser?
Click on "Yes" to open the URL in your default browser. IMPORTANT NOTE: Don't respond to the second pop up until after you've logged in to your Amazon account.
-
If you're running Raspbian Jessie with Pixel desktop (and with Chromium browser), you may get a warning from the browser. You can get around it by clicking on Advanced -> Proceed to localhost(unsafe).
-
You'll be taken to a Login with Amazon web page. Enter your Amazon credentials.
-
You'll be taken to a Dev Authorization page, confirming that you’d like your device to access the Security Profile created earlier.
Click Okay.
-
You will now be redirected to a URL beginning with
https://localhost:3000/authresponse
followed by a query string. The body of the web page will say device tokens ready. -
Return to the Java application and click the OK button. The client is now ready to accept Alexa requests.
Note: Skip this step to run the same app without a wake word engine.
This project supports two versions of Sensory's TrulyHandsFree wake word engine. The -e
option is used to select the low-power embedded wake word engine running on the Conexant development kit or the high-performance wake word engine running on the Raspberry Pi.
Open a new terminal window and use the following commands to bring up the wake word engine from Sensory. The wake word engine will allow you to initiate interactions using the phrase "Alexa".
To run the embedded low-power Sensory wake word engine (on the Conexant CX20924), type -
cd ~/alexa-avs-sample-app/samples/wakeWordAgent/src
sudo ./wakeWordAgent -e gpio
IMPORTANT NOTE: You must run the wake word agent as admin.
or, to run the high-performance Sensory wake word engine (on the Raspberry Pi), type -
cd ~/alexa-avs-sample-app/samples/wakeWordAgent/src && ./wakeWordAgent -e sensory
Use the following resources to learn more:
- Sensory's TrulyHandsFree Wake Word Engine
- [ TBD - Conexant AudioSmart 4-Mic Development Kit for Amazon AVS]
Open a new terminal window and type the following command to run the recordingAgent, which sends the processed microphone signals to the javaclient:
cd ~/alexa-avs-sample-app/samples/recordingAgent && ./run.sh
Now you have a working hands-free AVS prototype!
You can now talk to Alexa by simply using the wake word "Alexa". Try the following -
- Say "Alexa", then wait for the beep. Now ask "What time is it?"
- Say "Alexa", then wait for the beep. Now ask "What’s the weather in Las Vegas?"
- Say "Alexa", then wait for the beep. Now say "Set a timer for 5 seconds."
- Say "Alexa", then wait for the beep. Now say "Play Z100."
- Say "Alexa", then wait for the beep. Now say "Good afternoon."
- Say "Alexa", then wait for the beep. Now say "Tell me a joke?"
- Say "Alexa", then wait for the beep. Now ask "What’s the meaning of life?"
- Say "Alexa", then wait for the beep. Now say "Sing happy birthday."
- Say "Alexa", then wait for the beep. Now ask "What day of the week does Christmas fall on?"
- Say "Alexa", then wait for the beep. Now ask "Where were you born?"
- Say "Alexa", then wait for the beep. Now ask "Can you rap?"
If you prefer, you can also click on the "Listen" button, instead of using the wake word. Click the "Listen" button and wait for the audio cue before beginning to speak. It may take a second or two before you hear the audio cue.