We have moved at community.getvera.com

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

Offline jimpapa

  • Sr. Member
  • ****
  • Posts: 454
  • Karma: +28/-1
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #75 on: February 20, 2014, 04:32:19 pm »
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!

obsessed with the TTS

My Sonos device is 73 so I edited that.. 

Can someone point out what needs to be edited from the above working code..

My weather underground plug in is 74
But I'm doing something wrong here ..

« Last Edit: February 20, 2014, 04:36:59 pm by jimpapa »

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 #76 on: February 20, 2014, 04:43:30 pm »
Hi

Just change the value next to AV_DEV to your own Sonos device number e.g.

Code: [Select]
Local AV_DEV = 73
And then add the rest of the code, updating the temperature from 232 to 74 and then the Condition device numbers from 115 to ??? (What ever it is?)
« Last Edit: February 20, 2014, 04:48:56 pm by parkerc »

Offline jimpapa

  • Sr. Member
  • ****
  • Posts: 454
  • Karma: +28/-1
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #77 on: February 20, 2014, 04:48:39 pm »
yes, I should have edited to say I did that:

OK GOT IT! .. items below are the variables that needed to be edited for the weather plugin and SONOS

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

local OutTemp = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature", 75)
local currentCondition = luup.variable_get("urn:upnp-micasaverde-com:serviceId:Weather1", "Condition", 74)

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)

« Last Edit: February 20, 2014, 04:55:47 pm by jimpapa »

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 #78 on: February 20, 2014, 04:50:19 pm »
Sorry I just updated my previous post, to use that piece of code you need all three of the device numbers..

Offline jimpapa

  • Sr. Member
  • ****
  • Posts: 454
  • Karma: +28/-1
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #79 on: February 20, 2014, 04:56:35 pm »
Sorry I just updated my previous post, to use that piece of code you need all three of the device numbers..

... I must have got that telepathically!!

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 #80 on: February 20, 2014, 05:14:19 pm »
You got it !!

Offline haavard

  • Full Member
  • ***
  • Posts: 162
  • Karma: +0/-0
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #81 on: February 21, 2014, 03:25:48 am »
Hi

Just change the value next to AV_DEV to your own Sonos device number e.g.

Code: [Select]
Local AV_DEV = 73
And then add the rest of the code, updating the temperature from 232 to 74 and then the Condition device numbers from 115 to ??? (What ever it is?)

Good to see that you got it working. I spent some time figuring this out since I am not a programmer.
The thing that can be a bit confusing I guess is that in this code the weather condition and temperature is coming from two different devices. I use a real outdoor sensor to report the temperature.
The code is working perfect for me, and I use it every morning when I turn on the lights in my kitchen.

regards

Offline jimpapa

  • Sr. Member
  • ****
  • Posts: 454
  • Karma: +28/-1
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #82 on: February 21, 2014, 07:36:03 am »
@haavard

Yes, thanks!

So to use your own outdoor temp sensor.  Did you just have to change the device number
Ie: what I have as 75 to the device number of your sensor ?


Offline haavard

  • Full Member
  • ***
  • Posts: 162
  • Karma: +0/-0
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #83 on: February 21, 2014, 07:45:49 am »
What do you want the code to read info from? Weather Plugin only?

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

115 is my device number for the Weather underground device.
232 is the device number for my local temperature sensor.

If you go into settings for the device and the advance part you will find the "CurrentTemperature" variable and the "Condition" variable
« Last Edit: February 21, 2014, 07:47:37 am by haavard »

Offline jimpapa

  • Sr. Member
  • ****
  • Posts: 454
  • Karma: +28/-1
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #84 on: February 21, 2014, 09:33:10 am »
ok.. Thats my observation, 232 is your temp sensor..

Thanks

It works great.. Using the OSX TTS engine with the "siri" voice (Samantha)


Offline haavard

  • Full Member
  • ***
  • Posts: 162
  • Karma: +0/-0
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #85 on: February 21, 2014, 12:05:43 pm »
How did you setup the plugin to work with osx tts?


Sent from my iPad using Tapatalk

Offline jimpapa

  • Sr. Member
  • ****
  • Posts: 454
  • Karma: +28/-1
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #86 on: February 21, 2014, 02:32:31 pm »
I'm running Beta 3 that has the OSX_TTS support.

On the advanced tab just set the:

DefaultEngineTTS to OSX_TTS_SERVER

OSXTTSServerURL  http://YOUR_MACS_IP:8080

and on your MAC install this:

http://wolfpaulus.com/jounal/mac/ttsserver/

and configure from your web browser: http://YOUR_MACS_IP:8080


Works perfect  ;)

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 #87 on: February 21, 2014, 06:52:06 pm »
Here is new piece of TTS code to provide you with a way to have random words spoken, that way  each time you run it, it's potentially different. I've taken bits and pieces from other posts, so I cannot take any credit..

Play Random Words

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

local SONOS = 5
local LS_SID = "urn:micasaverde-com:serviceId:Sonos1"
local TEMP_SID = "urn:upnp-org:serviceId:TemperatureSensor1"

local greetings = { "Hi, ", "Hello, ", "Whatcha, " }
local greeting = greetings[math.random(table.getn(greetings))], "RAID"

local messages = { "How Ya Doing! ", "Hope You're Well! " }
local message = messages[math.random(table.getn(messages))], "RAID"

local introductions = { "My name is Vera! ", "This is your house talking, " }
local introduction = introductions[math.random(table.getn(messages))], "RAID"

local goodbyes = { "See Ya!", "Adios!", "Cheerrio,", "Goodbye, ", "Later, ", "Bye, "}
local goodbye = goodbyes[math.random(table.getn(goodbyes))], "RAID"

local frase = greeting .. message .. introduction .. goodbye

local benTemp = luup.variable_get(TEMP_SID,"CurrentTemperature", 210)
local emmaTemp = luup.variable_get(TEMP_SID,"CurrentTemperature", 211)

luup.call_action(LS_SID, "Say", {Text = string.format("%s, %s, I just wanted to let you know that Ben's room is at %s degrees, where as Emmers is at %s degrees,, %s ", greeting, message, benTemp, emmaTemp, goodbye)}, SONOS)

Let me know what you think..
« Last Edit: February 22, 2014, 05:09:02 am by parkerc »

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 #88 on: February 22, 2014, 05:06:57 am »
Here's a bit of fun, but it can be used for an all zones announcement. Just change you say command to include the GroupZones details below.

All Zones Message

(This one is out of respect to the UK TV show Red Dwarf)

Code: [Select]
local SONOS = 5
local LS_SID = "urn:micasaverde-com:serviceId:Sonos1"

luup.call_action(LS_SID, "Say", {Text="A-wooga! A-wooga! this is a test, A-wooga! A-wooga! this is a drill, A-wooga! A-wooga!.. No need to panic!! ", Language="en", GroupZones="ALL",Volume=30, SameVolumeForAll="true"},SONOS)
« Last Edit: February 22, 2014, 05:12:19 am by parkerc »

Offline Piwtorak

  • Hero Member
  • *****
  • Posts: 988
  • Karma: +4/-0
Re: Text To Speech (TTS) With Sonos - Creating Dynamic Messages
« Reply #89 on: February 28, 2014, 04:12:28 pm »
ParkerC,
thanks for the tip..

but what is the 5 in the SONOS variable, what this value set ?
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.