Jump to content

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


Recommended Posts

Maybe if you use "ding-dong" to be played before text, it will shift voice message and it will not be cut.

See few post above:

 

@RH_Dreambox

I have added an option to play a announcement message ("ding-dong") before the speech is played,

In settings choose "Application Settings" -> "Http services" -> "Play Speech on device" 

Check "Play intro announcement before speech" and select the audio file to use as announcement message.

Link to post
Share on other sites
  • Replies 67
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Hi, I have been working for a while to get an android device working as a text-to-speech engine and to generate speech from text that I can play in any speaker at home, and now I have finally got

Hi,   @RH_Dreambox I have added an option to play a announcement message ("ding-dong") before the speech is played, In settings choose "Application Settings" -> "Http services" ->

Without looking into details of your code I would think your problem is the whitespace in the message it needs to be html encoded. You can use string.gsub to replace the whitespace with a valid asci

Posted Images

I just noticed that android tts lib has an metod to play silence. So it should be possible to add an configurable silence to play before playing the speech, this would then give some time for the bt speaker to connect.

Link to post
Share on other sites
  • 3 weeks later...

That would be great, right now I use a silence3seconds.wav as an announcement (instead of ding-dong stuff).  3 seconds is enough to establish bluetooth connection.

Link to post
Share on other sites

I added an option to play silence for a configurable amount of milliseconds before playing ding-dong and the actual message.

You can try it out and see if it works, download the from https://github.com/davandev/AlarmController/releases/tag/v.0.1.651

 New option needed to configure:

Settings -> http services -> play speech on device -> Add silence before speech, then configure the amount of time to wait.

Link to post
Share on other sites
  • 3 months later...

Seems like a interesting project.

I'm having a dedicated wallmount console in the living room and would be awesome to have voice feedback of the system.

Going to give this a try :)

 

I already use geofencing for presentstate.

Will be fun to play a welcome message for each user specific when they arrive home.

 

Link to post
Share on other sites
  • 2 months later...

@davanha Hi, would like to ask if you know how to parse text message that can cause TTS engine to pause something like .. Hello -> stop 1 sec -> world? (Hello, World).  Putting a comma, fullstop etc is not working.

 

/tts=text_contain_pause&vol=<volume level>

On 2/27/2018 at 3:46 PM, Remi said:

Seems like a interesting project.

I'm having a dedicated wallmount console in the living room and would be awesome to have voice feedback of the system. 

Going to give this a try :)

 

I already use geofencing for presentstate. 

Will be fun to play a welcome message for each user specific when they arrive home. 

 

 

@Remi definitely this can be done easily, make sure u get a nice bluetooth speaker lol. but eh, if presentstate detects more than 1 person to get home, what you hear maybe welcome one of those person  only, because 2 messages may parse to your tablet at the same time and TTS engine does not have queue function. It plays what it picks directly.

 

Maybe you need to make a scene like the logic below.

 

if ( A is home and B is home) then

tts = welcome home, A and B

elseif (A is home and B is away) then

tts = welcome home, A

end

 

etc lol

Edited by Sirhideo
Link to post
Share on other sites

ok figure out it is %2e for period (fullstop) and voice does pause.

Edited by Sirhideo
Link to post
Share on other sites
  • 6 months later...

@davanha

First of all I want to thank you for this excellent piece of code.... (I'm heavily using the TTS portion. )

I have notice that you're working on new release.... 2.907, is it available for installation?  (I saw that you're trying to fix  some issue)

It might be an overhead request, but is there any chance to use TTS feature outside of WiFi connection. I mean over cellular network? I've fixed IP address, so I think  it might be helpful to find solution.

Again thank you.

Edited by cag014
Link to post
Share on other sites

@cag014
I am glad to hear you find the app usefull!.

Yes I have been working with a new version, however the new feature (sound detection) is mainly for the keypad app. 

I still have problem with signing the app which unfortunatly make upgrade fail and a reinstall/reconfigure of the app is required ... 

 

Your idea of using TTS outside wifi sounds good, I will test and see what happens if I remove the current wifi requirement.

 

 

Link to post
Share on other sites

Thanks a lot on taking look on this request. It should be enormous to hear your home at any place on earth. (instead of sending emails, push notification and etc.)

