@parkerc: do you know why + is used for space in the URL ?
That’s how URL escaping works. It’s not a Vera thing. Google it.
Hi Lolodomo, not being very technical I do recall looking into this a while back as I was curious. For example a Google TTS URL also works as http://translate.google.com/translate_tts?tl=en&q=kitchen%20lights%20off. With a ‘%20’ rather than a. ‘+’.
I think all this is due to URL encoding and RFCXXX format used (something like that)
Hope that helps…
The URL Encoding should happen only at the point of calling the Web Service.
The API’s layered above should allow blanks and any other special characters that might cause the HTTP request to have problems.
I use the the following code:
[code]----------------------------------------------------
local function to_hex(spec_char)
return string.format(“%%%2X”, spec_char:byte(1))
end
local function escape(in_string)
return string.gsub(in_string, “%W”, to_hex)
end
local EncodedString = escape(UnEncodedString)
[/code]
Hi
I’ve been reading this thread with great interest and have started to try some of the code that has been listed. I have a squeezebox and have tried the following code
[code]url = require(“socket.url”)
local AV_DEV = 23
local LS_SID = “urn:micasaverde-com:serviceId:SqueezeBoxPlayer1”
local MN_SID = “urn:micasaverde-com:serviceId:MediaNavigation1”
local TEMP_SID = “urn:upnp-org:serviceId:TemperatureSensor1”
local highTemp = luup.variable_get(TEMP_SID,“CurrentTemperature”, 9)
local currTemp = luup.variable_get(TEMP_SID,“CurrentTemperature”, 8)
local lang = “en”
local speak = url.escape(string.format(“Good morning Jon, The high today will be %s degrees Celsius. Currently it’s %s degrees”, highTemp, currTemp))
luup.call_action(LS_SID, “SetURIToPlay”, {URIToPlay = string.format(“x-rincon-mp3radio://translate.google.com/translate_tts?tl=%s&q=%s”, lang, speak)},AV_DEV)
luup.call_action(MN_SID, “Play”, {},AV_DEV)
[/code]
When i run the scene the squeezebox starts playing the last track that it was on!!! Do i have to have my player set on something specific ?
Cheers
m0jon
Hi @m0jon
The script you posted is suited for the Sonos plugin…
if you have a squeezebox, have a look at my earlier post on the thread (http://forum.micasaverde.com/index.php/topic,11269.msg81186.html#msg81186) as there is a section on the Wiki SqueezeBox TTS.
Hi
Thanks for the link. I eventually end up here
http://forum.micasaverde.com/index.php?topic=6952.0
and with a little help from a friend managed to get google TTS working through my squeeze box. I posted instructions at the link above.
Cheers
m0jon