We have moved at community.getvera.com

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

Offline haavard

  • Full Member
  • ***
  • Posts: 162
  • Karma: +0/-0
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #60 on: November 27, 2013, 04:01:37 am »
Thank you for looking at this :)

I had a copy fault in the currentTemp variable.
But I can not see what is wrong with the parenthesis?
I am on extremely thin ice when it comes to luup :(

 

Offline haavard

  • Full Member
  • ***
  • Posts: 162
  • Karma: +0/-0
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #61 on: November 27, 2013, 04:18:39 am »
I managed to save this code.
I will see if it works when I get home.

Code: [Select]
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, currentTemp,Volume=23}, AV_DEV)

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #62 on: November 29, 2013, 07:00:24 am »
Code: [Select]
luup.call_action(LS_SID, "Say", {Text = string.format("The outdoor condtion is %s, and the temperature is currently at %s degrees",currentCondition, currentTemp) ,Volume=23}, AV_DEV)
Should probably be better like that ?

Offline haavard

  • Full Member
  • ***
  • Posts: 162
  • Karma: +0/-0
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #63 on: November 29, 2013, 02:50:32 pm »
So I did a new try to get this to work. I am sure that it is correct to change the parenthesis. But the luup still doesn't  work.
So I tried to modify it again and I think I am closer now, but I still get an error when I try the luup. The code that I have now is as follows:

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

local AV_DEV = 253
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)
local Cond_SID = "urn:upnp-org:serviceId:Weather1"
local OutCond = luup.variable_get(Cond_SID,"Condition", 115)

luup.call_action(LS_SID, "Say", {Text = string.format("The outdoor condtion is %s, and the temperature is currently at %s degrees",OutCond, OutTemp) ,Volume=23}, AV_DEV)

The thing is that the temperature part is working. This whole project is about implementing the current condition from the weather underground app.
So I think something must be wrong with line 3 or 4. I created line 3 and 4 based on line 1 and 2, and according to similar codes found here on the forum.
Can you see something in the luup that doesn't make sense?

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #64 on: November 30, 2013, 05:37:49 am »
Try this:
Code: [Select]
local OutCond = luup.variable_get(Cond_SID,"Condition", 115) or "bad"Then if TTS is working, it would mean that you probably don't use the right variable name or service id.

Offline p3tter

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #65 on: December 01, 2013, 06:12:18 pm »
hello i had the same problem with sonos tts and the weather plugin. i could post my code, its working for me to say the condition.
Code: [Select]
local AV_DEV = 28
local MN_SID = "urn:micasaverde-com:serviceId:MediaNavigation1"
local device = 3
local LS_SID = "urn:micasaverde-com:serviceId:Sonos1"
local TEMP_SID = "urn:upnp-org:serviceId:TemperatureSensor1"
local WUGTemp1 = luup.variable_get(TEMP_SID, "CurrentTemperature", 21)
local time = os.date('%M minutes past %I:')
local t = luup.variable_get("urn:upnp-micasaverde-com:serviceId:Weather1", "ConditionGroup", 20)

luup.call_action("urn:micasaverde-com:serviceId:Sonos1", "PlayURI", {URIToPlay="Q:", Volume=20, Duration=20}, AV_DEV)



m = 60 --60 sek
luup.call_delay( 'switch_ON', m)
function switch_ON()
luup.call_action(LS_SID, "Say", {Text = string.format("Good morning. The time is currently %s. Current temperature outside is %s and the Condition outside is %s", time, WUGTemp1, t), Volume=40}, AV_DEV)
end

luup.call_delay( 'switch_off', 900) -- Call the switch off function after a delay of 2 seconds
function switch_off()
   luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue="0" },device)
   luup.call_action("urn:micasaverde-com:serviceId:Sonos1", "PlayURI", {URIToPlay="Q:", Volume=0 }, AV_DEV)
end

this play music for one minute and then it speaks the sentence: Good morning with the time, temperature and the condition outside, and then it goes back to play music for 900 sec.
hope this helps

Offline haavard

  • Full Member
  • ***
  • Posts: 162
  • Karma: +0/-0
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #66 on: December 02, 2013, 01:32:34 am »
I did some tweaking on the code, and finally got it to work.
I am not 100% sure what did the trick. But the faultfinding help lolodomo got me on the right track.
The code that works for me is as follows:

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

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

local OutTemp = 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 condition is %s, and the temperature is currently at %s degrees", currentCondition, OutTemp) ,Volume=23}, AV_DEV)




Thanks for your help!

Offline a-lurker

  • Hero Member
  • *****
  • Posts: 872
  • Karma: +66/-8
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #67 on: December 02, 2013, 03:06:22 am »
And you can remove this, as it's not referenced anywhere or needed:

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

Offline parkerc

  • Beta Testers
  • Sr. Hero Member
  • *****
  • Posts: 2479
  • Karma: +35/-48
  • Life Moves Pretty Fast....
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #68 on: December 19, 2013, 02:53:34 am »
I just wanted it create a link to a really good TTS discussion that's going on elsewhere in the forum.

It's goal is to dynamical change the messages that are delivered via TTS.

http://forum.micasaverde.com/index.php/topic,13921.0.html
 

Offline parkerc

  • Beta Testers
  • Sr. Hero Member
  • *****
  • Posts: 2479
  • Karma: +35/-48
  • Life Moves Pretty Fast....
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #69 on: February 16, 2014, 05:44:00 am »
Hi

Please could someone share some working code that groups a couple of Sonos zones players together so that it can Say a particular piece of text,  after which it should return to the previous state it was in (whatever that was.?)

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #70 on: February 16, 2014, 05:53:41 am »
Hi

Please could someone share some working code that groups a couple of Sonos zones players together so that it can Say a particular piece of text,  after which it should return to the previous state it was in (whatever that was.?)

I will try to update the example in the wiki page. I just noted the corresponding paragraph as outdated in the wiki as it lacks few arguments and in particular the GroupZones argument.

Offline parkerc

  • Beta Testers
  • Sr. Hero Member
  • *****
  • Posts: 2479
  • Karma: +35/-48
  • Life Moves Pretty Fast....
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #71 on: February 16, 2014, 06:15:09 am »
Thanks @lolodomo -

That's where I went first to check, but like you said, it's still marked as 'outdated' - I'm looking forward to using the new group commands.

Just a thought - but is there scope to have a 'GroupSay' command created, one that does all the grouping of Zones for you, an alternative to the current singular 'Say' command ?

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #72 on: February 16, 2014, 06:32:54 am »
Thanks @lolodomo -

That's where I went first to check, but like you said, it's still marked as 'outdated' - I'm looking forward to using the new group commands.

Just a thought - but is there scope to have a 'GroupSay' command created, one that does all the grouping of Zones for you, an alternative to the current singular 'Say' command ?

You can use "ALL" as value for the GroupZones argument.

Offline parkerc

  • Beta Testers
  • Sr. Hero Member
  • *****
  • Posts: 2479
  • Karma: +35/-48
  • Life Moves Pretty Fast....
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #73 on: February 16, 2014, 11:00:25 am »
Hi Lolodomo

Would you be able to give me an example of how that is used with a Say command?

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #74 on: February 17, 2014, 04:42:13 pm »
Hi Lolodomo

Would you be able to give me an example of how that is used with a Say command?

It is now explained with several examples in the Wiki: http://code.mios.com/trac/mios_sonos-wireless-music-systems/wiki/WikiStart#MakingaSonosSaysomething
I hope I am clear in my explanations.