Category Archives: Smart Home

Amazon Alexa functionality on Raspberry Pi

Alexa (wiki) is Amazon’s cloud-based voice service available on number of devices. It provides a natural voice experiences for interaction, playing music and other options. There are devices, produced by Amazon, as well, as supported by other vendors.

There is an Alexa Skill Kit to create custom products, based on the Amazon Alexa services. It is also available API and SDKs to integrate Alexa into own connected products.

This article walks through one of such option – to build own device, connected to Amazon Alexa, using Raspberry Pi single board PC.

Different projects

Following options require an powered speaker and a USB microphone. It is recommended to use Raspberry Pi3, however Raspberry Pi2 should work as well.

  • An option on Python – “the project allows to launch Alexa on any Linux devices, even on embedded devices like Raspberry Pi (with usb headset)”. A guideline to set it up.
  • An option on Python “a client for Amazon’s Alexa service. It is intended and tested to run on a wide range of platforms, such as Raspberry Pi, Orange Pi, CHIP and ordinary Linux or Windows desktops“. A guideline to set it up.
  • An option – the project provides step-by-step instructions for setting up Alexa Voice Service (AVS) on a Raspberry Pi and using wake word engines from Sensory or KITT.AI”. Discontinued – authors has put their project “into maintenance mode. To leverage the latest Alexa features, please use the AVS Device SDK C++ Sample App
  • An option, used in this article – , mentioned earlier as “AVS Device SDK C++ Sample App”.

AVS Device SDK C++ Sample App

Prepare Raspberry Pi

sudo apt-get update
sudo apt install xfce4 xfce4-goodies tightvncserver
In case errors, related locale
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
 LANGUAGE = (unset),
 LC_ALL = (unset),
 LC_CTYPE = "UTF-8",
 LANG = "en_GB.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_GB.UTF-8").

Fix locale

sudo locale-gen "en_US.UTF-8"
sudo dpkg-reconfigure locales

Resize the CF card

Run a command resize2fs as shown below. “/dev/sda2” is a volume name of the CF card, which can be found with a command lsblk

resize2fs -p /dev/sda2

Another option (only in GUI mode) is to use a graphics tool for disk, volumes and partition management: GParted

sudo apt-get install gparted
sudo gparted

Follow the guideline Raspberry Pi Quick Start Guide with Script – step-by-step instructions to set up the Alexa Voice Service (AVS) Device SDK on a Raspberry Pi.

Issues within a step, when starting


ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
#       Client not connected!       #
Failed to initialize SampleApplication
Failed to create to SampleApplication!

Solutions from Alsa lib conf issue #105

1. Not connected USB microphone

  • Check out this guideline of follow the next brief instruction
  • Check available recording devices
arecord -l

If the respond is as following – there is no recording devices available

**** List of CAPTURE Hardware Devices ****
  • Connect a USB microphone or a USB headset to the Raspberry Pi and check again. Example of a connected UCS headset
**** List of CAPTURE Hardware Devices ****
card 1: LX3000 [Microsoft LifeChat LX-3000], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Set the USB audio device as default


  • Try to record audio and play it back – the command records audio from the default recording device to the specified file during 10 seconds
arecord -d 10 test-mic.wav
  • It might be an error related to not supported format
Recording WAVE 'test-mic.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono
arecord: set_params:1299: Sample format non available
Available formats:
- S16_LE
  • Specifying the format will lett make record – example
arecord -f S16_LE -d 10 test-mic.wav

However this may lead to the other issues. So follow the further steps to change the ~/.asoundrc

  • Check available asound cards
    cat /proc/asound/cards


    Check which one is selected as current for playback and for capture. In this example: “ALSA” is a card #0, it is used for playback, “USB-Audio – Microsoft LifeChat LX-3000” is a card #1, it is used for capture. So the file ~/.asoundrc should be like following

pcm.!default {
  type asym
   playback.pcm {
     type plug
     slave.pcm "hw:0,0"
   capture.pcm {
     type plug
     slave.pcm "hw:1,0"
  • If file has been created – check it, replaying it with the command
aplay test-mic.wav
  • Note: changes of the default (or current) audio in the GUI will change this file ~/.asoundrc

2. Not licensed Sensory engine

Is the Sensory library you are using licensed? If not, there is a script in the Sensory project you downloaded from Github under bin/ that you can use to license to the project. You may not may not have to re-link the Sensory library.


If everything has been setup well – there will be following information and a option’s info displayed (i+Enter – shows this option’s info).


Press “q” (end “Enter”) to quit the sample.

There are some advises in the troubleshooting guide. One of them – to test the issue “No audio output from the SDK“. To do the testing – install GStreamer

sudo apt-get install libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools


Useful resources: