Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


Using an android device as a text-to-speech engine


davanha

Recommended Posts

I have the OnePlus 6.
And I can go to Battery optimization to prevent not going into sleep.

Problem is I often close apps in my android device (recent apps that are open in device)

When doing this the tts app closes also, and nothing will work. 

 

Link to comment
Share on other sites

  • 6 months later...

Hi 

 

I get the following error when i run my scen , what have i done wrong..

I copied "

Please login or register to see this link.

" in to a lua scen with id 15 and one scen with fibaro:startscene

 

Please login or register to see this image.

/monthly_2019_10/image.png.50614ac3b4ec67dd0df1c2fc1147bcba.png" />

 

 

image.png.6247d8e103f0039a6728345638b055db.png

Link to comment
Share on other sites

The line looks OK,  but the error is very weird... it points to line #1 ???  Why do you think that the error in on this line?

Could you please post entire scene code? As a text not a screenshot ...

 

 

Edited by cag014
Link to comment
Share on other sites

Hi thanks for your reply !

 

I'am a little confused in the TTS scen file the execution line is          fibaro:startScene('sceneID',\{"text","192.168.1.12:8080"\})  

but in the forum i also found following line                                  fibaro:startScene('ttsSceneID',{"text","192.168.1.12:8080"})

its not the same. Whats the correct line to execute the TTS scen?

 

This is the code i copied from the TTS file and pasted in to my scen.

 

 

{\rtf1\ansi\ansicpg1252\deff0\nouicompat{\fonttbl{\f0\fnil\fcharset0 Calibri;}{\f1\fnil\fcharset1 Segoe UI Symbol;}{\f2\fnil\fcharset1 Cambria Math;}{\f3\fnil\fcharset1 Segoe UI Symbol;}}
{\*\generator Riched20 10.0.17134}{\*\mmathPr\mmathFont2\mwrapIndent1440 }\viewkind4\uc1 
\pard\sl240\slmult1\f0\fs22\lang9 --[[ \par
V1.0 Scene functionality:\par
1. Sendi text (and volume level-optional) to specific IP address of ZenitGatekeeper.apk \par
2. The scene designed for external execuiton only with parameters of text and IP address.\par
    An example:\par
      * fibaro:startScene('sceneID',\{"text","192.168.1.12:8080"\})   \par
      * fibaro:startScene('sceneID',\{"text","192.168.1.12:8080",volLevel\}) \par
   Please notice that the volume level of your phone or tablet will be changed\par
                 accordingly. Usualy volume range is 1-15.\par
\par
======================== USER CONFIGURABLE PARAMETERS ===============================\par
--------------------------------- v1.0 ---------------------------------------------------------]]\par
local httpTimeout = 7000   -- HTTP timeout in mSec. \par
local debug       = false  -- Display debug information.\par
---------------------------------------------------------------------------------------\par
--=================================================================================\par
\par
function errProcess(httpStatus)\par
   mStr = mStr .. "<font color=orangered><sup>[" .. httpStatus .. "]</sup>"\par
    if (tonumber(httpStatus) >= 500 ) then\par
           mStr = mStr .. "<small> [X] </small>Server error while processing the request"\par
    elseif (tonumber(httpStatus) >= 400 ) then\par
           mStr = mStr .. "<small> [X] </small>lient request error"\par
    elseif (tonumber(httpStatus) >= 300 ) then\par
      mStr = mStr .. "<small> [X] </small>Redirection to another location"\par
    end\par
    fibaro:debug(mStr .. "</font>")\par
end\par
mStr =""\par
local IP_address,PAMessage = "",""\par
local TTS_delay,sleepTime,sCnt=0,0,fibaro:countScenes()\par
\par
math.randomseed(os.clock()*10000)\par
if (fibaro:args() ~= nil) then \par
   PAMessage  = fibaro:args()[1] \par
   IP_address = fibaro:args()[2]\par
   if fibaro:args()[3] then ttsVol = fibaro:args()[3] end\par
else\par
  fibaro:debug ("<font color=pink>No data received. Aborting scene...</font>")\par
  fibaro:abort()\par
end\par
-- In case that more than one messages received at the same time, \par
--    create delay between scenes to allow TTS to speak all messages.\par
if fibaro:countScenes() > 1 then\par
  while sleepTime ❤️ do sleepTime = math.random()*7.5 end\par
  if debug then fibaro:debug("\f1\u-10180?\u-8276?\f0 "..fibaro:countScenes() .. " \f1\u-10179?\u-8950?\f0 ".. PAMessage .. " \f2\u10711?\f0 "..sleepTime) end\par
else\par
  sleepTime = 6\par
end\par
TTS_delay = PAMessage:len() * 170--mSec per character\par
x=os.clock(); while (fibaro:countScenes() > 1 and os.clock() - x < sleepTime) do end \par
uri="/tts=" .. PAMessage  \par
\par
if PAMessage == "wakeup" or PAMessage == "ping" then uri="/"..PAMessage ; ttsVol=nil end \par
mStr = "<font color=lightblue><sub>\f1\u-10180?\u-8276?\f0 "..fibaro:countScenes().."/"..sCnt ..\par
       "</font></sub><font color=yellowgreen><small> "..string.match(IP_address,"(.*):") .. \par
       "</small></font><font color=wheat> \f1\u-10179?\u-8950?\f0  "..PAMessage.." </font><sup>\f2\u10711?\f0 "..TTS_delay/1000 .. "</sup>"\par
if ttsVol then \par
  mStr=mStr.. "\f1\u-10180?\u-8267?\f0 <font color=wheat>".. ttsVol.." </font>"\par
  uri = uri.."&vol="..ttsVol \par
end \par
uri = string.gsub(string.gsub(uri, "%%", "%%25"), "%s+", "%%20")\par
if debug then fibaro:debug("URL [ " .. uri .. " ]") end\par
TTS = net.HTTPClient(\{timeout=httpTimeout\})\par
TTS:request("http://" ..IP_address .. uri,\par
  \{success = function(resp)\par
                if resp.status >= 300 then  errProcess(resp.status) \par
                else \par
                   fibaro:debug(mStr .. "<font color=lightgreen><small> [\f3\u10004?\f0 ]</small></font>")\par
                   fibaro:sleep(TTS_delay)\par
                end\par
             end, -- function(resp) \par
   error = function(error)\par
               if string.find(error,"Operation canceled") then\par
                 fibaro:debug(mStr.."<font color=orangered><small> [X] </small>"..error..". timeout " .. httpTimeout/1000 .."sec.</font>")\par
               else\par
                 fibaro:debug(mStr.."<font color=orangered><small> [X] </small>"..error.."</font>")\par
               end\par
           end,\par
    option = \{method = "GET"\}\par
  \})\lang9\par
}
 

