Keep rhasspy running

Hi,

I would like to know what is the best way to have rhasspy always running, and restarting itself if crashing.

Here is my config:

Config:

  • Raspberry Pi4 Raspbian Buster Lite
  • ReSpeaker 2Mic with seed drivers
  • Virtual env installed
    Settings:
  • Listen for wake word on start-up
  • Custom wake word Snowboy
  • Use webrtcvad and listen for silence
  • Do speech recognition with pocketsphinx on this device
  • Do intent recognition with OpenFST on this device
  • Use pico-tts on this device : fr-FR
  • Use arecord directly (ALSA) / Default Device
  • Use aplay directly (ALSA) / Default Device

I use putty to connect via ssh on a windows 10 PC and simply run:
rhasspy/run-venv.sh --profile fr

But it never stay on, dunno if it’s when my PC goes sleep of whatever but after a few moment rhasspy doesn’t answer anymore.

I did tried to install rhasspy as a service, but this doesn’t work or I don’t know how to.
See: https://github.com/synesthesiam/rhasspy/issues/86

I’m not fond of docker but if it’s a way to got it reliable, I can give it a try.
Actually I have installed samba on the Pi, so I have a network drive on my Windows PC on the Pi, which is really nice to edit profile, intents, slots files and such. Is it still possible with docker ? Sorry, I dunno docker at all, played once with a container on my synolofy NAS and had some problems routing usb port etc.

Actually testing rhasspy, of course the goal is to have it 7/7 24/24 and robust to be able to ask him something anytime without taking care of it. So this is an important aspect :wink:

Docker is really handy for this purpose. See my answer here:

A health check could be just an attempt to connect to Rhasspy. If the connection fails, the Docker container is restarted automatically.

1 Like

Maybe it’s something related to your ssh connection. You can solve this by starting a screen session after logging in with ssh, and starting Rhasspy in this screen session. So when your ssh connection fails, Rhasspy keeps running in the detached screen session.

I didn’t know screen, seems nice indeed.

But from the start, I think rhasspy should run as a service, automatically started when the pi boot.

With snips, it always works, you can ssh and read service log, or stop it and run it in console to see the debug, etc.

Are you saying I should try docker install instead of venv ? And does the container will start itself at boot, so when something goes really wrong I can try sudo reboot or even just unplug and replug the pi ?

Yes, if Docker is configured to start at boot, it restarts all Docker containers that were running.

I’m not a big fan of systemd services. As you have already discovered in your issue about Rhasspy as a service, there are just too many things that can fail, with paths and so on. Running a Docker container instead of a systemd service is conceptually much simpler and hence more reliable.

Ok, I think I will test with a docker container.
Would you tell me how to configure it to start at boot ? Maybe add this in the doc

1 Like

If you’re following these installation instructions on a Raspberry Pi, this will configure Docker to start at boot by default: it enables the Docker engine’s systemd service.

Ok, so if I get it correctly, the official, most supported and reliable way of running rhasspy is actually docker with these instructions ?

How do you update it then, when there is some commits ?

I’m not the one who can declare things official with Rhasspy :wink: But if you ask me, I would say Docker is the most reliable way, yes.

About updating your Docker image, see:

This depends on the Docker image @synesthesiam publishes on Docker Hub being up-to-date. I don’t think he publishes a new version for every commit, but I see a new Docker image appearing very often. When we have CI/CD ready, a new docker image could be published for each commit.

2 Likes

Ok, installed docker, I have the ui so I guess all works, but:

  • all my previous settings are there, and seems my config folder didn’t changed: nice
  • still can’t put several intents files: integer division or modulo by zero
  • Still have timeout after first wakeword when starting

Seems rhasspy really don’t like me :woozy_face:

At least I can close ssh and still get rhasspy running, will see if it stays on all day long.

Maybe in the interface, a way to reboot the rpi could be nice.

Also, is there a way to access the container py file, alter them, and restart it ?

Also, seems docker container doesn’t have /api/intents :disappointed_relieved:

Containers are by design immutable. All changes you make while running them, except for external volumes you have mounted in them, will be lost after a restartyou recreate them.

I see, like a VM that would get back to snapshot :confused:

So I can’t debug anything or try new stuff on rhasspy files. But I could find solutions later for this, actually I can’t use rhasspy at all being venv or docker so I will wait for bugfixs :sleepy:

You can commit changes to a container and restart it but it might not be a good idea to change the files inside because they will reverted on the next pull…

No problem, I’m definitely not ready to help on dev part. Would better concentrate on get rhasspy running so I could really start to put in a production test environment. So many fix and features to add before that.

1 Like

How can I check when the docker container is updated ?

We really need a way to restart the pi from the console.
I sent some request on /api/text-to-intent but I guess too many, or too fast, it crashed rhasspy. The console was still accessible, but no wakeword, nothing responding.

BUT, actually, reboot the pi, the docker DOES NOT start automatically !

So yes, I can close / don’t need ssh, but I can’t unplug/replug the pi when it is not reachable and have rhasspy running without getting a PC, an ssh console, and run it.

We really need something on this, not production ready just on this aspect alone.

This is special. My docker setup on Raspbian Buster always starts automatically.
With the following commands I have installed everything:

Docker install:

curl -sSL https://get.docker.com | sh

Add User Pi to the Docker user group:

sudo usermod -a -G docker $USER

Restart!!!

Install Rhasspy Image in Docker:

docker run -e -p 12101:12101
–restart unless-stopped
-v ā€œ$HOME/.config/rhasspy/profiles:/profilesā€
–device /dev/snd:/dev/snd
synesthesiam/rhasspy-server:latest
–user-profiles /profiles
–profiles de

For me the Docker engine also starts automatically on Raspbian Buster and restarts all containers that have –restart unless-stopped . So @KiboOst this looks weird to me, what installation instructions did you follow? This isn’t a Rhasspy problem, it seems to be a problem with your Raspbian installation.

I’ve installed it exactly like you.
Get raspbian buster lite, etcher, ssh file, boot and then installed seed driver picotts then rhasspy docker like you.

Do a sudo reboot in ssh, rhasspy doesn’t start

We really need as easy as possible setup :wink:

What does docker ps show after a reboot?

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
42a21bcbd5a7 synesthesiam/rhasspy-server:latest ā€œ/run.sh --user-profā€¦ā€ 28 hours ago Up 2 hours 0.0.0.0:12101->121 01/tcp charming_maxwell

Seems to be running?

ah sorry, missed to reboot:

Just rebooted, and now it is up without doing anything !

Maybe that was due previous unresponding state, strange !

Will keep an eye on this :face_with_raised_eyebrow:

How can we know a new rhasspy docker container is available ? To know when doing an update

https://hub.docker.com/r/synesthesiam/rhasspy-server

2 Likes

Hi,

i installed Rhasspy and Home Assistant with a venv and i took inspiration from https://www.home-assistant.io/docs/autostart/systemd/ to start Rhasspy at boot

Disclaimer : it is not really safe to start it as pi user but i could not find a way to make it work with un unprivileged user :

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

and here is my service :

[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

Then to enable it like this :

sudo systemctl enable rhasspy@pi

3 Likes

I saw you use docker run -e

when the doc say

docker run -d

What is the difference ?

Also, to stop it, we should run:
docker stop rhasspy-server

but the running instance always have a names like 54dsts13ts, how can we start the container always with same human name (rhasspy-server) ?

I use -d indeed.
Regarding the name simply add --name rhasspy-server to the docker run command.

1 Like

Is there a way to pull the last commit of rhasspy and rhasspy-nlu into the container ? Or does I can only wait for a new version of the docker container ?

You can do what you want within the container (git clone, mv files, etc.)

Enter the container bash with:
docker run -it rhasspy-server bash

Then do whatever you want with the container files.

Once you exited the container bash, you can save the changes with:
docker commit rhasspy-server

Please note that pulling a new image version will overwrite your changes.

Nice !! Will try that, many thanks again

Ok, back to venv, with new service doc, but no way.

Have follow the doc, created service, but can’t train at all
[ERROR:526407] main: [Errno 13] Permission denied: ā€˜/home/pi/.config/rhasspy/profiles/fr/sentences.ini’

Also have lot of ā€œnetwork connection errorā€ and
wsproto.utilities.LocalProtocolError: Connection cannot be closed in state ConnectionState.CLOSED

And finally after updating from git:

Will shutdown everything and try a new fresh install I guess, but not before a few days.
Still have not been able to see what rhasspy can offer after so much trouble with venv and docker. Promising for sure, but getting it running fine is another story :disappointed_relieved:

Wow, now closing the ssh session with rhasspy running as service, and boom, no more rhasspy.

Unplugged, replugged (set all from the doc to get running at startup), still nothing.

Throwing all this :tired_face:

I’m using hassio and installed rhasspy as addon

Now issues so far… I can start/stop it in a single click or just by automation
The only thing I haven’t done yet is to monitor current state. But it’s not a problem I think

For me docker also autostart on raspberry pi boot but only when pi connected with laptop through ethernet, if pi start only with usb power without any lan interface rhasspy docker seems not working or not starting on boot …
can anyone guide in this …

Thanks in advance…