Use external pulseaudio sink for output is not working


#1

Hi.

I have a working multiroom audio setup running on a raspberry pi.
My picroft (another raspberry pi) is running great using matrix voice as input device and 3,5mm cable with external speakers as output device.

What i want to do is, that mycroft uses my external pulseaudio sink as output which does not work.

I verified that the following command gives output on my multiroom audio setup correctly (running as user pi)

paplay --server=<ip> --device=<sinkName> --volume=35536 start_listening.wav

When i change the following line in /home/pi/mycroft-core/mycroft/configuration/mycroft.conf:

from

"play_wav_cmdline": "paplay %1 --stream-name=mycroft-voice",

to

"play_wav_cmdline": "paplay --server=<ip> --device=<sinkName> --volume=65536 %1 --stream-name=mycroft-voice",

or

"play_wav_cmdline": "paplay --server=<ip> --device=<sinkName> --volume=65536 %1",

The audio output (activation sound or tts output) stills comes out of the external speakers connected by 3,5mm cable.

What did i miss?


#2

As far as I understand Mycroft takes control over PulseAudio as soon as Mycroft-Audio services are started. This may be the reason why the test on the console works as desired but paplay issued from Mycroft does not.

Maybe you can try editing /etc/pulse/default.pa and change the default-sink?


#3

Thanks for your reply @Dominik.
I double checked what i did and the activation sound is send correctly through my multiroom setup.
To be sure i edited /etc/mycroft/mycroft.conf too (additional to /home/pi/mycroft/…/mycroft.conf)
But the tts output is still played through local 3,5mm speaker.

Maybe tts output is an mp3 stream and i should change this line
"play_mp3_cmdline": "mpg123 -a hw:0,0 %1",


#4

I googled on how to use mpg123 with pulseaudio. This topic seems pretty common,but i do not find the right syntax for the config line from above.

Can anybody help me on how to modify the line for pulseaudio inclusive host and sinkname.

Thank you.


#5

Have a look at my blog post about doing a similar thing. mpg123 does not allow much pulseaudio changes, so I used mplayer.

https://www.j1nx.nl/project-1/diy-home-personal-ai-assistant-installing-configuration-part-4/

(not 100% sure if everything is still up to date with current development, but think the pulseaudio section might give you enough pointers to keep going)


#6

Even if your link seems broken you got the right “keyword” for me - mplayer.
The following steps made mycroft use my existing remote pulseaudio sinks for tts.

  1. sudo apt-get install mplayer

  2. edit /etc/pulse/default.pa and adding the following line
    load-module module-tunnel-sink sink_name=<localSinkAlias> server=<pulseaudioServer> sink=<remoteSinkName>

  3. Restart pulseaudio
    pulseaudio -k
    pulseaudio --start

  4. Modify mycroft.conf and replace the following content
    "play_mp3_cmdline": "mpg123 %1",
    with
    "play_mp3_cmdline": "mplayer -ao pulse::<localSinkAlias> -volume 40 %1",

  5. /home/pi/mycroft-core/stop-mycroft.sh

  6. bash /home/pi/auto_run.sh

Maybe that’s helpful for anyone :slight_smile:

Thorsten


#7

Yeah, that looks about right / similar as what I wrote.:wink: