rhasspy / wyoming-satellite

Remote voice satellite using Wyoming protocol
MIT License
694 stars 104 forks source link

Run wyoming satellite as user, not as root? #57

Open seppeel opened 10 months ago

seppeel commented 10 months ago

Hey,

in my opinion it is better to run the satellite (and wakeword, led-service) as user, not as root.

The reason:

i configured all my services as user with systemctl --user --full --force <service-name> Im running

satellite and snapcast are using pulseaudio.

The only thing i needed to do is sudo loginctl enable-linger <username> to prevent systemctl from quitting all services when the user session ends (like ssh disconnect)

What do you think? Is it better to run as root?

I would open a PR for adding documentation to configure the service as user.

I took a look at the new install script @synesthesiam recently added. It looks like its creating and controlling services which are running as root. Is it worth to add an option to create (and control) the services as user?

What do you think?

lightsabata commented 10 months ago

I agree with you, since i use other audio based programs such as shairport-sync and MPD which they can go head to head to take ownership of the soundcard in root. On my side i create a user service template in /etc/systemd/user/wyoming-satellite.service:

[Unit]
Description=Wyoming Satellite
Wants=network-online.target
After=network-online.target wyoming-porcupine3.service mpd.service shairport-sync.service

[Service]
Type=simple
ExecStart=/home/USER/wyoming-satellite/script/run   \
    --vad   \
    --name "Salon"  \
    --uri "tcp://0.0.0.0:10700" \
    --mic-command "arecord -D micro_rhasspy -r 16000 -c 1 -f S16_LE -t raw" \
    --snd-command "aplay -D sysdefault -r 22050 -c 1 -f S16_LE -t raw"  \
    --wake-uri "tcp://127.0.0.1:10400"  \
    --wake-word "alfred"    \
    --awake-wav "sounds/wake.wav"
WorkingDirectory=/home/USER/wyoming-satellite

Restart=always
RestartSec=1

SyslogIdentifier=wyoming-satellite

[Install]
WantedBy=default.target

then enable with:

$ systemctl --user enable wyoming-satellite

then enable linger to allow service to start after boot even when the user is not login

$ sudo loginctl enable-linger USER
NonaSuomy commented 9 months ago

@lightsabata are you able to resume MPD music after notifications if so how do you accomplish this? Any way to lower MPD music level then play prompt then resume ie play both at the same time?

lightsabata commented 9 months ago

I am not using MPD to stream music, i use it for some TTS. I suggest you to use shareport-sync or squeezebox to recieve audio an music assistant for send audio (if it can fit to your configuration) with that i can control my speaker as a regular one. I hope it can help