Text To Speech (TTS) With Sonos - Creating Dynamic Messages

PLease, help! Where is error in syntax? Can’t find :cry:


local TEMP_SID = "urn:upnp-org:serviceId:TemperatureSensor1"
local WUGTemp1 = luup.variable_get(TEMP_SID, "CurrentTemperature", 27)
local WUGTempMIN = luup.variable_get(TEMP_SID, "CurrentTemperature", 28)
local WUGTempMAX = luup.variable_get(TEMP_SID, "CurrentTemperature", 29)

if (WUGTemp1 > 0) then
	WUGTemp1 = "плюс " .. WUGTemp1
end
if (WUGTempMIN > 0) then
	WUGTempMIN = "плюс " .. WUGTempMIN
end
if (WUGTempMAX > 0) then
	WUGTempMAX = "плюс " .. WUGTempMAX
end

[quote=“allmoney.ws, post:41, topic:173177”]PLease, help! Where is error in syntax? Can’t find :cry:

[code]

local TEMP_SID = “urn:upnp-org:serviceId:TemperatureSensor1”
local WUGTemp1 = luup.variable_get(TEMP_SID, “CurrentTemperature”, 27)
local WUGTempMIN = luup.variable_get(TEMP_SID, “CurrentTemperature”, 28)
local WUGTempMAX = luup.variable_get(TEMP_SID, “CurrentTemperature”, 29)

if (WUGTemp1 > 0) then
WUGTemp1 = "плюс " … WUGTemp1
end
if (WUGTempMIN > 0) then
WUGTempMIN = "плюс " … WUGTempMIN
end
if (WUGTempMAX > 0) then
WUGTempMAX = "плюс " … WUGTempMAX
end
[/code][/quote]

Thanks for all answers!! )) Found a solution:
tonumber(WUGTemp1) > 0

Hello Lolodomo and anothers…

I would like to make my sonos speak something in portuguese, is it possible ?

luup.call_action(LS_SID, “Say”, {Text = string.format(“One or more motion sensores have reported motion.”)}, AV_DEV)

in the line above where can be inputed the language parameter ?

I read in some place: it=italian, sw= sweden, maybe po= is equal portuguese not ?

thanks !

[quote=“Piwtorak”]Hello Lolodomo and anothers…

I would like to make my sonos speak something in portuguese, is it possible ?

luup.call_action(LS_SID, “Say”, {Text = string.format(“One or more motion sensores have reported motion.”)}, AV_DEV)

in the line above where can be inputed the language parameter ?

I read in some place: it=italian, sw= sweden, maybe po= is equal portuguese not ?

thanks ![/quote]
Try pt see

ok brientim ,
but in that line, where goes this parameter ?

thanks !

[quote=“Piwtorak”]ok brientim ,
but in that line, where goes this parameter ?

thanks ![/quote]

Refer to wiki there is an example of insert language parameters: Sonos Wireless HiFi Music Systems

Running fine the talking clock.
I would like only remove zeroes of the hours and minutes <10 , sounds no good :
Zero one hours and zero five minutes to 01:05

I would like the system talks one hour and five minutes…

I think this be in luup sintax some function to supress zero if that is at left.

