Audio playback with openHAB (and Snapcast)

Hello again,

I was curious about snapcast, and I read some documentation about it.
This morning I was in a hurry and write my comment rather shortly. I can now take some more time to add additional relevant information :sweat_smile:

So, the first part (pico tts) is addressed by my previous post. If you want better sound quality you can use the mimic tts as mdar said. But it needs a mimic server on the network (you can ask me for help in the community discussion, as I’m the binding author)

So, for the second part (outputting sound from openHAB).
You are trying to redirect output of a TTS service to another sound system. This is exactly the job of the openHAB “audiosink”. On the documentation, you can see the two included audiosink that you already know (javasink, which is the default alsa soundcard, and webplayer), and a mention “Additionally, certain bindings register their supported devices as audio sinks, e.g. Sonos speakers.”
So you have to find the right binding which provide an audiosink that you can use for playing your TTS to.
And then you could choose it instead of the javasound or webplayer audiosink, and send your TTS to it without any additional configuration.

  • the mpd binding, but it doesn’t provide an audiosink

  • the snapcast binding (not official) more or less maintained, but it doesn’t seem to register an audiosink in openHAB. Maybe you can ask on the community topic if someone can do it ? I developed two audiosinks for two different bindings, and by looking at the snapcast documentation it should be OK (by the TCP or the pipe file interface maybe ?)

  • if you are willing to drop MPD, you can use the squeezebox binding with another audio playing software : may I suggest “Logitech Media Center” if you don’t know it ? It is a multiroom software, you can think of it as a mpd + snapcast, as it already includes the synchronization mechanism. You install a software on every client (namely squeezelite), and it connects to the Logitech Media Center to play your library (even online library like Spotify). It needs a little bit more configuration than MPD, but it is IMHO more flexible.
    And the squeezebox binding, available for openHAB, register an audiosink for every player found in the Logitech Media Server. So no additional configuration to play your TTS.

  • The pulseaudio binding allows openHAB to connect to and control a pulseaudio server on the network (or locally). You make a bridge thing for a pulseaudio server. And inside the bridge you can create one or several “audiosink” thing targeting a sound output available on this pulseaudio server (audio jack, hdmi, optical, or even a purely software pulseaudio sink loaded by a plugin).
    Each audiosink thing is an openHAB audiosink, and you can directly play your TTS sound to it.
    So, with this pulseaudio binding, you have to choose between two options :

Option 1 for the pulseaudio binding, without snapcast (openhab → pulseaudio binding → pulseaudio sink on each client → speaker) - Configure your pulseaudio servers on each computer you want to send sound to by loading the proper module-cli-protocol-tcp module (see pulseaudio binding documentation). Then make in openHAB a bridge thing for every computers you want to send sound to. Make an audiosink inside each bridge for the desired output. Activate the audiosink for them, and Voilà.

Option 2 for the pulseaudio binding, with snapcast (openHAB → pulseaudio binding → pulseaudio pipe sink → snapcast → each snapcast client → speaker) Configure the pulseaudio server on the computer with the snapcast server. Also load the proper module-cli-protocol-tcp module as the pulseaudio binding documentation. Create a bridge thing on openHAB to connect to the pulseaudio server on the snapcast machine. Create a thing inside the bridge thing to connect to the pulseaudio virtual sink (the one created by the module-pipe-sink). Activate the openhab audiosink functionality for this think. And Voilà. (I’m not 100% sure that this “option 2” works because I didn’t test it, but theorically it should work)

2 Likes