Hi,
I'm using the 1.0.1b beta of the Sonos remote with the voicers API.
I have a basic test scene to develop voice usage in my system
From when I start the it takes between 8-9 seconds before I hear the sentence. The sonos mutes from when I start the scene
The code is a simple function
--[[
%% properties
%% events
%% globals
--]]
local ZoneID = 1308
local Message = "Seting away mode now, Alarm will arm in 30 seconds"
local VolLevel = 30
local TTSEngineID = 356
if (fibaro:countScenes()>1) then
fibaro:abort()
end
function tempFunc()
fibaro:setGlobal("TTSZoneID", ZoneID)
fibaro:setGlobal("TTSMessage", Message)
fibaro:setGlobal("TTSVolLevel", VolLevel)
fibaro:startScene(TTSEngineID)
end
tempFunc()
The actual code to "speak" is separate as this allows me to call it with the required sentence and not repeat all the code
The TTSEngineID code is from the forum here
--[[
%% properties
%% events
%% globals
--]]
-- Configuration - Scene Info
sceneName = "TTS Engine"
sceneVersion = "1.0.1"
-- Configuration - Device IDs
local bid = 28 -- ID of the VD buttom (do not change)
local sid = fibaro:getGlobalValue("TTSZoneID")
-- Validate Number of Scene Instance
if (fibaro:countScenes()>1) then
fibaro:abort()
end
-- Main Scene Execution Code
function tempFunc()
local params = {
message = fibaro:getGlobalValue("TTSMessage"),
duration = 'auto', -- Duration: "auto", xx seconds
language = "en-gb", -- Language: see http://www.voicerss.org/api/documentation.aspx to get your language code
volume = fibaro:getGlobalValue("TTSVolLevel"),
}
local _f = fibaro
local _x ={root="x_sonos_object",load=function(b)local c=_f:getGlobalValue(b.root)if string.len(c)>0 then local d=json.decode(c)if d and type(d)=="table"then return d else fibaro:debug("Unable to process data, check variable")end else fibaro:debug("No data found!")end end,set=function(b,e,d)local f=b:load()if f[e]then for g,h in pairs(d)do f[e][g]=h end else f[e]=d end;_f:setGlobal(b.root,json.encode(f))end,get=function(b,e)local f=b:load()if f and type(f)=="table"then for g,h in pairs(f)do if tostring(g)==tostring(e or"")then return h end end end;return nil end}
-- Make a request to the remote to process params object instantly
_x:set(tostring(sid), { tts = params })
_f:call(sid, "pressButton", bid)
end
-- Trigger Management
local currentDate = os.date("*t")
local startSource = fibaro:getSourceTrigger()
--Start of Scene Execution
if (startSource["type"] == 'property') then
fibaro:debug("Started through property")
tempFunc() -- this is calling the the function if something happens.
elseif (startSource["type"] == 'global') then
fibaro:debug("Started through variable")
tempFunc() -- this is calling the the function if something happens.
elseif (startSource["type"] == "autostart") then
fibaro:debug("Started through autostart")
tempFunc() -- this is calling the the function if something happens.
elseif (startSource["type"] == "other") then
fibaro:debug("Started through other ")
tempFunc() -- this is calling the the function if something happens.
else
fibaro:debug("Scene not started, this can only be started through other, property, global or autostart!");
end
-- End of Scene Execution
fibaro:debug("Scene, " .. sceneName .. " v" .. sceneVersion .. " completed.")
Is there anybody else experiencing this type of delay (or perhaps its normal ??)
Is I used MP3's on my local NAS would it be faster?
Thanks
-F