Sonos "Say"

I tried to run a rule to send some anoucements to my sonos using this http://www.makeuseof.com/tag/send-voice-notifications-sonos-speakers/.
I have this rule:

then
var String EscadaAcesa = “The ligth is on"
sendHttpGetRequest(“http://localhost:5005/sala/say/"+EscadaAcesa.encode+(“UTF-8”)"/en-gb””)
end

This “almost” work. When the rule runs it sounds “Theplusligthplusispluson”. Every space is said as a “plus”.

I’m using OH2.0 and node 5.12

João

You’ve got a couple of extra " and you’re + is in the wrong place, which may be your problem

fixed here:
var String EscadaAcesa = "The ligth is on"
sendHttpGetRequest(“http://localhost:5005/sala/say/"+EscadaAcesa.encode(“UTF-8”)+"/en-gb”)

Though you should really use String::format()

so it would be:
var String EscadaAcesa = "The ligth is on"
sendHttpGetRequest(String::format(“http://localhost:5005/sala/say/%s/en-gb”, EscadaAcesa.encode(“UTF-8”)))

Also, I was also using the sonos-http-api for a long while but the Sonos binding in OH2 is pretty rock solid and fairly awesome. you could just replace this call with:

say("The light is on")

if you have ‘sala’ as the default audiosink or you could specify the Sonos to ‘say’ it on in the call as a second argument. my example is how I summon the children by playing a sound in their rooms and the tv room:

var summonText = "I summon thee both"

if(summonDinnersReady.state == ON)
{
	summonText = String::format("%s for dinner post haste", summonText)
}

say(summonText, "voicerss:enGB", "sonos:PLAY1:RINCON_5CAAFD2A673E01400")
say(summonText, "voicerss:enGB", "sonos:PLAY1:RINCON_5CAAFD4627D401400")
say(summonText, "voicerss:enGB", "sonos:PLAY1:RINCON_5CAAFD159A2A01400")
1 Like

Thank you for your help. I tryed:

rule "Lâmpada escada acesa"
when
Item LampadaEscada changed from OFF to ON
then
var String EscadaAcesa = “The ligth is on"
sendHttpGetRequest(String::format(“http://localhost:5005/sala/say/%s/en-gb”, EscadaAcesa.encode(“UTF-8”)))
if (tmJoao==OFF) then
sendNotification("xxxxxx@gmail.com”, “Lampada escada acesa”)
end
end

and get the exacly same result “Theplusligthplusispluson”.

I cannot try the Sonos binding today (bed time for the young girl of the house) and will be out of country for 4 days, so I will try latter this week.

João

I think you have to manually encode the spaces in the string to %20. The
+'s are the utf-8 encoding for spaces and that doesn’t work for an URL.

Why don’t you use the say command as suggested? It is the build in version with the binding and it doesn’t need any additional software installed. The website you used dates from before the time the say command was available.
I’m using this command as posted above and it works like a charm, even in my language.I have a textbox on my habpanel in which I type the text, and on the press of the button it is spoken without any “plus”.

Is Say still available in 2.0 binding?

/Mike

I’m on OH2 using Sonos binding 0.9.0.b4 (according bundle:list).

I’m on 2.1.0.SNAPSHOT and can not find anything around say so I am also using node-sonos-http-api for say.

/Mike

I’ve posted my rule in Sonos ... Audio Sink ... Say?
I’d be surprised if a new binding would skip that.
How did you setup the TTS service in Paper UI?

http://docs.openhab.org/configuration/multimedia.html

Thank you all for your help. I couldn’t try until now.

I’m now using the say command it kinda works
I can ear the message, but the volume is low and the quality is bad, so I can barely understand.
The good side: there is no “plus” on the message now.

This is my rule now:

rule "Lâmpada escada acesa"
when
Item LampadaEscada changed from OFF to ON
var Lacesa = "A lâmpada está acesa"
Lacesa = String::format(summonText)
say(Lacesa , “voicerss:ptPT”, “sonos:PLAY1:sala”)
end
end

The say command uses the NotificationVolume channel for it’s volume. It’s a good idea to set this before using say.

My Sonos is now saying all the annoucements. Its odd, as I didn’t change anyting (at least that in this part of the code). I had no time to play with OH latelly, but a couple of days ago I give it a try and enabled the rules and it worked. I really don’t know why it is working now and was not before.
I have a few simple rules, like this one:

rule "Lampada escada acesa"
when
Item LampadaEscada changed from OFF to ON
say(“A lâmpada da escada foi acesa” , “voicerss:ptPT”, “sonos:PLAY1:sala”)
end

The only problem is that I need to code “lâmpada” as “lâmpada” to have the rigth word on Sonos. Is there any solution for this?