We have moved at community.getvera.com

Author Topic: Say action - different problems and solutions  (Read 22212 times)

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Say action - starting delay problem and best way to stop it
« Reply #15 on: December 30, 2012, 11:03:22 am »
I made different tests and the size of the buffer does not make a big difference.
With "test" as text, 35 ms is the best I can get for example with a 128 bytes buffer.
Increasing the buffer size does not reduce the time.

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Say action - different problems and solutions
« Reply #16 on: December 30, 2012, 11:06:28 am »
To summarize the remaining problems:

1 - Say not working as soon as the text is of a certain length
2 - avoiding the repeat and restore the old playback context at the right time

Point 2 is partially ok but could be hopefully improved.

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Say action - starting delay problem and best way to stop it
« Reply #17 on: December 30, 2012, 11:12:23 am »
I would still make the write chunks 1-4k to reduce the system CPU load, and syscalls always strive up SYS CPU levels.  Our end-to-end time Weill be bounded by URL calls etc,but we should minimize our CPU impact, during the time we are running, since these boxes are small and doing a bunch of other stuff that's impacted by our resource usage.


I made different tests and the size of the buffer does not make a big difference.
With "test" as text, 35 ms is the best I can get for example with a 128 bytes buffer.
Increasing the buffer size does not reduce the time.

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Say action - different problems and solutions
« Reply #18 on: December 31, 2012, 05:49:55 am »
Unfortunately I discovered that my solution produces a strange rendering of the end of the file.
I imagine it is due to the fact that the Sonos buffers a certain number of MP3 packets before playing them.
I think the solution would be to add real MP3 packets to the file, packets corresponding to silence.

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Say action - starting delay problem and best way to stop it
« Reply #19 on: December 31, 2012, 06:33:37 am »
@guessed: I tried to add your metadata but it does not avoid repeat of the playback.

Offline teonebello

  • Sr. Member
  • ****
  • Posts: 405
  • Karma: +0/-0
  • Macs, Home Automation, Bikers
Re: Say action - different problems and solutions
« Reply #20 on: December 31, 2012, 08:57:47 am »
Hi All,

as you are speaking about the say function, I would ask you a support.

I create a "good morning message" using the sonos say function.

As the text is long I had to split in the call.
I tried to separate using the deelay function.

...
luup.call_action(LS_SID, "SetURIToPlay", {URIToPlay = "x-rincon-mp3radio://translate.google.com/translate_tts?tl=it&q=buongiorno+famiglia+XXX.+al+momento+ci+sono+"..tostring( lul_temp ).."+gradi+e+vento+a+"..tostring( lul_wind ).."+kilometriorari"}, DEVICE_NO)
luup.call_action(MN_SID, "Play", {}, DEVICE_NO)
luup.sleep(6500)
luup.call_action(LS_SID, "SetURIToPlay", {URIToPlay = "x-rincon-mp3radio://translate.google.com/translate_tts?tl=it&q=le+previsioni+per+oggi+sono+"..tostring( lul_weather ).."+con+una+massima+di+"..tostring( lul_maxtemp ).."+gradi"}, DEVICE_NO)
luup.call_action(MN_SID, "Play", {}, DEVICE_NO)
luup.sleep(6500)
luup.call_action(LS_SID, "SetURIToPlay", {URIToPlay = "x-rincon-mp3radio://translate.google.com/translate_tts?tl=it&q=Il+sistema+di+allarme+eh+attualmente+"..tostring( lul_smart_text ).."+..+Buona+giornata"}, DEVICE_NO)
luup.call_action(MN_SID, "Play", {}, DEVICE_NO)
luup.sleep(7000)
luup.call_action(MN_SID, "Stop", {}, DEVICE_NO)

Is the delay function indicate? It seems that the scene is busy until the deelay are finished.
Is there still the limit of length in the say function? That can solve my issue.

Thank you for your support
Matteo

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Say action - different problems and solutions
« Reply #21 on: December 31, 2012, 09:22:12 am »
You encountered the problem with the URL too long. I have not checked but the way you handle it is probably a way to get it work.
But why not using the Say function ?


To come back to the Say function, we could try to cut automatically the text and finally call several times Google. We will have to find the best cut points in the text (like end of sentences) as there will be some delay between each fragment playback (time for Sonos to switch to next "web-radio" file). Other alternative would be to let the user define the cut points in the text, for example with a special character ? Then we will add other cut points only if there are too much characters.

