We have moved at community.getvera.com

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

Offline Brientim

  • Sr. Hero Member
  • ******
  • Posts: 2497
  • Karma: +78/-7
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #150 on: February 06, 2015, 02:12:48 pm »
Yes, you need to go to the devices Advanced tab and get their Device Id (the number) not their name. This is what you are replacing

Offline hkk1644

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #151 on: February 06, 2015, 03:11:53 pm »
alright so this is the code I am putting in, all i want to do is create a scene that i can trigger when i walk in the door. If someone could let me maybe Bold or italicize what i need to change with some type of guidance I would really appreciate it, once again I really have looked through as much as i can of the forums and cannot find anything to help me.  thank you very much for any help

url = require("socket.url")
local t = os.date('*t')

local AV_DEV = 5
local LS_SID = "urn:micasaverde-com:serviceId:Sonos"
local current_second = t.hour * 3600 + t.min * 60 -- number of sec since midnight
local morning = 0 * 3600 +  0 * 60             -- 00:00
local afternoon = 12 * 3600 +  0 * 60       -- 12:00
local evening = 18 * 3600 +  0 * 60             -- 18:00
local name = "Chris"

   if (current_second > morning) and (current_second < afternoon) then
        luup.call_action(LS_SID, "Say", {Text = string.format("Good Morning %s ", name)}, AV_DEV)
   else
     
        if (current_second > afternoon) and (current_second < evening) then
             luup.call_action(LS_SID, "Say", {Text = string.format("Good Afternoon %s ", name)}, AV_DEV)
        else

             luup.call_action(LS_SID, "Say", {Text = string.format("Good Evening %s ", name)}, AV_DEV)
        end
   end

Offline Brientim

  • Sr. Hero Member
  • ******
  • Posts: 2497
  • Karma: +78/-7
Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #152 on: February 06, 2015, 03:25:17 pm »
local AV_DEV = 5  Change the 5 to match your Sonos Device# from the Advance tab as per the attached screen shot, it would be 404.  You will then need to set the trigger to activate the scene.

Some YouTube stuff, the first is Vera Traing the the other two are specific to Automating Sonos. I have not watched them but there were referenced in other threads and created by a member of the forum to assist in these cases...
https://m.youtube.com/user/veratraining

http://youtu.be/hCvsC0MmoV4

https://m.youtube.com/watch?v=9uff1VQFdpA
« Last Edit: February 06, 2015, 03:34:44 pm by Brientim »

Offline hkk1644

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #153 on: February 06, 2015, 04:18:50 pm »
url = require("socket.url")
local t = os.date('*t')

local AV_DEV = 24 ------I changed this to myg device
local LS_SID = "urn:micasaverde-com:serviceId:Sonos" -------what is this do i have to change this to whatever my sonos zone is called?
local current_second = t.hour * 3600 + t.min * 60 -- number of sec since midnight
local morning = 0 * 3600 +  0 * 60             -- 00:00
local afternoon = 12 * 3600 +  0 * 60       -- 12:00
local evening = 18 * 3600 +  0 * 60             -- 18:00
local name = "Chris" -----what is this? do i have to change this to my username?

   if (current_second > morning) and (current_second < afternoon) then
        luup.call_action(LS_SID, "Say", {Text = string.format("Good Morning %s ", name)}, AV_DEV)
   else
     
        if (current_second > afternoon) and (current_second < evening) then
             luup.call_action(LS_SID, "Say", {Text = string.format("Good Afternoon %s ", name)}, AV_DEV)
        else

             luup.call_action(LS_SID, "Say", {Text = string.format("Good Evening %s ", name)}, AV_DEV)
        end
   end

Offline hkk1644

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #154 on: February 06, 2015, 04:21:34 pm »
is there anything else I need todo in the advance tab or the devices tab like add something with a specific command? thank you so much

Offline Brientim

  • Sr. Hero Member
  • ******
  • Posts: 2497
  • Karma: +78/-7
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #155 on: February 06, 2015, 04:50:14 pm »
url = require("socket.url")
local t = os.date('*t')

