To Pause and to resume TextToSpeech

Is it possible to pause and resume reading “TextToSpeech” as if it were a player?

What you can do with TTS using App Inventor 2 is described in TextToSpeech

There isn’t a pause event or method, so you can not pause and resume.

Unfortunately, the way the Android TTS interface is designed makes it next to impossible to implement a pause/resume feature, at least not without a lot of extra bookkeeping. The two main APIs it provides are a speak() call and a stop() call. The first enqueues a string to be spoken and the latter stops speaking and removes any remaining, unspoken utterances. Now, there is a mechanism by which one can get updates of what parts of the string are being spoken, such as to make a text highlighting utility, and so one might be able to use that to track progress. The Pause operation then would have to save the current point of speech in the original text and the Resume operation would need to construct a new string to be spoke that is just the remaining text. If the interval between pause/resume is quite short then I imagine there will also be an appearance of “jittering” because if you stop in the middle of a word you’d need to probably resume with the word or the following word, so it’s not as fluid as pausing an audio recording.

A post was split to a new topic: Is it possible to generate a file larger than 10Mb?

Hi, I am new to this community.
I am very happy to be here.

I have worked on this problem ( how to pause or resume the TTS component ) for quite a long time and have successfully found a solution. Yes, there isn’t any direct block that can be used for this purpose. However, built-in blocks can do this job.

I am so sorry as I cannot disclose the information here because I have recently published a new course based on this topic. So, please watch this course for solution :point_down: :point_down:

I have been using App Inventor and similar platforms since 2016. And I am very happy to know that App Inventor has its own community. I am also very excited about App Inventor for IOS.

Thank you,

@Eenjeen

A bit like giving me a free car but with no keys !!

:sweat_smile: :rofl:
Ok I will give a free coupon (unlimited redemptions) but, this will be active only for 3 days from now:

Please give feedback (on Udemy) after you have watched it.

Where is the stop() API call exposed? Thanks.

— dcp

Somehow in my testing I missed the fact that TextToSpeech.Start interrupts any speaking, so giving it an empty message effectively stops the speech. That didn't appear to be working, but it definitely is (on Android, at least).