rhasspy / piper

A fast, local neural text to speech system
https://rhasspy.github.io/piper-samples/
MIT License
4.38k stars 297 forks source link

Device or resource busy error #458

Closed the-arkhive closed 1 month ago

the-arkhive commented 1 month ago

Let me open with I realize this is not a fault of Piper, and instead my audio setup, but I have done a lot of searching, including in the issue tracker here, and none of the solutions I have found have worked. If I should ask this in a different place I am happy to, but I was not sure where else to start.

I am running arch linux, and I have pulseaudio, pipewire, wireplumber, and alsa installed. As far as I can tell I need the first three in order to get OBS working. I have a USB audio interface and speakers plugged into the line out of my mobo. I can easily swap between both outputs with pavucontrol, and all my system and application sounds seem to respond properly. Piper works just fine when outputting to a file, so know I have properly setup my model files and such.

When I attempt to run:

echo 'This sentence is spoken first. This sentence is synthesized while the first sentence is spoken.' | \
  ./piper --model en_GB-cori-high.onnx --output-raw | \
  aplay -D "default" -r 22050 -f S16_LE -t raw -

I get the error:

ALSA lib pcm_dmix.c:1000:(snd_pcm_dmix_open) unable to open slave
aplay: main:850: audio open error: No such file or directory
[2024-04-03 18:43:54.209] [piper] [info] Loaded voice in 0.378567086 second(s)
[2024-04-03 18:43:54.210] [piper] [info] Initialized piper

After digging around online for this error I eventually created an 'asound.conf' file in /etc with

defaults.pcm.card 3
defaults.ctl.card 3

as the contents, based on the output of cat /proc/asound/cards. Upon running the same Piper command the new error I get is:

ALSA lib pcm_dmix.c:1000:(snd_pcm_dmix_open) unable to open slave
aplay: main:850: audio open error: Device or resource busy
[2024-04-03 18:47:07.702] [piper] [info] Loaded voice in 0.385020763 second(s)
[2024-04-03 18:47:07.703] [piper] [info] Initialized piper

Which seems like a step in the right direction, but again, all my searching for this error has not yielded a clear fix.

I have read issue #375, and all that informed me of was adding the device option and setting it to "default". Ideally Piper would swap which audio device it outputs to as I swap between my interface and speakers, but I would settle for just outputting to the interface as I eventually plan to drive speakers off that.

Any assistance would be greatly appreciated.

the-arkhive commented 1 month ago

I am a bit of a buffoon. Literally moments after submitting this issue, I finally found the combo of search terms that actually got me to a solution. I was missing the pulseaudio-alsa package. So for anyone else that finds this later. Make sure you have that package installed, and you can remove the asound.conf file from /etc if you made one.

Solution found in this post on the Arch forum.

Sorry for the post, marking as closed.