Respeaker 2 Hat - Buster - Rhasspy + HA as service install + picotts + snips wakeword

I installed Rhasspy last WE, i didn’t want to use docker because of potential problems with sound device so i installed everything thanks to venv. Here is how i did it.

Disclaimer : it is certainly not be the only or best but since it works for me, it might be useful to others.

Disclaimer 2 : i did not invent anything, you can find all these steps in the official documentation of each project but all in one place is not so bad :wink:

Requirements :

  • Raspberri Pi
  • Debian buster installed
  • Respeaker hat
  • speaker connected to the Respeaker Hat

Update you Pi

sudo apt update && sudo apt upgrade

Disable inboard audio to avoid conflicts

sudo nano /boot/config.txt

find this line and change its value to off

dtparam=audio=off

install seeds drivers

sudo apt install git
git clone https://github.com/respeaker/seeed-voicecard.git
cd seeed-voicecard
sudo ./install.sh
sudo reboot

test audio record/playback
beware : this command should produce an awful echo sound, this is what is expected

arecord -f cd -Dhw:0 | aplay -Dhw:0

install Home Assistant

sudo apt-get install python3 python3-dev python3-venv python3-pip libffi-dev libssl-dev
sudo useradd -rm homeassistant -G dialout,gpio,i2c
cd /srv
sudo mkdir homeassistant
sudo chown homeassistant:homeassistant homeassistant
sudo -u homeassistant -H -s
cd /srv/homeassistant
python3 -m venv .
source bin/activate

you should have switched to venv, now install Home Assistant

python3 -m pip install wheel
pip3 install homeassistant

exit the venv

exit

and now create the service file

sudo nano -w /etc/systemd/system/home-assistant@homeassistant.service

with this content

[Unit]
Description=Home Assistant
After=network-online.target

[Service]
Type=simple
User=%i
ExecStart=/srv/homeassistant/bin/hass -c "/home/%i/.homeassistant"

Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target

enable and start Home Assistant Service

sudo systemctl --system daemon-reload
sudo systemctl enable home-assistant@homeassistant
sudo systemctl start home-assistant@homeassistant

now Rhasspy

cd
git clone https://github.com/synesthesiam/rhasspy.git
cd rhasspy/
./download-dependencies.sh
./create-venv.sh

create rhasspy service

sudo nano -w /etc/systemd/system/rhasspy@pi.service

with this content

[Unit]
Description=Rhasspy
After=network-online.target

[Service]
Type=simple
ExecStart=/home/pi/rhasspy/run-venv.sh --profile fr
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target

enable and start the service

sudo systemctl --system daemon-reload
sudo systemctl enable rhasspy@pi
sudo systemctl start rhasspy@pi

[optional] install PicoTTS
there are missing packages on Buster so we need to install them manually

wget http://archive.raspberrypi.org/debian/pool/main/s/svox/libttspico-utils_1.0+git20130326-3+rpi1_armhf.deb
wget http://archive.raspberrypi.org/debian/pool/main/s/svox/libttspico0_1.0+git20130326-3+rpi1_armhf.deb

sudo apt install ./libttspico0_1.0+git20130326-3+rpi1_armhf.deb ./libttspico-utils_1.0+git20130326-3+rpi1_armhf.deb 

[optional] install Snips wakeword - we don’t need/want all Snips platform

sudo bash -c 'echo "deb https://raspbian.snips.ai/stretch stable main" > /etc/apt/sources.list.d/snips.list'
sudo apt-key adv --fetch-keys  https://raspbian.snips.ai/531DD1A7B702B14D.pub
sudo apt update
sudo apt install mosquitto mosquitto-clients snips-satellite snips-hotword-model-heysnipsv4

and now my config file
wake > system > hermes is for Snips wakeword only

{
    "handle": {
        "system": "hass"
    },
    "home_assistant": {
        "access_token": "xxxx",
        "url": "http://localhost:8123"
    },
    "microphone": {
        "arecord": {
            "device": "capture"
        },
        "system": "arecord"
    },
    "mqtt": {
        "enabled": true,
        "publish_intents": false
    },
    "sounds": {
        "recorded": "/home/pi/rhasspy/etc/wav/beep_lo.wav",
        "wake": "/home/pi/rhasspy/etc/wav/beep_hi.wav"
    },
    "text_to_speech": {
        "picotts": {
            "language": "fr-FR"
        },
        "system": "picotts"
    },
    "wake": {
        "system": "hermes"
    }
}

One more thing
Resppeaker 2 has a built-in button, why not using it to trigger voice recognition without Wakeword?
Needs Hermes wake system
install requirments

sudo pip3 install rpi.gpio paho-mqtt

create file

sudo nano button.py

with this content

import RPi.GPIO as GPIO
import time
import paho.mqtt.client as mqtt

BUTTON = 17

GPIO.setmode(GPIO.BCM)
GPIO.setup(BUTTON, GPIO.IN)

client = mqtt.Client("rhasspy")
client.connect("localhost")

while True:
    state = GPIO.input(BUTTON)
    if not state:
        # someone has pushed the button, publish to MQTT
        client.publish("hermes/hotword/default/detected",'{"siteId": "default"}')
        while not state:
            state = GPIO.input(BUTTON)
            time.sleep(0.1)  # Pause
    time.sleep(0.1)  # Pause

now create a service file as usual

sudo nano /etc/systemd/system/button@pi.service 
[Unit]
Description=Button
After=network-online.target

[Service]
Type=simple
ExecStart=/usr/bin/python3 /home/pi/button.py
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target

enable and restart the service

sudo systemctl --system daemon-reload
sudo systemctl enable button@pi
sudo systemctl start button@pi

Merry Christmas :gift_heart:

9 Likes

Awesome, thanks for the write-up! The wake button is a nice bonus :ok_hand:

Yes with snips and led control I use the button to disable wakeword. Help with lot of people to avoid false positive.
We really need a rhasspy implementation of led control. Maybe after having builtin slots like duration :grin:

En faite, tu utilise la détection de snips (wakeword) et rhasspy pour la gestion des intents ? C’est bien ça ?

Yes indeed, i use use the snips-satellite package for wakeword and MQTT in Rhasspy to detect it.
Why Snips? I already had a good custom wakeword and i don’t have time to switch to something else right know.

Thanks duch for the configuration, I’ll do the same! Because, I find the detection of WakeWord is very bad with snowbow and these little friends.

I have the same hardware setup but I am using docker, microphone and speakers work.
I am satisfied of my setup except for wake Word.
Actually I am using porcupine as wake word engine but I have to shout to make myself heard and It doesn’t work from 50 centimeters.

Probably the microphone Is not good but with “Hey snips” It worked from 1 Meter.
Have you suggestions?

Hi @adrianofoschi, welcome! I’ve heard of some users in this situation switching over to snowboy and increasing the “audio gain” and sensitivity. You may try adjusting porcupine’s sensitivity too (I’m not sure the library has an audio gain option yet).

Hi synesthesiam, congratulations for your work.
I will try snowboy and sensivity.
Anyway I suspected that the Respeaker 2 mic Array Is very limited…

I have in my plan to buy https://respeaker.io/usb_4_mic_array/ for make a professional voice assistant, what do you think about It?

1 Like

I have the Respeaker 4 mic array (real name is Respeaker mic array v2.0) and it is pretty good.

The AEC and beam forming claerly do the job and I can get the wakeword detected (the one from Snips though) from more than 5 meters away while playing music near the mic array.

Note that the Respeaker Mic Array v2 firmware limits the audio playback quality to 16Khz (their 48Khz firmware is pretty bad due to XMOS capacity limitations and the AEC is inexistant).

I’ve heard good things regarding the sensitivity of the Respeaker 2 mic hat but it does not provides AEC or any audio algorithms. For AEC you’ll have to implement it yourself using something like Pulseaudio.

If you plan to play music via your assistant, the Respeaker mic array v2 is a very good device.

If not, I think the 2 mic hat should be pretty good.

Hope this helps.

1 Like

have you the MicArray usb version? I’m confusing about the names :slight_smile:

I tried snowboy and I can definitively say that with respeaker 2 it’s much more precise than porcupine.
I suggest it with the same hardware.
Thanks you

I have the Respeaker Mic Array v2.0 (USB) and the Respeaker 4 mics Raspberry Hat.

Does Respeaker Mic Array v2.0 (USB) work out of the box on raspbian or does it need driver installation?
I bought one I will receive it in the next days :slight_smile:

No driver installation is needed. It works out of the box as both an ALSA input and output device.

Enjoy :blush:

1 Like

Fastjack did you modify webrtcvad default parameters for respeaker mic array v2.0?
Are you using a satellite configuration?

I did not modify the default Respeaker config.

Though I have not yet tested the full Rhasspy chain (mic->wakeword->asr->nlu->intent->tts->speaker).

I got good results with the snips software.

For now, I’m concentrating on the ASR and NLU part as this seems like the most complex stuff to get right.

Once I get satisfied with the ASR and NLU results I’ll move on the wakeword.

:blush:

ok thanks you :slight_smile:

Sorry to resurrect this thread, but I’m trying to get the same setup (snips-satellite (I like snips’ hotword detection) and rhasspy handling the rest (I dislike the rest of modern-day snips)).

Do you run the snips part on the same raspy as the rhasspy software? I’m using the ps3 eye mic and run into “arecord: main:828: audio open error: Device or resource busy” errors when I have snips-satellite running.

Any idea how to solve that?