local AV_DEV = 24 ------I changed this to myg device
local LS_SID = "urn:micasaverde-com:serviceId:Sonos" -------There is an error with the Service ID see below for change. There are a number of ways to verify this and http://forum.micasaverde.com/index.php/topic,29454.msg209151.html#msg209151 for more details
local current_second = t.hour * 3600 + t.min * 60 -- number of sec since midnight
local morning = 0 * 3600 +  0 * 60             -- 00:00
local afternoon = 12 * 3600 +  0 * 60       -- 12:00
local evening = 18 * 3600 +  0 * 60             -- 18:00
local name = "Chris" -----what is this? This is used later and announcement of the name recorded here, so change to your name, but I have changed it below to make it more clearer

   if (current_second > morning) and (current_second < afternoon) then
        luup.call_action(LS_SID, "Say", {Text = string.format("Good Morning %s ", name)}, AV_DEV)
   else
     
        if (current_second > afternoon) and (current_second < evening) then
             luup.call_action(LS_SID, "Say", {Text = string.format("Good Afternoon %s ", name)}, AV_DEV)
        else

             luup.call_action(LS_SID, "Say", {Text = string.format("Good Evening %s ", name)}, AV_DEV)
        end
   end

Code: [Select]
url = require("socket.url")
local t = os.date('*t')

local AV_DEV = 24
local LS_SID = "urn:micasaverde-com:serviceId:Sonos1"
local current_second = t.hour * 3600 + t.min * 60
local morning = 0 * 3600 +  0 * 60           
local afternoon = 12 * 3600 +  0 * 60     
local evening = 18 * 3600 +  0 * 60             
local myName = "Your Name"

   if (current_second > morning) and (current_second < afternoon) then
        luup.call_action(LS_SID, "Say", {Text = string.format("Good Morning %s ", myName)}, AV_DEV)
   else
     
        if (current_second > afternoon) and (current_second < evening) then
             luup.call_action(LS_SID, "Say", {Text = string.format("Good Afternoon %s ", myName)}, AV_DEV)
        else

             luup.call_action(LS_SID, "Say", {Text = string.format("Good Evening %s ", myName)}, AV_DEV)
        end
   end
« Last Edit: February 06, 2015, 05:03:09 pm by Brientim »

Offline hkk1644

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #156 on: February 06, 2015, 05:18:27 pm »
Hi, I clicked on the link you had to help fix the error code for the "local service id".  The 2 links that had screenshots when hovered over are dead and the other one where it said to paste this following link into my browser only took me to google search results.

http://<veraip>/port_3480/data_request?id=lu_status&output_format=xml

what is...service id? is it anything i can find clicking around UI5?

Once again thank you for being a great help, i looked around on the posts to give you a thumbs up or something similar but didnt see anything

Offline Brientim

  • Sr. Hero Member
  • ******
  • Posts: 2497
  • Karma: +78/-7
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #157 on: February 06, 2015, 05:23:49 pm »
The link needs to be changed <veraip> must be modified to reflect the IP address of your Vera e.g 192.168.1.55/port...., etc

There are also a number of apps that contain the links internal to vera but I can't remember them at the moment.

An example of how to find the service id is found at
http://forum.micasaverde.com/index.php/topic,13003.msg96037.html#msg96037

Lua Invoke will provide a drill down:
http://vera_ip/port_3480/data_request?id=lu_invoke
Of course as above change vera_ip to match your vera's IP address and then paste into your browser
« Last Edit: February 06, 2015, 05:33:33 pm by Brientim »

Offline hkk1644

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #158 on: February 06, 2015, 05:33:45 pm »
GOT IT! now what am i looking for...i would paste it in here but its way too much.  Is it something correlated to the sonos or the vera itself?  if so what can i put in the search box to pull it up, also what is it just a number or words?

Offline Brientim

  • Sr. Hero Member
  • ******
  • Posts: 2497
  • Karma: +78/-7
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #159 on: February 06, 2015, 06:05:32 pm »
Most of the codes have the respective data correct and only a few variable need modifying. Just by chance the one you selected to start with had the incorrect Service ID.. That did not help you. Did you try the code I pasted before with the corrected information? Match the Sonos device number and change to reflect your name.
Do not paste the user_data.xml  output as it contains sensitive information.

If you drill throught the lu_invoke you will see service ids and other variable used but only time will give you an understanding

Offline hkk1644

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #160 on: February 06, 2015, 06:09:08 pm »
Oh I see what youre saying, let me give that a shot.  No I was using the one that was originally posted as the one to use.

Offline hkk1644

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #161 on: February 06, 2015, 06:13:16 pm »
AHHH, it worked ! thanks you so much for your help

Offline Brientim

  • Sr. Hero Member
  • ******
  • Posts: 2497
  • Karma: +78/-7
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #162 on: February 06, 2015, 06:17:44 pm »
That is fine... Now you have one working start on the next. Compare the changes I pointed out and for most, it will only require the Device id being updated. Good luck

Offline hkk1644

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #163 on: February 06, 2015, 06:24:44 pm »
Yes most definitely now I have an idea of how and what needs to change from the code.  one more question if I wanted to assign a volume to it, what command and where would i put it?  Also is there a pdf file somewhere that addresses all of the different code and syntax for luup?