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

  • Topic Author
  • hm yeah... seems like I need to extend my testing somewhat :=) or maybe spend some time to create unit tests anyway new version (0.1.457) is added  

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    • 4 weeks later...
  • Topic Author
  • No this is not the latest version, you find the latest on 

    Please login or register to see this link.

    .

    I have been struggling to automate the deployment of the app and it seems to work.. but please let me know if you run into problems.  

    Link to comment
    Share on other sites

    Really, really good app!
    Now, my wall-mounted tablet can finally talk to me! It works really well in my own language (Swedish).

    But I have a point on my wish list.

     

    Can you get a message starting with a "Ding-Dong" or similar sound. Selectable sound or Off (no sound).

    Then you should have more time to listen to the message.
    Example:
    Ding-Dong, (short break), message

    Link to comment
    Share on other sites

  • Topic Author
  • Hi, good to hear you like it!

     

    Regarding Ding-Dong message, I agree it is a good idea, I have thought about it myself and as I see it there are 3 different use cases that would need to work.

    1. Play speech directly via headphone/bluetooth speaker

    2, Play speech using callback method to rpi/hc2 etc.

    3. Play speech using callback to wifi speaker

     

    For the first case, playing the speech in a speaker connected(headphone/bluetooth) to the android device. 

    I think it might already work although it is not controlled via configuration parameter instead I earlier added support for playing local media files stored on the device:
    http://<device ip>:8080/play=<full path to media file on device>

    or
    http://<device ip>:8080/play=<full path to media file on device>&vol=<volume level normally 0-15>

    So in theory, you store (or choose an existing) a ding-dong file on the device and then before playing your speech you play the ding-dong file.

     

    The second and third case can probably be implemented in different ways, I haven't really thought about details, but I will add it to my todo list :=)  

     

     

    Link to comment
    Share on other sites

    Please, can anyone help me with this?

    I have modified a (borrowed) Telegram-code to send messages via TTS.


    When I write something to the global TTS variable, the text will be sent to my Android tablet and read up there.

    The message is sent, but only the first word is read, then an error message appears.

     

    So, how do I write a code that reads all the words?
    I can not find where in my code the error exists.

     

    Please login or register to see this code.

    The ERROR message

    Quote

    [DEBUG] 15:39:58: Message: Hello World&vol=10
    [DEBUG] 15:39:58: [1;31m2017-05-10 15:39:58.426091 [ fatal] LUA error: /usr/share/lua/5.2/json/decode/util.lua:35: unexpected character @ character: 1 0:1 [<] line:
    [DEBUG] 15:39:58: <

     

    Link to comment
    Share on other sites

  • Topic Author
  • 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 ascii format, for example :
    fibaro:debug("OrigMsg:" .. message)
    encodedmsg = string.gsub(message,'%s','%%20')
    fibaro:debug("EncodedMsg" .. encodedmsg )

    Since you are swedish you might also want to encode å,ä,ö, you can find correct conversion here :

    Please login or register to see this link.

     

    Link to comment
    Share on other sites

    Thanks davanha, I'll try to solve this with your tips.

    Edit:

    Now it works! Many thanks for your help!

    Edited by RH_Dreambox
    Link to comment
    Share on other sites

    Hi. I try to play ttsFetch on my lms server but it generate wav file so it can't work.

    Is it possible to generate mp3 file.

    Link to comment
    Share on other sites

  • Topic Author
  • I dont think there is builtin support for generating mp3 in android, however it seems there are different options to get still get support for it, for example

    Please login or register to see this link.

    .

    I will have a look at it.

     

    Link to comment
    Share on other sites

    • 4 weeks later...

    As I see, the App requires manual initialization at Android startup. I have to run it, than select TTS mode.

    I have an idea to make TTS speaker with board as RapberryPi or Pine64, with build in small amplifier and speaker, normally not connected to any display, and put it somewhere, bit hidden.

    Is it easy way to make the app active at startup of the Android system?

     

    I did some tests with Pine64. The app works fine. I was really looking for something like that. So many thanks for this application.

    Meanwhile I found at Google Play app Text to speech (TTS):

    Please login or register to see this link.

    It also has option to TTS via HTTP, but also requires manual start, and even more steps that this app.

     

    Small bug: my Pine64 board is connected to network via LAN. HTTP service works fine, but application does not show IP at it status page, it shows 0.0.0.0:8000 as a hint. So it is not able to read IP from LAN interface. But as I wrote - API works fine.

    Edited by Albert
    Link to comment
    Share on other sites

  • Topic Author
  • Hi,

    Getting the app to auto start after reboot seemed pretty easy, at least for android 5.0 and 7.0.

    However on android 6.0 there seem to be some kind of bug related to permissions which cause the app not to autostart (not for me anyway).

    What version of android are you running on your Pine64

     

    Regarding the displayed ip address, yes there are multiple ways of retrieving the ip address and I just picked one way that seemed to work. I have updated the app but I don't have any device to test this on, so please feel free to test it.

    You can download an updated version of the app from:

    Please login or register to see this link.

      

    Link to comment
    Share on other sites

  • Topic Author
  • 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" -> "Play Speech on device" 

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

     

    @Albert

    I have added option to restart application after reboot.

    In settings choose "Application Settings"

    Check "Autostart application after reboot"

     

    The settings starts to become a bit gory I know I will try to restructure it somehow.

     

    You find the latest build here 

    Please login or register to see this link.

     

    Link to comment
    Share on other sites

    On ‎10‎.‎06‎.‎2017 at 2:13 PM, davanha said:

    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" -> "Play Speech on device" 

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

     

    @Albert

    I have added option to restart application after reboot.

    In settings choose "Application Settings"

    Check "Autostart application after reboot"

     

    The settings starts to become a bit gory I know I will try to restructure it somehow.

     

    You find the latest build here 

    Please login or register to see this link.

     

    Hi

     

    Thank you very much or updates. Yes, it become very nice and complete TTS app.

     

    I tested it at Pine64 with Android 6. They released Android 7, I will have to retest.

    For Android 6 service does not start at system startup indeed. I changed permissions of your app, allowing it to change Android system settings. But it does not solve the case. So I will better check it with Android 7.

    I see the change in the way you display IP. But it is still wrong. Now it displays IP6, so as hint I see:

    Please login or register to see this link.

    :.  etc

    I set intro sound to play - small WAV file taken from Windows sounds. I copied it to Pine64 memory to Music folder, so it is local at the device. And I set it to play it at Settings of your app. Audio is played by external speaker connected to Audio-out (recognized as headphones). Standard output at Pine64 is with video, via HDMI.It works fine just after setting it.

    The problem is that after restart and startup of the app, it accepts http commands (confirms HTTP calls, and increments statistic counter on the screen), but no speech via speakers. Speaker works, I can hear system sounds, as keyboard clicks etc. But your app does not play. It start to play after few, sometimes several calls, and than plays stable. I was not able to find the rule. It is also not time-releated. When I waited 1minute from start, it still didn't play. Pine64 is at LAN, so network is stable, internet access also looks stable.

    When I switched off Intro playback - I had no such problem anymore. Speech was played always from beginning.

    And also small thinks:

    - when you select or change intro file to play, "Announcement intro file" option in settings is not updated, shows old value.

    - when app works in the background, and you activate it via its icon (as if you start it), it breaks the service, and restart it after selecting TTS green icon in main menu. Maybe it could find running instance and just open it.

     

    I see also other problem, but it is Android related, maybe Android 6 at Pine64 only. When system starts with headphones plugged in, it does not switch audio to headphones. Just does not recognize it. I have to unplug and plug again (than it shows headphone icon near the clock at top bar)

    Link to comment
    Share on other sites

    Checking and playing with the App, and using it as TTS extension for Fibaro, I got one more idea. Simply, to repeat last message.

    I see button "Play Speech" on the screen - for me it does nothink, maybe it is for other mode. I initially thought that it is to play last generated speech. My idea is to have HTTP command to repeat last message. Same as in some GPS maps systems in cars. Fibaro controller can send such request, when user push as button on remote etc. Just when he miss the message.

    Of course, HC2 can also buffer last message or last few messages and can simple send it again. This is how I plan to do the VD. And for repeat I will probably add time stamp... yes, via VD it would be more flexible. If I will allow to repeat last three messages, if message is older than let say 5min, it will add at the beginning "Message from XX:YY am/pm: ...". I like the app and all these ideas more and more ;-)

    But I wanted to share my the idea here.

    ---

    I did some next tests at Pine64 and Android 7.1. It looks as not stable (Android). But the App starts at startup indeed. And shows proper LAN IP too.

    I have some performance issues and other, with your App and other Apps, so I cannot trust that Android version. I also had problems with first commands sent after startup of the device and the system. Sometimes it started to tell all after 2 minutes. So it buffered all inside. Usually it skips also first word. It can be my Android issue, it bad version.

    There is also Android TV v7 version available for Pine64. Mayby it will be more stable.

    Can you please also check, if is all fine with ping called via http ([IP]:8080/ping). After ping I had problems with playing next speech. As if the app get blocked. Ping (sent as URL from webbrowser) always return ServiceEnabled[flase]. Is that fine, shall it be "false"? 

    Edited by Albert
    Link to comment
    Share on other sites

  • Topic Author
  • Hi, @Albert

    Seems you have been busy testing during the afternoon :=) 

    I will try to fix the faults you found (including a workaround for autostart in android 6), just a few comments.

     

    - I have also noticed on my devices that it takes some time after android is booted until the app is actually auto-started. Could you after a reboot when the app starts to respond to http requests, but no speech, try to run "http://<ipaddress:8080>/log" then you should get the logfile, maybe it is possible to determine what is the cause of the failure with it.

    -  The reason for restarting the app when icon is selected was actually by intention, I had problems that android seem to close the server socket when the battery level decreases under some level even though the app service was suppose to always run, when that happened the socket was not released and would be hanging and required some manual enable/disable things start working again.  

    -  The "play speech" button only applies for the case when the app is configured to send a "ttsCompleted" callback. When configured to send a ttsCompleted callback it needs to store the generated speech to be able to return it when the initiator asks for it and this is the only case when the play message button works. When the app is configured to play speech on device it does not store the speech, it simply generates it and plays it immediately. 
    I realize that the button is a bit miss leading, I can probably disable the button in case it is configured to play on device only or maybe remove it since the purpose is really only for testing.


    I like your idea, a message cache could be useful.

    I have also some more ideas, the highest on my wish list is currently to implement support for speech recognition as a service running in background, then I would for example be able to say "status" to the android device and it would then invoke some scene on hc2 to collect house status and then get the status read in speakers. 

     

    This home automation is like an addict and I am totally hooked.. I don't dare to think about how many hours I spent on it since I bought my HC2 last year, all other house projects are currently put on hold :=)

    Link to comment
    Share on other sites

    • 1 month later...


    Sometimes, ZenitGatekeeper stops reading messages. I can see at the statistics that it receives the message, but does not read it in the speaker.
    The only way i found it to get started again is to uninstall the app and then reinstall it.
    Is there any easier way to restart the app?

    Link to comment
    Share on other sites

    • 3 weeks later...
  • Topic Author
  • ok, next time this happens can you run following in a webbrowser : "http:<ip address>:8080/log" this should give you the apps log file and with it I might be able to determine the cause.

    Edited by davanha
    Link to comment
    Share on other sites

    Probably my question has nothing to do with zenitgatekeeper but still hope if anyone has the same experience.

    I have a bluetooth speaker connected to the tablet, recently it cannot play the complete TTS statement. It skipped around 3 seconds from the beginning, feel like the BT connection is not established fast enough.

     

    For example, the original statement is : It is now 3 PM but tablet read as "ow 3 PM"

     

    Can it be resolved?

    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...