In the past few days I have been experimenting with Amazon Alexa AVS, with a Raspberry Pi 3 as the hardware component. The final goal is to build a custom Alexa Skill. To even begin development, the hardware to communicate with Alexa AVS is a hard necessity. There are dozens of devices on the market for this, but in my case, I wanted to use the Raspberry Pi, which had been catching dust as a printer server ;) In this and subsequent articles I will explain some of the challenges I ran into and the solutions I found to solve them.

The Story

Last week a colleague inspired me to have a look into Amazon Alexa AVS (Alexa Voice Service). This Amazon service allows developers to build conversation models with Amazon Alexa, the sweet voiced AI assistant. To save me the effort of buying an Amazon Echo Dot, or one of the other available hardware devices to interact with Alexa, I decided to try and set up the hardware on a Raspberry Pi 3

It turned out to be more challenging than buying an Echo Dot, but in between all the frustrating moments, it was actually quite a lot of fun when achieving new milestones in the setup process.  One of the milestones was a headless start of Alexa on the Raspberry Pi, with a functioning wake word feature.

Raspberry Pi Hardware

One obvious prerequisite to interact with a voice service is a working audio setup. In the case of the Raspberry Pi sample application, this means:

  1. A microphone connected to the Rasberry Pi's USB port
  2. A speaker, connected to the Rasberry Pi's 3.5mm audio jack

It should look something similar to my setup, seen on the picture below. This exact hardware setup is expected by the Alexa AVS Raspberry Pi Sample App.

Raspberry Pi 3 for Alexa AVS
Raspberry Pi 3 Hardware

In my case, just following the installation instructions worked like a charm and everything ran without any problems, instantly.

First Challenge:

Alexa AVS Sample App, Headless

My next challenge was to have the 3 scripts (companionService, javaClient and wakeWordAGent) start at boot time of the Raspberry Pi, so that I could run Alexa "headless" (i.e. without a monitor / keyboard). I tried several approaches to achieve this, among which the approach described here, which did not work at all. A more promising script I found at Unfortunately, after running this script, the wakeWordAgent stopped working.

The wake word is part of an Alexa Skill, which is set in the Amazon Developer Portal when designing the skill. It's intended to activate a specific Alexa Skill by saying for example "Alexa, start <my wake word>".

The error presented by the wakeWordAgent script, no matter whether it was working with sensory or kit_ai, consisted of several variations of the same root cause: A problem with the .asoundrc file in the home directory of your Raspberry Pi user. The error message always boiled down to: "ERROR:An error happened in the mainLoop of SensoryWakeWord snsrRun(): task: Input channel audio-pcm: ALSA error: No such file or directory".

After hours trying to figure this out, editing the .asoundrc and various other configuration files on my Raspberry (producing all kinds of variations to the earlier error message), I decided to go for the nuclear option and re-install the sample app. Before re-installing, I first deleted the .asoundrc and existing installation from the Raspberry Pi.

Every time I did this, it solved the problem and the Wake Word was picked up again by Alexa. In fact, what I found out is that installing the sample app according to the instructions, will actually create a .asoundrc file in your home directory on the Raspberry Pi. The created .asoundrc will assume the exact setup as outlined above and configure it correctly.

But the "headless" challenge was still to be solved....

Then, finally, I ran into this youtube video, which contains a detailed explanation on how to run Alexa headless. Thanks misperry for the explanation. Alexa is running headless now!


Add comment

Security code