I have uploaded your code and my simple scene how to use it. (Waits for Fibaro's approval)

To my opinion you did an excellent job on that, especially the stability of the app, it's just outstanding. 

I know that many users wants this feature as well, but they are not familiar with http coding on HC2 , so I hope  by download this simple scene could help them a lot.

 

Edited by cag014
Link to post
Share on other sites

@cag014

Could you please give a more detailed explanation about how you would like to use the TTS outside wifi, (just so I dont missunderstand you ideas). 

 

besides, I see a security risk of using cellular network and that is because the app starts an (open source) webserver, and exposing the android device on the cellular network would open up for attacks.

You might argue that the same apply for local wifi network aswell and that is of course true but I believe most routers have built-in firewalls which keep the local network fairly safe.

 

Link to post
Share on other sites

I understand the risk, but you can set cellular network as an option with warning about the risk. I don't see that as an issue.

What really is a problem that the phone frequently changes the IP address, to my opinion we have two options:

1. Your app will starts as web server with some name instead of IP address, but we need the web name on DNS. I believe you understand what I mean.

2. Once you switch to cellular you can set HC2 global parameter to your IP address. Every change on IP you need to update global variable of HC2 with new IP.

 

Please let me know if you have any other ideas..?

Link to post
Share on other sites

yes I agree, keeping HC2 in sync with the ipaddress of the phone will probably be difficult to get reliable.

I was thinking about another way, I dont know if you are aware already but there is an application named "tasker" in which you can do all sorts of automation stuff with your phone and which could probably be used here.

Lets say that you send all your notifications/messages from HC2 to your phone via Telegram then you dont have to care about the ipaddress of your phone, the phone will receive all notifications 

With tasker on your phone you can then create a "task" that intercepts notifications from Telegram, perform TTS on the notifications and then play it in your phone speakers.

 I did a quick test of it this morning and it seems to work.

Edited by davanha
Link to post
Share on other sites
  • 1 month later...

Hi I think the app works so good! thank you.

 

Where do i find the VD code and other code i need in HC2 to bring the full functionality into play? 

 

Best Regards,

Daniel

Link to post
Share on other sites

@Forall Currently VD is not necessary.  There are 2 kinds of scene (you may imagine as a middle process engine) to parse your TTS message to zenitgatekeeper.

 

A great work from @cag014. Very neat.

 

I am using below, because using a global variable to store TTS message support any language (Of cause your device must have the corresponding text to speech installed )

You may do a scene say

 

For Cag014's work as TTS engine:

if (you wake up) then

   fibaro:startScene(id_of_cag014_scene,{"Morning","ZenigatekeeperIP:8080",15})

end

 

RH_Dreambox scene as TTS engine:

if ( you wake up ) then

    fibaro:setGlobal("TTS", "Morning")

    fibaro:startScene(id_of_rh_dreambox_scene)

end

 

Both TTS engine scenes above read your desired message, in this case "Morning", then it parses morning to your zenitgatekeeper  IP which result you hear your tablet saying.

 

Hope this helps

Edited by Sirhideo
Link to post
Share on other sites

Thank you, maybe i was unclear. What i was refering to was the keypad functions for the alarm system and the power monitoring.

 

Best regards, 

Daniel

Link to post
Share on other sites

Hi

Sure I can publish the VD and scenes I use, but just for your information, it should be possible to integrate the app it with different virtualdevices, I guess it is more about being able to configure it correctly in the app and I dont think that I have documented that  properly :=).

 

But basically in HC2 I have one virtualdevice from where I can arm/disarm the alarm or perimeter protection, then I have 5-6 scenes that performs the actual arming/disarming and finally 2 variables "AlarmState", "AlarmType" defined that keeps the current state of the system.

AlarmState can have values like Disarmed/Armed/Arming/Disarming/Breached and AlarmType like  "Alarm"/"Perimeter"

 

How this then works is that when you press/click arm/disarm button in the app, the app will send a http request that will push a arm/disarm button in the virtual device. 

 

My VD and scenes are not that that pretty looking today, I will spend a day to shape it up and then publish it.

 

Link to post
Share on other sites
  • 1 month later...

little question

4. Usually we're cleaning our phones by killing background applications, so please lock this application on your phone.

 

so how to lock this application on android? I don't know how..

Link to post
Share on other sites

maybe an answer, not sure :=) 

 

Each device manufacturer seem to have different ways to configure which apps/services are allowed to run in the background and it also seems to differ how its done between different android versions.

However even if the app is allowed to run in the background it can still be periodically stopped by android (battery saving feature called doze).

So when the phone screen is turned off and the phone is in standby, android can disable network access which then cause interrupt in apps/services that requires network access, like my app that starts a webserver... .

According to android documentation, keeping the device in a charger will keep network access enabled, however when testing I noticed that at least huawei phones still drop network connection. 

So currently I run the app on a device with android 5 (before doze), it never kills my app and it also never shut down network access even when not in charger =)

 

  
 

Link to post
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...