In clipper we use: alltrim(str((val (hour)))

Use a pattern:

http://www.lua.org/pil/20.2.html
http://www.lua.org/manual/5.1/manual.html#5.4.1

Just guessing but this may work - if it doesn’t read the above pages:

hour = hour:gsub(“^0”, “”)

Hi @piwtorak

If you get it working, please post the full set of code here, I’ll be interested to see how you did it.

Hello !!

I do not get working the talking hours with Zero in the front of the number when that is minor than 10…

my code now is:

[i]local AV_DEV = 98
local LS_SID = “urn:micasaverde-com:serviceId:Sonos1”
local time = os.date(‘%I: horas e %M minutos’)

luup.call_action(LS_SID, “Say”, {Text = string.format(“%s”, time),Language=“pt”,Volume=60}, AV_DEV)
[/i]

but I don’t know where to put the gsub instruction supplied for a-lurker.
but is running fine !!!

Try this.

[code]local AV_DEV = 98
local LS_SID = “urn:micasaverde-com:serviceId:Sonos1”

local timeTable = os.date(“*t”)
local hour = tostring(timeTable.hour)
local min = tostring(timeTable.min)

–local time = "The time is “…hour…” "…min – Language=“en”
–local time = "L’ora “…hour…” "…min – Language=“it”
local time = "O tempo “…hour…” "…min – Language=“pt”

luup.call_action(LS_SID, “Say”, {Text=time, Language=“pt”, Volume=60}, AV_DEV)

return true[/code]

Thank you very much a-lurker !
My system now speaks perfectly.

I can see the difference in code, where can I find a good material to luup language ?

Where can I find a good material to luup language ?

http://www.lua.org/docs.html

Hello

[quote=“parkerc, post:1, topic:173177”][code]url = require(“socket.url”)

local AV_DEV = 5
local LS_SID = “urn:micasaverde-com:serviceId:Sonos1”
local MN_SID = “urn:micasaverde-com:serviceId:MediaNavigation1”

local TEMP_SID = “urn:upnp-org:serviceId:TemperatureSensor1”
local benTemp = luup.variable_get(TEMP_SID,“CurrentTemperature”, 42)
local emmaTemp = luup.variable_get(TEMP_SID,“CurrentTemperature”, 48)
local lang = “en”
local speak = url.escape(string.format("Ben’s Room is currently at %s degrees, and emmers is at %s ", benTemp, emmaTemp))

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][/quote]

Is this still the easiest way to get Vera to dynamically speak the temperature to me?
I dont know luup code, but I cant see where in code the volume of the zone is selected?

Try this sintax in the line of say instruction.

luup.call_action(LS_SID, “Say”, {Text=time, Language=“pt”, Volume=60}, AV_DEV)

So have I got this right if I want my sonos in the bedroom to tell me the temperature outside?
I dont understand how I make a reference to the required sonos player.

url = require(“socket.url”)

local AV_DEV = 5
local LS_SID = “urn:micasaverde-com:serviceId:Sonos1”
local MN_SID = “urn:micasaverde-com:serviceId:MediaNavigation1”

local TEMP_SID = “urn:upnp-org:serviceId:TemperatureSensor1”
local uteTemp = luup.variable_get(TEMP_SID,“CurrentTemperature”, 232)
local lang = “en”
local speak = url.escape(string.format(?Outdoor temperature is currently at %s degrees", uteTemp))

luup.call_action(LS_SID, “Say”, {Text=time, Language=?e?n, Volume=25}, AV_DEV)
luup.call_action(MN_SID, “Play”, {},AV_DEV)

local AV_DEV = 5
The "5 " is the device id of the Sonos. This is found in the Advanced tab of your Sonos device that you want the TTS sent too.

Thank you.
I did some more research and found that if I put in this code it works.
So now my sonos tells me the outdoor temperature in the morning.
How cool is that!

url = require(“socket.url”)

local AV_DEV = 254
local LS_SID = “urn:micasaverde-com:serviceId:Sonos1”

local TEMP_SID = “urn:upnp-org:serviceId:TemperatureSensor1”
local OutTemp = luup.variable_get(TEMP_SID,“CurrentTemperature”, 232)

luup.call_action(LS_SID, “Say”, {Text = string.format(“The outdoor temperature is currently at %s degrees”, OutTemp)}, AV_DEV)

I have tried to evolve my dynamic message :slight_smile:
But my lack of luup skills is killing me.

I have tried to modifie the working code that I have to include Weather underground “condition”. But I get an error when I save the scene.
Can someone help me to see what is wrong with the code below?

[code]url = require(“socket.url”)

local AV_DEV = 253
local LS_SID = “urn:micasaverde-com:serviceId:Sonos1”

local currentTemp = luup.variable_get(“urn:upnp-org:serviceId:TemperatureSensor1”, “CurrentTemperature”, 232)
local currentCondition = luup.variable_get(“urn:upnp-micasaverde-com:serviceId:Weather1”, “Condition”, 115)

luup.call_action(LS_SID, “Say”, {Text = string.format(“The outdoor condtion is %s, and the temperature is currently at %s degrees”,currentCondition, OutTemp,Volume=23)}, AV_DEV)
[/code]

You are using undefined variable OutTemp rather than currentTemp

  • parenthesis look wrong in the call_action command.