Link to comment
Share on other sites

I found the problem,  i did not open the downloaded TTS scen in wordpad.

Now it works :-)

Link to comment
Share on other sites

Great... enjoy

Link to comment
Share on other sites

  • 11 months later...

Good morning to all,
I am trying to bring this solution for HC3 using Quick Apps via this code:

function QuickApp:ChiamareTTS()
       self:debug("ChiamareTTS ")
    local address = "http://100.79.219.99:8080/tts=testing&vol=15"
 
    self.http:request(address, {
        options={
           headers = { 
               Accept = "application/json"
            },
            checkCertificate = true,
            method = 'GET'
        },
        success = function(response)
            self:debug("response status:", response.status) 
            self:debug("headers:", response.headers["Content-Type"]) 
            local data = json.decode(response.data)  
            self:debug("ChiamareTTS data " .. data)
            self:updateView("label""text", data) 
        end,
        error = function(error)
            self:debug('error: ' .. json.encode(error))
        end
    }) 
    self:debug("ChiamareTTS fine")
 
end
 
function QuickApp:setLabelWithTime()
    self:debug("setLabelWithTime")
    self:updateView("label""text""testoTTS")
end
 
function QuickApp:onInit()
    self:debug("onInit")
    self.http = net.HTTPClient({timeout=3000})
end
 
function QuickApp:uibutton1OnReleased(event)
    self:debug("uibutton1OnReleased")
    self:ChiamareTTS()
 
end
 
Ma ottengo sempre questa risposta:
[24.09.2020] [07:18:49] [TRACE] [QUICKAPP137]: UIEvent: {"eventType":"onReleased","values":[],"deviceId":137,"elementName":"button1"}[24.09.2020] [07:18:49] [DEBUG] [QUICKAPP137]: uibutton1OnReleased[24.09.2020] [07:18:49] [DEBUG] [QUICKAPP137]: ChiamareTTS[24.09.2020] [07:18:49] [DEBUG] [QUICKAPP137]: ChiamareTTS fine[24.09.2020] [07:18:52] [DEBUG] [QUICKAPP137]: error: "Operation canceled"
Do you have any suggestions?
it could be a port problem as shown in this post (I'm not very clear about the exposure): 
 
 
 
Link to comment
Share on other sites

  • 4 months later...
On 10/3/2019 at 8:01 PM, pewi said:

I found the problem,  i did not open the downloaded TTS scen in wordpad.

Now it works :-)

 What do you mean ?

 

my runnnig code is >

--[[
%% properties
%% events
%% globals
--]]
fibaro:startScene(130,{"Morning",192.168.1.27:8080,15})

 

My error message is "

[DEBUG] 18:19:10: 2021-02-20 18:19:10.756876 [ fatal] Unknown exception: /opt/fibaro/scenes/131.lua:10: malformed number near '192.168.1.27'
 "

What can I do ?

Link to comment
Share on other sites

30 minutes ago, iTibor said:

 What do you mean ?

 

my runnnig code is >

--[[
%% properties
%% events
%% globals
--]]
fibaro:startScene(130,{"Morning",192.168.1.27:8080,15})

 

My error message is "

[DEBUG] 18:19:10: 2021-02-20 18:19:10.756876 [ fatal] Unknown exception: /opt/fibaro/scenes/131.lua:10: malformed number near '192.168.1.27'
 "

What can I do ?

 

 

Also I tested the following line, without error but without speaking

fibaro:startScene('130',{"speaking test","192.168.1.27:8080","12"}) 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...