Author Topic: Text To Speech (TTS) With Sonos - Creating Dynamic Messages  (Read 83380 times)

Offline allmoney.ws

  • Full Member
  • ***
  • Posts: 105
  • Karma: +0/-0
  • Vera 3
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #30 on: January 31, 2013, 08:04:10 am »
You can have it get, return and say multiple variable as long as they are available.
You just need to declare where there are coming from... Once again, I will say with the precedence that has been displayed in previous posts.

E.g.
local WUGTempCurrent = luup.variable_get(TEMP_SID, "CurrentTemperature", 288)
local WUGTempHigh= luup.variable_get(TEMP_SID, "CurrentTemperature", 289)

So, in the example below
377 is the Sonos and the remaining are other devices that have a Variable called CurrentTemperature



Code: [Select]
url = require("socket.url")

local AV_DEV = 377
local LS_SID = "urn:micasaverde-com:serviceId:Sonos1"

local TEMP_SID = "urn:upnp-org:serviceId:TemperatureSensor1"
local RoomTemp1 = luup.variable_get(TEMP_SID,"CurrentTemperature", 389)
local RoomTemp2 = luup.variable_get(TEMP_SID,"CurrentTemperature", 36)
local RoomTemp3 = luup.variable_get(TEMP_SID,"CurrentTemperature", 381)
local WUGTempCurrent = luup.variable_get(TEMP_SID, "CurrentTemperature", 288)
local WUGTempHigh= luup.variable_get(TEMP_SID, "CurrentTemperature", 289)

luup.call_action(LS_SID, "Say", {Text = string.format("Bedroom1 is currently %s degrees  Room2 is currently at %s degrees, Room3 is currently %s degrees the outside is currently %s degrees" and the maximum excepted today is %s degrees, RoomTemp1,RoomTemp2,RoomTemp3,WUGTempCurrent,WUGTempHigh )}, AV_DEV)

Question was about other thing :)
Why TTS not read 2nd line luup.call_action, without variables too. One more example:

luup.call_action(LS_SID, "Say", {Text = string.format("The current temperature outside is %s degrees", WUGTemp1 )}, AV_DEV) -- SAID
luup.call_action(LS_SID, "Say", {Text = string.format("Thanks you")}, AV_DEV) -- DIDN'T SAY

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #31 on: January 31, 2013, 11:39:24 am »
Because the plugin is not able to say several things at the same time

Offline Brientim

  • Beta Testers
  • Sr. Hero Member
  • *****
  • Posts: 2497
  • Karma: +77/-7
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #32 on: January 31, 2013, 02:08:01 pm »
Sorry, I missed answering your question. As lolodomo stated, and that is why the several things are included in the same string... In the example, there is actually four statements and uses the four variables.

So, including your two statements into the single string would appears like.
luup.call_action(LS_SID, "Say", {Text = string.format("The current temperature outside is %s degrees,        Thankyou", WUGTemp1 )}, AV_DEV)

So, if WUGTemp1 = 68 the response would be
"The current temperature outside is 68 degrees,        Thankyou"

Offline parkerc

  • Sr. Hero Member
  • ******
  • Posts: 2463
  • Karma: +35/-48
  • Life Moves Pretty Fast....
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #33 on: February 03, 2013, 06:53:00 am »
Another TTS template for people to look at and hopefully improve for me and others.

The intent here is to do a occupancy check of the house and then report back if the house is presumed to be empty of if someone is maybe still there.

Occupancy Check

Code: [Select]
local MO_DEV1 = 119
local MO_DEV2 = 124
local MO_DEV3 = 135
local SEC_SERV = "urn:micasaverde-com:serviceId:SecuritySensor11"

local AV_DEV = 5
local LS_SID = "urn:micasaverde-com:serviceId:Sonos1"


local livingroommotion = luup.variable_get(SEC_SERV, "Tripped",MO_DEV2)
local hallwaymotion = luup.variable_get(SEC_SERV, "Tripped",MO_DEV1)
local kitchenmotion = luup.variable_get(SEC_SERV, "Tripped",MO_DEV3)

if ((livingroommotion == "0") and (hallwaymotion == "0") and (kitchenmotion == "0")) then
luup.log("All motion sensor report no motion seen")
luup.call_action(LS_SID, "Say", {Text = string.format("All motion sensores report that no motion is being seen.")}, AV_DEV)
else
luup.log("One or more motion sensors have reported motion")
luup.call_action(LS_SID, "Say", {Text = string.format("One or more motion sensores have reported motion.")}, AV_DEV)
end

If anyone can work out how to extract which sensor is still reporting motion out of a list of devices, it would be a nice touch for Sonos to say e.g. "Motion Is Still Being Reported in the Living Room"

Offline big517

  • Hero Member
  • *****
  • Posts: 576
  • Karma: +1/-4
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #34 on: February 09, 2013, 05:44:57 am »
I believe this is available in RTS Vera Alerts Plugin, and now you can send text directly from that Plugin to the Sonos Plugin his formatting may be better documented to create this dynamic string, and it may be very easy to push it to the sonos (or maybe not) I dont remember but it seemed to work well... I'm using THIS code to send the weather information via TTS to Vera Alerts that plays through my Sonos

Code: [Select]
local currentTemp = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1", "CurrentTemperature", 333)
local lowTemp = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1", "CurrentTemperature", 334)
local highTemp = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1", "CurrentTemperature", 335)
local currentCondition = luup.variable_get("urn:upnp-micasaverde-com:serviceId:Weather1", "Condition", 332)
local currentWind = luup.variable_get("urn:upnp-micasaverde-com:serviceId:Weather1", "WindCondition", 332)

local speakMessage = "{tone:1} Good Morning.  Current conditions are " .. currentCondition .. ".  The temperature is " .. currentTemp .. " degrees with a high today of " .. highTemp .. " and a low of " .. lowTemp

luup.call_action("urn:richardgreen:serviceId:VeraAlert1", "SendAlert",
                  {Message = speakMessage, Recipients = ""}, 397)


This was put together by Signal16 by the way.

So the last line there of luup.call_action would probably be where we would point the Vera Alerts plugin to deliver this message as "SAY" to the Sonos we choose.
Again, i'm not sure how to do that, but RTS would probably be able to advise fairly quickly.


Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #35 on: February 10, 2013, 02:58:13 am »
You call the SendAlert action of the Vera Alerts plugin that will call the Say action of the Sonos plugin (forward) if the Vera Alerts is correctly setup. So it is just an indirect call to the Say action. That's mainly interesting if you want to use several kinds of notification at the same time.

Offline big517

  • Hero Member
  • *****
  • Posts: 576
  • Karma: +1/-4
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #36 on: February 10, 2013, 05:38:01 am »
You call the SendAlert action of the Vera Alerts plugin that will call the Say action of the Sonos plugin (forward) if the Vera Alerts is correctly setup. So it is just an indirect call to the Say action. That's mainly interesting if you want to use several kinds of notification at the same time.
Using the code I posted above, can you modify that to send to Sonos plugin?
Thank you.

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #37 on: February 14, 2013, 01:47:34 pm »
You have to setup how to forward to the Sonos plugin in a tab of the Vera Alerts device. It is explained in the wiki of Vera Alerts. The luup code you posted is, I suppose, correct.

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #38 on: February 24, 2013, 05:13:26 am »
Because the plugin is not able to say several things at the same time

Creating a queue for TTS is in my TODO list.



To come back to the subject of this topic, I would like Vera/Sonos telling me when e-mails arrive, not all time but for example when I come back to home. Any idea ?

Offline parkerc

  • Sr. Hero Member
  • ******
  • Posts: 2463
  • Karma: +35/-48
  • Life Moves Pretty Fast....
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #39 on: February 24, 2013, 05:24:46 am »
I would like Vera/Sonos telling me when e-mails arrive, not all time but for example when I come back to home. Any idea ?

To join the two - see here - as i want this too. http://forum.micasaverde.com/index.php/topic,13463.msg103821.html#msg103821

Offline allmoney.ws

  • Full Member
  • ***
  • Posts: 105
  • Karma: +0/-0
  • Vera 3
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #40 on: April 18, 2013, 11:37:04 am »
PLease, help! Where is error in syntax? Can't find  :'(

Code: [Select]

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

Offline allmoney.ws

  • Full Member
  • ***
  • Posts: 105
  • Karma: +0/-0
  • Vera 3
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #41 on: April 21, 2013, 06:18:22 am »
PLease, help! Where is error in syntax? Can't find  :'(

Code: [Select]

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

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

Offline Piwtorak

  • Hero Member
  • *****
  • Posts: 988
  • Karma: +4/-0
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #42 on: May 03, 2013, 04:41:08 pm »
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 !
Vera3 (1), Airport Extreme (2), Apple TV (3), Sqblaster (1), GE Switch (3), GE Dimmer (1), Leviton VRCSZ2 (2), GE 45601 (1), Intermatic HA03 (2), GE Zwave Outlet (1), Remote Control Curtain (1) and growing.

Offline Brientim

  • Beta Testers
  • Sr. Hero Member
  • *****
  • Posts: 2497
  • Karma: +77/-7
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #43 on: May 03, 2013, 05:10:52 pm »

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 !
Try pt see


https://developers.google.com/adwords/api/docs/appendix/languagecodes

Offline Piwtorak

  • Hero Member
  • *****
  • Posts: 988
  • Karma: +4/-0
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #44 on: May 03, 2013, 05:47:17 pm »
ok brientim ,
but in that line, where goes this parameter ?

thanks !
Vera3 (1), Airport Extreme (2), Apple TV (3), Sqblaster (1), GE Switch (3), GE Dimmer (1), Leviton VRCSZ2 (2), GE 45601 (1), Intermatic HA03 (2), GE Zwave Outlet (1), Remote Control Curtain (1) and growing.