Openhab 2 Squeezebox Text to speech?

What version of the LMS are you running?

You can do this, which plays on a specific sink at a volume of your choosing.

    // Play the sound on a specific sink at a specified volume level
    playSound("squeezebox:squeezeboxplayer:5919BEA2-764B-4590-BC70-D74DCC15491B:20cfbf221510", "doorbell.mp3", new PercentType(45))

Iā€™m using piCorePlayers with LMS installed on one of them and itā€™s version is 7.9.1.
I guess the problems start when playSound is used before the previous notification ends. How to make sure playSound is not used before the previous sound is still playing ?

While I havenā€™t tried this, you could funnel all your notifications through a single rule (maybe using one String item as the proxy for the say message and another String item as the proxy for the playSound mp3 file.

Then, by wrapping the rule logic with a reentrant lock, you could ensure that subsequent executions of the rule wait for the currently executing rule to complete.

This only might work if the say and playSound actions block (which I think is the case).

Note the LMS is a bit sensitive to the timing of playlist modifications, which is what the binding relies upon for notifications. Sending multiple notifications that run concurrently likely will cause the LMS to mess up the playlist.

1 Like

My goal is to have a DP for everything. :wink: This one describes what you are suggesting: Design Pattern: Gate Keeper.

If not then it gets complicated but the overall approach would still work. There would just need to be a way to tell how long it takes to say the text (maybe an algorithm that estimates the length based on number of characters would be close enough) or play the sound (perhaps a map file?)

1 Like

And you seem to be approaching that goal. :+1:

Yes, I think it does. Donā€™t know how I missed this DP. Thanks!

An algorithm based on the # of characters would work well for TTS, but it would be hard to estimate the length of an MP3. Iā€™m banking on say and playSound blocking. :wink:

I meant for the MAP part of my suggestion to handle that. Put each filename in a .map with the number of seconds for the file. Then

    val length = new Integer(transform("MAP", "mp3.map", filename))

Of course this assumes you know all the mp3s ahead of time.

I posted a question about this (TTS and add to playlist) a couple of days ago, also added a feature request about it. :slight_smile: