Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipewire shenanigans #253

Open
FamousL opened this issue Dec 24, 2024 · 7 comments
Open

Pipewire shenanigans #253

FamousL opened this issue Dec 24, 2024 · 7 comments

Comments

@FamousL
Copy link

FamousL commented Dec 24, 2024

Not sure if this is considered out of scope, but I didn't want a dedicated device sitting on my desktop, so I got it running on my desktop alongside Pipewire.

Current spec of my machine:
Fedora 41
Python 3.11 (using venv, for both satellite and openwakeword)

I don't have it fully stable, but this "works" so far, I am able to summon, and issue commands (that are executed). I also have not tested a reboot yet. Responses from ollama llm don't seem to make it back to me yet.

To accomplish this I edited the service file for the satellite (and openwakeword) in usermode "systemctl edit --user --force --full wyoming-satellite" and checked out the satellite and openwake word to a folder named assistant in my home directory (more organization than anything on my part).

I replaced arecord and aplay as I was not aware of how to get them to play nice and let other applications use the speakers/microphone (which may be possible, I just didn't see how when I did this). Routing it all through pipewire was the solution I ended up using, below is the way I ended up setting it up.

[Unit]
Description=Wyoming Satellite
Wants=network-online.target
Requires=wyoming-openwakeword.service

[Service]
Type=simple
ExecStart=/home/(user)/assistant/wyoming-satellite/.venv/bin/python3.11 /home/(user)/assistant/wyoming-satellite/script/run --name 'Desktop-Satellite' --uri 'tcp://0.0.0.0:10700' --mic-command 'pw-record --rate 16000 --channels 1 - ' --snd-command 'pw-play --rate 22050 --channels 1 -' --wake-uri 'tcp://127.0.0.1:10400' --wake-word-name 'hey_jarvis' --awake-wav /home/(user)/assistant/now_listening.wav --done-wav /home/(user)/assistant/processing.wav
WorkingDirectory=/home/(user)/assistant/wyoming-satellite
Restart=always
RestartSec=1

[Install]
WantedBy=default.target

@FamousL
Copy link
Author

FamousL commented Jan 2, 2025

update: It has survived multiple reboots, and llm responses do appear to be working

@Vaskyy
Copy link

Vaskyy commented Jan 4, 2025

I also cannot get this to work unfortunately.

I stumbled upon this problem with my Pi 5 that im using as a desktop.

Its kinda impossible to have systemd run this as it seems for me.
Doesnt matter which command im using (arecord, pw-record, parecord), it seems as its a permission issue.

Can u specify exactly what u mean with usermode? what parts of the installation did u not do as sudo user?

@FamousL
Copy link
Author

FamousL commented Jan 4, 2025

Apologies, I was writing how how I did get it to work,

First, yes, running the service in systemd as a system-wide service will fail if you are trying to run this on a desktop.
Second, the command I posted, "systemctl edit --user --force --full wyoming-satellite" pay special attention to the --user portion, that's what allows systemd to run the command as you(and does not require sudo).

This entire setup must be done without sudo, as you are setting this up to run as your user.

@FamousL
Copy link
Author

FamousL commented Jan 4, 2025

Re-reading my initial post, I can see where I was unclear, I will attempt to give an easier to follow guide here:
This assumes a few things are present

  1. desktop enviornment (I do not believe there is a difference between which ones, but this can be revisited later)
  2. python 3.11 is available (installed, or in a virtual envirnment)
  3. pipewire and its utilities pw-record and pw-play are installed
  4. pipewire is the audio server you are using.
  5. Wyoming satellite and openwakeword have been installed using the provided setup commands, and will run in your terminal of choice.

The exact commands I used are as follows:

  1. systemctl edit --user --force --full wyoming-satellite

This command is not run with sudo, as systemd does have user-level services that can be run. This is creating one such service.
I created this service with the above (edited) service description.

  1. systemctl edit --user --force --full wyoming-openwakeword

Also run without sudo, same reason as the satellite
Contents of mine are basically just the normal openwake word, I can post that later if needed.

  1. systemctl enable --now --user wyoming-openwakeword

This is where we enable the service for your user, and start it immediately. Starting with openwakeword as satellite will kick out an error if it cannot connect.

  1. systemctl enable --now --user wyoming-satellite

This should start immediately and without issue, provided the prereques are met.

@Vaskyy
Copy link

Vaskyy commented Jan 4, 2025

That did it! OMG.. i've searched for it for such a long time!
Pi5 with HA and fully local voice assistant while still working desktop audio AND also being able to stream to it to shairport-sync! God bless u kind soul!

@Vaskyy
Copy link

Vaskyy commented Jan 14, 2025

So after fiddeling more around with it. It still kinda doesnt work
After a reboot i have to restart the service manually

Also an similar problem which i thought to solve with ur "--user" systemd service: shairport-sync
Same stuff: i wanna make it an SYSTEMWIDE user executed service so it can talk to pipewire

when its a system service it cannot talk to pipewire

earlier i solved this issue with rc-local calling "sudo systemctl restart **.service"
but i dont think thats the real way to go

@FamousL
Copy link
Author

FamousL commented Jan 14, 2025

if it isn't coming back up after a reboot, two things to check:
First) is it enabled, (the enable lines)
Second) is it spitting out an error?

So far this is surviving reboots on my end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants