Issue with bluetooth speaker pulseaudio. aplay cmd line works but rhasspy not say something with no error

Hi,

I used rhasspy with no problem until i decide to go with bluetooth speaker/mic.

I spend the day to get it works with no succes and i have no idea of the issue

I can do aplay without specify a device in command line and my speaker speak so the speaker is the default one.
I can prove it with aplay -L that return me that :

ostro@ostrobase:~$ aplay -L
default
    Playback/recording through the PulseAudio sound server
null
    Discard all samples (playback) or generate zero samples (capture)
jack
    JACK Audio Connection Kit
pulse
    PulseAudio Sound Server
sysdefault:CARD=Audio
    Intel HDMI/DP LPE Audio, Intel HDMI/DP LPE Audi
    Default Audio Device
hdmi:CARD=Audio,DEV=0
    Intel HDMI/DP LPE Audio, Intel HDMI/DP LPE Audi
    HDMI Audio Output
hdmi:CARD=Audio,DEV=1
    Intel HDMI/DP LPE Audio, Intel HDMI/DP LPE Audi
    HDMI Audio Output
hdmi:CARD=Audio,DEV=2
    Intel HDMI/DP LPE Audio, Intel HDMI/DP LPE Audi
    HDMI Audio Output
dmix:CARD=Audio,DEV=0
    Intel HDMI/DP LPE Audio, Intel HDMI/DP LPE Audi
    Direct sample mixing device
dmix:CARD=Audio,DEV=1
    Intel HDMI/DP LPE Audio, Intel HDMI/DP LPE Audi
    Direct sample mixing device
dmix:CARD=Audio,DEV=2
    Intel HDMI/DP LPE Audio, Intel HDMI/DP LPE Audi
    Direct sample mixing device
dsnoop:CARD=Audio,DEV=0
    Intel HDMI/DP LPE Audio, Intel HDMI/DP LPE Audi
    Direct sample snooping device
dsnoop:CARD=Audio,DEV=1
    Intel HDMI/DP LPE Audio, Intel HDMI/DP LPE Audi
    Direct sample snooping device
dsnoop:CARD=Audio,DEV=2
    Intel HDMI/DP LPE Audio, Intel HDMI/DP LPE Audi
    Direct sample snooping device
hw:CARD=Audio,DEV=0
    Intel HDMI/DP LPE Audio, Intel HDMI/DP LPE Audi
    Direct hardware device without any conversions
hw:CARD=Audio,DEV=1
    Intel HDMI/DP LPE Audio, Intel HDMI/DP LPE Audi
    Direct hardware device without any conversions
hw:CARD=Audio,DEV=2
    Intel HDMI/DP LPE Audio, Intel HDMI/DP LPE Audi
    Direct hardware device without any conversions
plughw:CARD=Audio,DEV=0
    Intel HDMI/DP LPE Audio, Intel HDMI/DP LPE Audi
    Hardware device with all software conversions
plughw:CARD=Audio,DEV=1
    Intel HDMI/DP LPE Audio, Intel HDMI/DP LPE Audi
    Hardware device with all software conversions
plughw:CARD=Audio,DEV=2
    Intel HDMI/DP LPE Audio, Intel HDMI/DP LPE Audi
    Hardware device with all software conversions
usbstream:CARD=Audio
    Intel HDMI/DP LPE Audio
    USB Stream Output
sysdefault:CARD=bytchtcx2072x
    bytcht-cx2072x,
    Default Audio Device
dmix:CARD=bytchtcx2072x,DEV=0
    bytcht-cx2072x,
    Direct sample mixing device
dmix:CARD=bytchtcx2072x,DEV=1
    bytcht-cx2072x,
    Direct sample mixing device
dsnoop:CARD=bytchtcx2072x,DEV=0
    bytcht-cx2072x,
    Direct sample snooping device
dsnoop:CARD=bytchtcx2072x,DEV=1
    bytcht-cx2072x,
    Direct sample snooping device
hw:CARD=bytchtcx2072x,DEV=0
    bytcht-cx2072x,
    Direct hardware device without any conversions
hw:CARD=bytchtcx2072x,DEV=1
    bytcht-cx2072x,
    Direct hardware device without any conversions
plughw:CARD=bytchtcx2072x,DEV=0
    bytcht-cx2072x,
    Hardware device with all software conversions
plughw:CARD=bytchtcx2072x,DEV=1
    bytcht-cx2072x,
    Hardware device with all software conversions
usbstream:CARD=bytchtcx2072x
    bytcht-cx2072x
    USB Stream Output

My /etc/asound.conf is the following :

pcm.pulse {
    type pulse
}

ctl.pulse {
    type pulse
}

pcm.default pulse
ctl.default pulse

And my profile for rhasspy is the following :

    "sounds": {
        "aplay": {
            "device": "default"
        },
        "system": "aplay"

I add default in device because if i do not rhasspy automaticaly remove:

"aplay": {
            "device": "default"
        },

And that do not work too, if i go with pulse instead of default in aplay setting in rhasspy i’ve got the following error :

AudioServerException: Command '['aplay', '-q', '-t', 'wav', '-D', 'pulse']' returned non-zero exit status 1.

And the log after i run the tts in the home page of the rhasspy UI is :

[DEBUG:2021-08-12 20:21:53,603] rhasspyserver_hermes: Publishing 131 bytes(s) to hermes/tts/say
[DEBUG:2021-08-12 20:21:53,603] rhasspyserver_hermes: -> TtsSay(text='coucou', site_id='default', lang=None, id='d0c2c8ac-b015-4692-a410-bef8fd1ffec7', session_id='', volume=1.0)
[DEBUG:2021-08-12 20:21:53,601] rhasspyserver_hermes: Subscribed to hermes/error/audioServer/play
[DEBUG:2021-08-12 20:21:53,601] rhasspyserver_hermes: Subscribed to hermes/audioServer/default/playBytes/#
[DEBUG:2021-08-12 20:21:53,600] rhasspyserver_hermes: Subscribed to hermes/error/tts
[DEBUG:2021-08-12 20:21:53,600] rhasspyserver_hermes: Subscribed to hermes/tts/sayFinished
[DEBUG:2021-08-12 20:21:53,599] rhasspyserver_hermes: TTS timeout will be 30 second(s)

Someone have an idea pls ?

Hi @Ostro
First question
Did you do the test process in the Audio Input section.
I found it necessary to clear the old setting before refresh and test.

Secondly are you running in the docker.
If so pulse is not running in the docker. Pulse audio is started on a user by user basis and is only started when you login. There are concerns about running it at boot so it is disabled glabaly by default.
These days your window manager will start it when you login.
So running headless or under the docker means there is no pulse server running.

If you want to run via pulse.
(The easiest way I have found so far.)
You will need to work out a way to start pulse in your environment (docker or shell).

Actually to be completely honest I have found using command and gstreamer in the deb version the most reliable. I didn’t want to muck around with it too much.

what works for me
in my profile.json

  "microphone": {
        "arecord": {
            "device": "default"
        },
        "command": {
            "record_arguments": "alsasrc ! audioconvert ! audioresample ! audio/x-raw, rate=16000, channels=1, format=S16LE ! filesink location=/dev/stdout",
            "record_program": "/usr/bin/gst-launch-1.0"
        },
        "system": "command"
    },

and

    "sounds": {
        "aplay": {
            "device": "default",
            "volume": "0.9"
        },
        "command": {
            "play_arguments": "/dev/stdin",
            "play_program": "/usr/bin/gst-play-1.0"
        },
        "error": "${RHASSPY_PROFILE_DIR}/Desolee.wav",
        "recorded": "${RHASSPY_PROFILE_DIR}/Oki.wav",
        "system": "command",
        "wake": "${RHASSPY_PROFILE_DIR}/Oui.wav"
    },

the extra bits are just for fun I left them there so you could see this is just a cut and paste.

Hi @greg_dickson ,

First of all, thanks for the interest.
To be honest, i didn’t try to speak to him (jarvis) because i can’t hear what he said :slight_smile:
I run on docker but since i post this topic, i try with a no docker install via the .deb for amd64 of the doc with the same result except for one thing. Now no matter what is my choice for the aplay device, i always have the famous AudioServerException: Command ‘[‘aplay’, ‘-q’, ‘-t’, ‘wav’]’ returned non-zero exit status 1.
I tried to remove pulseaudio but when i do that i have the same error in rhasspy and the aplay command did’nt work from the command line that give me this error

aplay: main:828: erreur à l'ouverture audio: Périphérique ou ressource occupé

For no french guys, that say ressource is busy

when i install pulseaudio the cmd line works again

So at this point i suggest the following things:
1 : pulseaudio does’nt care about the busy ressource
2 : rhasspy does care about the busy ressource that why I’ve got the “returned non-zero exit status 1” from rhasspy

At this point, 2 things blow my mind :
1 : What is this “AudioServerException: Command ‘[‘aplay’, ‘-q’, ‘-t’, ‘wav’]’ returned non-zero exit status 1” from rhasspy ?
2 : Since i switch to docker for a local install and rhasspy use aplay command, how it’s possible that the same aplay command works in command line and not in rhasspy?

As i wrote this, i think hermes is the issue but i know nothing about hermes :frowning:

I will give a try to that gstreamer

Again thx for the interest!

donc viola
j’ai eu le meme probleme

when you swap you have to remove the Device: value in the Audio recording section
Save the config
run Refresh
run Test
select the device in the dropdown that has Working * in it

pulse handles multiple devices alsa doesn’t without a loop back and a lots of dark magic.

rhasspy is trying to run aplay with asla not pulse as it’s not running.
the pulse server is not started in the docker
you could try running the pulse server at boot but then it runs as root and that is not advised.

if you start the rhasspy deb in your terminal under X you probably wont get this error in rhasspy.

I start it with a systemd file that is started at user level when I log in and everything is setup
I use the startup system of my window mangaer xfce4

That’s why I am running the 2.5.10 deb with gstreamer.

That config has not skipped a beat since I set it up. But I am using the systemd --user service I adapted

I got it working and left it at that.

Bonne chance

ok this might help I just found this.