rhasspy
rhasspy copied to clipboard
rhasspy audio recording on a laptop
I am trying to get rhasspy running on my laptop, which uses PulseAudio on Pipewire, but I am having problems getting audio recording to work. I know that audio recording can be made to work as I have voice2json working using arecord -r 16000 -f S16_LE -c 1 as the audio source. This correctly routes through pulse.
I tried PyAudio, which only shows two sof-hda-dsp devices that probably correspond to the digital microphone in my laptop and the headphone jack. Neither appear to work when I test them, either with or without a headphone connected. The testing microphone pop up appears for about one second but then goes away whether I am talking or not. Neither of the devices show "working".
I tried arecord, which shows many devices, including pulse. But using pulse doesn't appear to work. The behaviour is as above. The default device appears to be the null device. Neither that nor the other devices I have tried work.
I think the problem with using arecord may be that rhasspy is running in docker as root and thus does not have access to my audio setup. I tried using --user 1316:1316 in the docker command but no web server is brought up.
So is there a way to get rhasspy to connect to the seated user's pulse?`
Alternatively, is there an easy way to use voice2json facilities from a within a Python GUI program?
@Kamilcuk
The solution is https://github.com/rhasspy/rhasspy/tree/master/examples/docker-compose-pulseaudio
There are some gotchas, though. Existing profiles have to be chowned to the user, recursively. You don't see your input devices in the devices list, not even pulse, so don't change the device away from "pulse".
What distro are you on, btw?
The tricky thing about Pipewire is that it's only started under your own user, as soon as you login to your X session (or Wayland session). Before that moment, it is running as gdm user (if you're using gdm) and that trick might not help if you're planning to use Rhasspy without logging to your system interactively.
I'm searching for a bulletproof solution myself, but the only option I found so far, is to configure ALSA dmix plugin for my audio card I want to use with Rhasspy, and re-route Pipewire to use that, so I could also use ALSA devices directly out of docker.
Something like this:
Various software on your host
(web browser, media players)
┌───────────────────────┐◄────┐
│ │ │
┌───┤ PipeWire/PulseAudio │◄──┐ │ ┌───┐ ┌───┐ ┌───┐
│ │ │ │ └─┤ │ │ │ │ │
┌───────────────┐ ┌───────────────┐ ┌────────────────────┐ │ └───────────────────────┘ │ └───┘ └─┬─┘ └─┬─┘
│ │ │ │ │ │◄─┘ ▲ │ │ │
│ Sound card ◄──┤ ALSA Device ◄──┤ ALSA dmix plugin │ ┌────────────────────┐ │ └────────────┘ │
│ │ │ │ │ │◄──┐ │ │ │ │
└───────────────┘ └───────────────┘ └────────────────────┘ └──┤ Rhasspy in Docker │ └────────────────────────┘
│ │
└────────────────────┘
Or to configure Pipewire to not even touch that card, if it's possible
I use Fedora and XFCE. As I'm using my main laptop I have to be able to use its mirophones for other things as well.
I finally managed to make it work through the Pipewire - https://stackoverflow.com/a/75775875/1321921
I finally managed to make it work through the Pipewire - https://stackoverflow.com/a/75775875/1321921
How did you install pipewire-alsa in the rhasspy docker image? It uses debian buster and there is no pipewire-alsa package
https://wiki.debian.org/PipeWire#Installation
Can you please share your Dockerfile or the exact commands?
@bcm0 buster might be too old and didn't have pipewire back then in repos. Try bookworm. All the commands I used are in the repo https://github.com/kha84/R3Docker It might be bit behind current state of Rhasspy3
I didn't use rhasspy docker image. I was building my own from scratch based on Ubuntu 22 LTS