Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when play google TTS 2 or 3 times, it crashes #395

Open
lioujj opened this issue May 19, 2021 · 5 comments
Open

when play google TTS 2 or 3 times, it crashes #395

lioujj opened this issue May 19, 2021 · 5 comments

Comments

@lioujj
Copy link

lioujj commented May 19, 2021

Hi
When I use AudioFileSourceICYStream to play google TTS voice 2 or 3 times, it will crash!
I try to increase the buffer size, but it still not works.

TTS code here:
i2sFile = new AudioFileSourceHTTPStream("http://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=en&q="+YourTextHere);

I use a DAC MAX98357A.
Thanks!

@JJ-Concept
Copy link

Same issue here. ESP32 completely freezes after playing google tts. It had worked for half a year perfectly fine but the same problem occurs now on two different devices here that use esp8266audio to play google tts.

Error (several of these):
STATUS(mp3) '257' = 'Decoding error 'lost synchronization' at byte offset 33265'

Then it shows "Running for xxx ms" two times (the second one appearing after more than a second) and then the ESP32 completely freezes. No further output on serial, no reaction anymore...

Would be cool to get this error fixed as i prefer google tts instead of esp8266sam becuase it talks more clearly and supports more than only english language ;-)

Thanks

@schmurtzm
Copy link

schmurtzm commented Dec 20, 2021

Same problem here : I play one google tts mp3 then it hang immediately at the end of the sound.
I tried :

  • with esp8266 (wemos D1, no dac)
  • with ESP32 (with "dac" and "no dac")
  • with "out->SetRate(22050);"

Always with the same result : it play correctly but no more response from the ESP and no stack trace...
May be a debugger with ESP32 could be useful for better investigation ?

@schmurtzm
Copy link

schmurtzm commented Dec 20, 2021

Edit : some additional test & information :

  • if you stop during the playing of the streamed file there is no hang of the ESP.
  • The ESP doesn't crash, continue to being "ping" and after few minutes it gives back the hand.
  • If I use the same mp3 from google in SPIFFS or on another web server -> no problem at all

So there is something which hang in the library (may be in "bool AudioGeneratorMP3::loop()" ? ) when playing specific url from google TTS...

@schmurtzm
Copy link

schmurtzm commented Dec 29, 2021

Hi, easy way to reproduce the bug : Take "StreamMP3FromHTTP" example, and replace :
const char *URL="http://kvbstreams.dyndns.org:8000/wkvi-am";
with
const char *URL="http://translate.google.com/translate_tts?ie=UTF-8&q=bonjour&tl=fr&client=tw-ob&ttsspeed=1";

This is a record of the sound that I obtain.

Output of the StatusCallback :

...Connecting to WiFi
Connected
+0 0x3ffb1ed8
Running for 4334 ms...
STATUS(buffer) '2' = 'Refilling buffer'
STATUS(mp3) '257' = 'Decoding error 'lost synchronization' at byte offset 2048'
STATUS(mp3) '257' = 'Decoding error 'lost synchronization' at byte offset 2049'
STATUS(mp3) '257' = 'Decoding error 'lost synchronization' at byte offset 2050'
STATUS(mp3) '257' = 'Decoding error 'lost synchronization' at byte offset 2051'
STATUS(mp3) '257' = 'Decoding error 'lost synchronization' at byte offset 2052'

... And after a long time (about 3 minutes), the hang is released (if we stop the output before the end of the file there is no hang) :

STATUS(buffer) '3' = 'Buffer underflow'
STATUS(buffer) '2' = 'Refilling buffer'
STATUS(buffer) '3' = 'Buffer underflow'
STATUS(buffer) '2' = 'Refilling buffer'
STATUS(buffer) '3' = 'Buffer underflow'
Running for 244596 ms...
STATUS(buffer) '2' = 'Refilling buffer'
STATUS(buffer) '3' = 'Buffer underflow'
STATUS(buffer) '2' = 'Refilling buffer'
STATUS(buffer) '3' = 'Buffer underflow'
STATUS(buffer) '2' = 'Refilling buffer'
STATUS(buffer) '3' = 'Buffer underflow'
STATUS(buffer) '2' = 'Refilling buffer'
STATUS(buffer) '3' = 'Buffer underflow'
STATUS(buffer) '2' = 'Refilling buffer'
STATUS(buffer) '3' = 'Buffer underflow'
STATUS(buffer) '2' = 'Refilling buffer'
STATUS(buffer) '3' = 'Buffer underflow'
STATUS(buffer) '2' = 'Refilling buffer'
STATUS(buffer) '3' = 'Buffer underflow'
STATUS(buffer) '2' = 'Refilling buffer'
STATUS(buffer) '3' = 'Buffer underflow'
STATUS(buffer) '2' = 'Refilling buffer'
STATUS(buffer) '3' = 'Buffer underflow'
STATUS(buffer) '2' = 'Refilling buffer'
STATUS(buffer) '3' = 'Buffer underflow'
STATUS(buffer) '2' = 'Refilling buffer'
STATUS(buffer) '3' = 'Buffer underflow'
STATUS(buffer) '2' = 'Refilling buffer'
STATUS(buffer) '3' = 'Buffer underflow'
STATUS(mp3) '1' = 'Decoding error 'input buffer too small (or EOF)' at byte offset'
MP3:ERROR_BUFLEN 0
STATUS(buffer) '2' = 'Refilling buffer'
STATUS(buffer) '3' = 'Buffer underflow'
MP3 done
MP3 done
MP3 done

The codec used by Google TTS seems classic :
image

@FedericoBusero You have resolved a similar issue with RTTTL recently (thanks for that !) , do you have an idea for this one too ?
Having good and multilingual TTS on ESP is a killer feature 😉

@schmurtzm
Copy link

Managing Google TTS seems more complex than what I was thinking...
I found this great I2S library which support Google TTS: ESP32-audioI2S

As you can see here the author has made a complex function to use Google TTS. This could be a good source of inspiration to make a new AudioFileSourceGoogleTTS.h 😅

Interesting facts : I also tested to play Google TTS on this library without using this specific function, just with the URL of Google Translate and the result was similar to ESP8266Audio : at the end of the play there is a buffer problem. It doesn't hang the ESP on this library but it means that Google TTS send the mp3 file in a particular way which require more work than a classic mp3 stream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants