TTS failed in Scene

#1

Hi,

I’m trying to create a scene where Sonos says something when triggered by a motion sensor or fire alarm. I’ve successfully tested TTS manually via TTS menu:

TTS

But if I create a scene with TTS I only get the error “Scene run failed”:

The scene looks like this:

Any idea what’s wrong?

0 Likes

#2

I’m guessing that the Google translate URL should be formatted in text…

C

0 Likes

#3

The Google TTS server URL should be “http://translate.google.com” instead of “http%3A%2F%2Ftranslate.google.com” but every time I change to the correct URL it’s reset to http%3A…

Anyway I’m using ResponsiveVoice instead of Google and direct TTS is working fine. Is it possible in general to use TTS in a scene or do I have to use a LUA script? Anything else I could try to make it work in a scene?

0 Likes

#4

Odd. Have you typed the URL in manually or are you copy <> pasting?

Cheers

C

0 Likes

#5

I’ve tried both. One Sonos device where I didn’t tried TTS has still the correct URL. I’m afraid the change there anything leads to the same http&3A…

Do you think that that the Google URL affects the output via ResponsiveVoice?

0 Likes

#6

I use lua to send TTS to sonos here is an example for my morning weather announcement:

url = require("socket.url")

local AV_DEV = 219
local LS_SID = "urn:micasaverde-com:serviceId:Sonos1"
local time = os.date('%I: %M')
local TEMP_SID ="urn:upnp-micasaverde-com:serviceId:Weather1"
local OwTempTodayHigh= luup.variable_get(TEMP_SID, "TodayHighTemp", 548)
local OwTempTodayLow= luup.variable_get(TEMP_SID, "TodayLowTemp", 548)
local currentCondition= luup.variable_get(TEMP_SID, "TodayConditions", 548)
local OwTempTomorrowHigh= luup.variable_get(TEMP_SID, "TomorrowHighTemp", 548)
local OwTempTomorrowLow= luup.variable_get(TEMP_SID, "TomorrowLowTemp", 548)
local tomorrowCondition = luup.variable_get("urn:upnp-micasaverde-com:serviceId:Weather1", 
"TomorrowConditions", 548)



luup.call_action(LS_SID, "Say", {Text = string.format("God morgon! Idag blir det %s med en högsta 
temperatur på %s grader och en lägsta temperatur på %s grader.   I morgon blir det %s med en 
högsta temperatur på %s grader och en lägsta temperatur på %s", currentCondition, 
OwTempTodayHigh, OwTempTodayLow, tomorrowCondition, OwTempTomorrowHigh, 
OwTempTomorrowLow) ,Volume=35}, AV_DEV)

AV_DEV is the device ID of my sonos plugin device

0 Likes

#7

I’ll give it a try.

0 Likes

#8

Maybe start with something simple like:

url = require("socket.url")

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

luup.call_action(LS_SID, "Say", {Text = string.format("Hello World") ,Volume=35}, AV_DEV)
1 Like

#9

I believe the value for Engine in your scene action should be “RV” not “ResponsiveVoice”. The latter is what shows on the menu in the plugin (the human-readable text for the option), but the key value that the UI sends to the action is actually different.

1 Like

#10

I’ve set the Engine to RV. Seems to work. The script also runs fine in “Test Luup code” and in Scene.

Is it possible to realize the following scene (with LUA)?

  • Smoke Sensor XY triggered an alarm
  • All Sonos devices say “Firealarm at XY” and repeat (with some delay between) as long as smoke is detected
0 Likes

#11

There are a number of ways to do it, but you could add the following Lua to a scene that is triggered by the smoke detector tripping:

-- Insert this as your scene Lua, triggered by the smoke detector tripping
-- (whether armed or disarmed--you always want to know).
-- Be sure to set the device numbers correctly below. Modify the TTS text
-- and language as needed.

local SonosDeviceNum = 123
local SensorDeviceNum = 456
local warningInterval = 15 -- seconds between warnings

function warnSmoke()
	-- Since this function is called in a time-delay loop, we have to make sure
	-- we check the sensor state each time or it will never stop talking.
	local status = luup.variable_get( "urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", SensorDeviceNum ) or "0"
	if status == "0" then
		luup.log("The smoke has cleared; stopping warnings.")
		return 
	end

	-- Give TTS warning on Sonos.
	luup.call_action( "urn:micasaverde-com:serviceId:Sonos1", "Say",
		{ Text="Achtung! Feuer in der Badewanne! Wieso?", Language="de", Engine="RV", Volume=50 },
		SonosDeviceNum )

	-- Delay and call this function again.
	luup.call_delay( "warnSmoke", warningInterval, "" )
end

-- Since we are triggered by the detector, start off with the first warning.
luup.log("Smoke detector TTS warning loop starting.")
warnSmoke()
return true

This code also writes start and stop messages to the Vera log, so you can see it running there.

1 Like

#12

Thank you! I’ll try this when wife and children are not at home :wink:

0 Likes

#13

Cool. Just be aware that if you run the scene directly (with the “play” button on the scene list), it likely will not speak. That’s because it checks the sensor status before speaking, so it knows when to stop speaking, so if you just run the scene and the sensor is not tripped, nothing will happen.

0 Likes

#14

You are a bad man :smile:

C

0 Likes

#15

Das stimmt so, aber nur ein bisschen.

1 Like

#16

I think I’ll trigger the sensor with some test smoke from the spray can… at night :grin:

0 Likes

#17

0 Likes