We have moved at community.getvera.com

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

Offline Brientim

  • Sr. Hero Member
  • ******
  • Posts: 2497
  • Karma: +78/-7
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #45 on: May 03, 2013, 06:05:17 pm »

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

thanks !

Refer to wiki there is an example of insert language parameters: http://code.mios.com/trac/mios_sonos-wireless-music-systems/wiki#

Offline Piwtorak

  • Hero Member
  • *****
  • Posts: 988
  • Karma: +4/-0
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #46 on: May 05, 2013, 10:53:27 am »
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)))
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 a-lurker

  • Hero Member
  • *****
  • Posts: 872
  • Karma: +66/-8
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #47 on: May 05, 2013, 07:16:38 pm »
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", "")

« Last Edit: May 18, 2013, 02:31:29 am by a-lurker »

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 #48 on: May 12, 2013, 02:48:40 am »
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.

Offline Piwtorak

  • Hero Member
  • *****
  • Posts: 988
  • Karma: +4/-0
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #49 on: May 13, 2013, 07:20:12 am »
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:

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)


but I don't know where to put the gsub instruction supplied for a-lurker.
but is running fine !!!
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 a-lurker

  • Hero Member
  • *****
  • Posts: 872
  • Karma: +66/-8
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #50 on: May 18, 2013, 01:05:15 am »
Try this.

Code: [Select]
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

« Last Edit: May 19, 2013, 04:44:55 am by a-lurker »

Offline Piwtorak

  • Hero Member
  • *****
  • Posts: 988
  • Karma: +4/-0
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #51 on: May 18, 2013, 01:01:15 pm »
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 ?

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 RichardTSchaefer

  • Community Beta
  • Master Member
  • ******
  • Posts: 10091
  • Karma: +764/-143
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #52 on: May 18, 2013, 01:32:14 pm »
Quote
Where can I find a good material to luup language ?

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

Offline haavard

  • Full Member
  • ***
  • Posts: 162
  • Karma: +0/-0
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #53 on: November 22, 2013, 07:54:10 am »
Hello


Code: [Select]
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)

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?
 

Offline Piwtorak

  • Hero Member
  • *****
  • Posts: 988
  • Karma: +4/-0
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #54 on: November 22, 2013, 08:25:25 am »
Try this sintax in the line of say instruction.


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

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 haavard

  • Full Member
  • ***
  • Posts: 162
  • Karma: +0/-0
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #55 on: November 23, 2013, 05:53:29 am »
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)

Offline Brientim

  • Sr. Hero Member
  • ******
  • Posts: 2497
  • Karma: +78/-7
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #56 on: November 23, 2013, 06:04:39 am »
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.

Offline haavard

  • Full Member
  • ***
  • Posts: 162
  • Karma: +0/-0
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #57 on: November 23, 2013, 06:10:49 am »
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)

Offline haavard

  • Full Member
  • ***
  • Posts: 162
  • Karma: +0/-0
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #58 on: November 26, 2013, 09:57:50 am »
I have tried to evolve my dynamic message :)
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: [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, OutTemp,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 #59 on: November 26, 2013, 11:53:18 am »
You are using undefined variable OutTemp rather than currentTemp
+ parenthesis look wrong in the call_action command.