Manual Setup

4
Last updated 11 days ago

For this tutorial, we assume you have a Raspberry Pi 3 with a recent version of Raspbian installed. For a quick and streamlined way to install Snips, check out the Sam Command Line Interface.

Installation

Step 1: Configuring network access

Please refer to the following guide to quickly walk you through how to get your Raspberry Pi connected to your network.

Step 2: Installing the Snips Platform

Snips is distributed as a Debian package. If you would rather installed Snips via Docker, please follow the Docker Setup Guide.

First, connect to your Raspberry Pi via SSH. We assume your device's hostname is the default raspberrypi.

ssh pi@raspiberrypi.local

From your Raspberry Pi prompt, update the APT package directory, adding the Snips repository:

sudo apt-get update
sudo apt-get install -y dirmngr
sudo bash -c 'echo "deb https://raspbian.snips.ai/$(lsb_release -cs) stable main" > /etc/apt/sources.list.d/snips.list'
sudo apt-key adv --keyserver pgp.mit.edu --recv-keys D4F50CDCA10A2849
sudo apt-get update

If, in the above, the fourth command failed due to pgp.mit.edu being down, try usingpgp.surfnet.nl or gpg.mozilla.org instead, e.g.:

sudo apt-key adv --keyserver pgp.surfnet.nl --recv-keys D4F50CDCA10A2849

We are ready to install the Snips Platform:

sudo apt-get install -y snips-platform-voice

Configuration

Configuring audio

This section shows you how to configure the audio input and output on your Raspberry Pi 3. Before you begin, plug your USB microphone to the Raspberry Pi, and connect your speaker or headphones to the audio jack.

Everything happens from the Raspberry Pi command line:

Step 1: List your devices

Audio output

To list all playback devices detected on the system, run the following command:

aplay -l

This will produce an output similar to the following:

**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0

The first device is what we are looking for: card 0 / device 0 (hw:0,0). The other device (hw:0,1) is HDMI audio output, which we won't use here.

Audio input

To list all audio capture devices, run the following command:

arecord -l

We should see something like this:

**** List of CAPTURE Hardware Devices ****
card 1: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0

Audio capture device here is card 1 / device 0 (hw:1,0).

Step 2: Select an input and an output

Specifying the appropriate input and output devices is done on the/etc/asound.conf configuration file. Open it with your favorite command line editor, e.g.:

sudo nano /etc/asound.conf

Add the following section, and make sure that the hw: references match with the output of aplay and arecord noted above:

pcm.!default {
type asym
playback.pcm {
type plug
slave.pcm "hw:0,0"
}
capture.pcm {
type plug
slave.pcm "hw:1,0"
}
}

Step 3: Adjust input and output volume

In order to configure the sound card, open alsamixer:

alsamixer

The sound card that controls the output volume is the one of the Raspberry Pi. It's called bcmX ALSA. The sound card that controls the input volume is the one of the microphone. Use the F6 key to select this card and the F4 key to play with the decibel gain.

If you can't change settings of your microphone it may due to the fact some microphones have no support mixer (that's the case for instance for the PlayStation Eye microphone).

Troubleshoot your audio setup (optional)

To run this test, you first need to stop the snips-audio-server service, as it takes hold of the microphone:

sudo systemctl stop snips-audio-server

Execute the following command, speak into your microphone, and hit CTRL-C when you are done speaking.

arecord -f cd out.wav

This will save a file, out.wav, containing what the microphone has recorded. To check that the microphone is properly working as well as the speaker, run the following:

$ aplay out.wav

You should hear the recorded sound. If you don't, you might want to play again with the decibel gain using alsamixer.

When you are satisfied that everything works, restart the Snips audio server:

$ sudo systemctl start snips-audio-server

Configuring the Automatic Speech Recognition (ASR) engine

Using the Snips native ASR module

If you use Snips on-device ASR, you're all set! This comes free and does not require a subscription.

We are continually adding languages to the Snips ASR. If, however, you wish to use a language that is not yet supported, you can use the Google Cloud Speed-to-Text service instead. Note though that this solution is cloud-based, and thus requires an Internet connection.

Using Google Cloud Speech-to-Text

Start by setting up your Google Cloud Speech-to-Text account and credentials on the Google API Console. From the Google Console, do the following:

  1. Enable the Google Speech API

  2. Download the credentials in JSON format

Next, copy the credentials file to your device, for example using scp. From your computer, run the following command from the directory where your googlecredentials.json file resides:

scp credentials.json \
pi@raspberrypi.local:/home/pi/googlecredentials.json

Connect to the Raspberry Pi:

ssh pi@raspberrypi.local

Using admin permissions, move the credentials file to /usr/share/snips:

sudo mv /home/pi/googlecredentials.json /usr/share/snips/

Finally, tell Snips to use the Google ASR service rather than the native one:

sudo apt-get remove snips-asr
sudo apt-get install snips-asr-google

Installing a demo assistant

The Snips Platform is installed as a set of standard services. The services are monitored by systemdand they are automatically launched after installation or when you boot the system. They are also relaunched if they crash.

If you want to try out a working instance, you can try out the demo assistant, which is a simple weather assistant. It can be installed as follows:

sudo apt-get install snips-platform-demo

At this point, you have a fully working setup, and you can start asking questions to your device, such as:

Hey Snips, what's the weather going to be tomorrow in Chicago?

Installing your assistant

If you haven't already, make sure to go through the following guide to create an assistant on the Snips Console:

Once your assistant is ready, download it to your computer. Copy it to your device, for instance using scp:

scp assistant.zip pi@raspberrypi.local:/home/pi

Establish a terminal connection to your device:

ssh pi@raspberrypi.local

Remove previously installed assistants and unzip the assistant to /usr/share/snips:

sudo rm -rf /usr/share/snips/assistant/
sudo mkdir /usr/share/snips
sudo unzip /home/pi/assistant.zip -d /usr/share/snips/

The assistant is installed, and we can restart the Snips Platform as follows:

sudo systemctl restart 'snips-*'

Monitoring components

Except for the sound hardware configuration, which mostly happens in /etc/asound.conf, the main configuration for the Snips Platform is located in the /etc/snips.toml file. For more details, check out the Platform Configuration article.

Systemctl

The daemons are running by a system user called _snips. If you need to stop, start and check the status of the different services, you can use systemctl. Here are a few examples.

sudo systemctl stop snips-dialogue
sudo systemctl start snips-dialogue
sudo systemctl status "snips-*

Snips Watch

Another handy tool is Snips Watch, which displays platform logs in real time. You can install it as follows:

sudo apt-get install snips-watch

Run it using the command

snips-watch

For more, or less logs, add the -v, -vv, -vvv flags, e.g.:

snips-watch -vvv

For more info, check out the complete Snips Watch guide:

System logs

All the components also send logs to /var/log/syslog, so you can monitor the live debug output by running:

sudo tail -f /var/log/syslog

Updating the platform

To update the platform (and the Raspbian operating system), simply run the following:

sudo apt-get update
sudo apt-get upgrade

Configuring individual components

If you want further information about how the platform works, please head to the on-device processing overview. In a nutshell, each component subscribes to events on the bus, and publishes events based on their results, that are taken over by other components, and so on. If you want to install specific components or replace one or several component, like the audio server or the Wake Word detector, you can install the packages separately. Here is the list of the packages of the platform:

  • mosquitto

  • snips-analytics

  • snips-asr

  • snips-audio-server

  • snips-dialogue

  • snips-hotword

  • snips-queries

  • snips-tts