Offline parkerc

  • Beta Testers
  • Sr. Hero Member
  • *****
  • Posts: 2479
  • Karma: +35/-48
  • Life Moves Pretty Fast....
Re: Say action - different problems and solutions
« Reply #22 on: January 04, 2013, 06:12:31 am »
Hi lolodomo

Just thinking (outloud as i do) ;)

As it seems Google TTS has a 100 character limit per request, an idea might be to have a character count next to the SAY field (or a fixed limit on that field) so people know or can see if they are going to reach the limit on any request. (There looks to be no restriction at the moment)

I'm testing your skills now but may consider having an '+' option so you can add extra SAY commands, then if all I requested at almost the same time, it might be possible to play them in order with little to no delay.

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Say action - different problems and solutions
« Reply #23 on: January 05, 2013, 05:32:19 am »
Hi lolodomo

Just thinking (outloud as i do) ;)

As it seems Google TTS has a 100 character limit per request

When typing my text directly in http://translate.google.fr/?hl=fr I have not the limit I get when using the API. Isn't the web site using the API ?

Quote
an idea might be to have a character count next to the SAY field (or a fixed limit on that field) so people know or can see if they are going to reach the limit on any request. (There looks to be no restriction at the moment)

You mean the field in the UI (player tab) ? As it is Javascript, it is probably possible. But that would not help the users using the other ways (scene) to use Say. So the idea is more to find a global solution, not something limited to a particular usage.

Quote
I'm testing your skills now but may consider having an '+' option so you can add extra SAY commands, then if all I requested at almost the same time, it might be possible to play them in order with little to no delay.

Sorry I don't understand your request.

Offline Brientim

  • Sr. Hero Member
  • ******
  • Posts: 2497
  • Karma: +78/-7
Re: Say action - different problems and solutions
« Reply #24 on: January 05, 2013, 06:12:18 am »
I would suggest the last comment was to enable a "+" which would provide another input for addition text.

However, if the API is limited 100 characters, it might be a better option to substring at the last complete word before the 100 character limit and send it in multile blocks.

Offline parkerc

  • Beta Testers
  • Sr. Hero Member
  • *****
  • Posts: 2479
  • Karma: +35/-48
  • Life Moves Pretty Fast....
Re: Say action - different problems and solutions
« Reply #25 on: January 05, 2013, 07:13:14 am »
Thanks Brientim,

Yes that was the idea, to have the ability to do multiple requests, that could then be played in order (maybe added in sequence to the queue).

@lolodomo

As for the 100 character limit - check this out http://viralpatel.net/blogs/the-unofficial-google-text-to-speech-api/. I interpret this to mean that requests not made directly into the google tts page have a limit set on them..

Offline Brientim

  • Sr. Hero Member
  • ******
  • Posts: 2497
  • Karma: +78/-7
Re: Say action - different problems and solutions
« Reply #26 on: January 05, 2013, 07:18:32 am »

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Say action - different problems and solutions
« Reply #27 on: January 05, 2013, 07:54:31 am »
The limit at 100 characters is exactly what I have with my initial example.
The good news is that the limit is absolutely not dependent on the way we call Google.
So we have now just to cut a more than 100 characters in several blocks.

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Say action - different problems and solutions
« Reply #28 on: January 05, 2013, 08:09:02 am »
Something like this chain of thought.
http://stackoverflow.com/questions/10189860/controlling-input-for-google-tts-api

My question is then: can we concate all downloaded files to make one unique file ?
Some tests have to be done to check if concatening two files having the same sampling rate is ok for playing by Sonos.
« Last Edit: January 05, 2013, 08:25:41 am by lolodomo »

Offline lolodomo

  • Moderator
  • Master Member
  • *****
  • Posts: 3484
  • Karma: +74/-10
Re: Say action - different problems and solutions
« Reply #29 on: January 05, 2013, 08:20:38 am »
Something like this chain of thought.
http://stackoverflow.com/questions/10189860/controlling-input-for-google-tts-api

My question is then: can we concate all downloaded files to make one unique file ?
Some tests have to be done to check if concatening two files having the same sampling rate is ok for playing by Sonos.

The answer is yes, I just made a positive test 8)
« Last Edit: January 05, 2013, 08:25:51 am by lolodomo »