flutter_tts icon indicating copy to clipboard operation
flutter_tts copied to clipboard

ProgressionHandler is not considering SSML

Open JCKodel opened this issue 2 years ago • 0 comments

🐛 Bug Report

When speaking this text:

<speak>Texto que vem antes, então <say as="dis is a tést, em inglês">This is a test</say>, depois o texto que vai depois.</speak>

and adding this line:

_flutterTts.setProgressHandler((a, b, c, d) => print("${a} ${b} ${c} ${d}"));

this is the output:

I/flutter (14583): <speak>Texto que vem antes, então dis is a tést, em inglês, depois o texto que vai depois.
I/flutter (14583): </speak> 0 5 <spea
I/flutter (14583): <speak>Texto que vem antes, então dis is a tést, em inglês, depois o texto que vai depois.
I/flutter (14583): </speak> 6 9 >Te
I/flutter (14583): <speak>Texto que vem antes, então dis is a tést, em inglês, depois o texto que vai depois.
I/flutter (14583): </speak> 10 13 to

Expected behavior

The first call to the progression handler, last parameter, should be Texto (5 characters), not <spea. It seems the progression handler is "substringing" the text from 0 to 5, but including <speak></speak, while it should not!

The <speak> is required so (at least for Android), the TTS engine enters in SSML mode and ignores HTML tags (I'm actually reading an HTML page). It also supports pauses (and that's it, Android TTS has a clumsy SSML support!).

As a work-around for TTS speaking foreign text in portuguese voice (which is just weird), I created a function to make <say as="I will say this">instead of this</say>, so HTML shows instead of this while TTS speaks I will say this. (That's why SSML mode is required: I don't need to take special actions in the HTML renderer, only some substring tricks before _flutterTts.speak(text) =))

Reproduction steps

See above.

Configuration

Version: 3.2.2

Platform:

  • [ ] :iphone: iOS (NOT TESTED IN IOS YET)
  • [X] :robot: Android

JCKodel avatar Aug 13 '21 23:08 JCKodel