Skip to content

Conexant4Mic Raspberry Pi

tamashin edited this page May 1, 2017 · 16 revisions

On this page


Overview

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.


Required hardware

Before you get started, let's review what you'll need:

  1. Conexant AudioSmart 4-Mic Development Kit for Amazon AVS - Buy
  2. Raspberry Pi 2 - Buy at Amazon - Pi 2
  3. 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).
  4. External Speaker with 3.5mm audio cable - Buy on Amazon
  5. A USB Keyboard & Mouse, and an external HDMI Monitor to connect to the Raspberry Pi.
  6. Internet connection (Ethernet or WiFi) - For WiFi, you will need a USB WiFi Dongle

Setup Instructions

Step 1: Download and write the Raspbian OS to an SD card

Using Win32DiskImager

  1. 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.

SD-card-format-1 SD-card-format-2

  1. Download a Raspbian OS using kernel 4.4. The latest Raspbian OS can be found at the following location: https://www.raspberrypi.org/downloads/raspbian/

  2. 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/

  3. 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.

  1. Once the SD card has the OS loaded, setup the hardware connections.

Step 2: Setting up the Conexant AudioSmart 4-Mic Development Kit for Amazon AVS

Make the hardware connections between the CX20924-EVK and the RPi2. If you haven't setup your Development Kit, see the TBD.

  1. Connect the cable assembly to the GPIO pins on the RPi. Align the sticker labeled ‘1’ with physical pin 1 on the RPi2.

![](assets/Plugging IO to Pi 2.jpg)

  1. Connect output of 4-Mic processing signal

    a. Use the USB cable to connect J4 on the CX20924 EVK board to an USB port on the RPi

  2. Connect the powered speakers to the LineOut port.

    a. Connect the 3.5mm jack from the powered speakers to J8 on the CX20924 EVK board.

  3. Using the HDMI and USB ports on the RPi2, connect the RPi to the monitor, keyboard, and mouse.

  4. Connect the 5V supply to the J1 connector on the evaluation board. Use the +5V power supply included with the kit to power the CX20924 EVK board, Microphone / LED module, and the RPi2.

Note: Power to the RPi2 is provided from the CX20924 EVK and the Micro-USB power on the RPi2 is not used.

When assembled, your setup should look like this:


Using Terminal

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.


Step 3: Register for an Amazon developer account

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.


Step 4: Create a device and security profile

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 6 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).


Step 5: Clone the sample app

Open a terminal window and type the following:

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

Step 6: Update the install script with your credentials

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.


Step 7: Run the automated install script

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 following 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.

Step 8: Building/Installing the Linux kernel

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 . Refer to the readme file for instruction on building/installing the kernel.

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.

Step 9: Run your LED server, Node.js service, sample app, wake word engine, and recordingAgent

Now that installation is complete, you'll need to run five commands in 5 separate terminal windows:

  1. Terminal Window 1: for LED functionality on the 4-mic setup
  2. Terminal Window 2: to run the web service for authorization
  3. Terminal Window 3: to run the sample app to communicate with AVS
  4. Terminal Window 4: to run the wake word engine which allows you to start an interaction using the phrase "Alexa"
  5. Terminal Window 5: to run the recordingAgent, which sends audio content continuously to the client

Note: These commands must be run in order.

Terminal Window 1

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

Terminal Window 2

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.


Terminal Window 3

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.

  1. 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.

  2. 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).

  3. You'll be taken to a Login with Amazon web page. Enter your Amazon credentials.

  4. 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.

  5. 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.

  6. Return to the Java application and click the OK button. The client is now ready to accept Alexa requests.


Terminal Window 4

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:

Terminal Window 5

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!


Step 10: Talk to Alexa

You can now talk to Alexa by simply using the wake word "Alexa". Try the following -

  • Say "Alexa", then ask "What time is it?"
  • Say "Alexa", then ask "What’s the weather in Las Vegas?"
  • Say "Alexa", then say "Set a timer for 5 seconds."
  • Say "Alexa", then say "Play Z100."
  • Say "Alexa", then say "Good afternoon."
  • Say "Alexa", then say "Tell me a joke?"
  • Say "Alexa", then ask "What’s the meaning of life?"
  • Say "Alexa", then say "Sing happy birthday."
  • Say "Alexa", then ask "What day of the week does Christmas fall on?"
  • Say "Alexa", then ask "Where were you born?"
  • Say "Alexa", then 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 LED cue before beginning to speak. It may take a second or two before you see the LED cue.