Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pause android.speech.tts.TextToSpeech?

Tags:

I'm playing text with android TTS - android.speech.tts.TextToSpeech

I use: TextToSpeech.speak to speak and .stop to stop. Is there a way to pause the text also?

like image 942
Jas Avatar asked Feb 11 '11 14:02

Jas


People also ask

How do you pause text to speech on Android?

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.

What is text to speech output in Android?

With text-to-speech, your device can convert text input and play audio aloud.


1 Answers

The TTS SDK doesn't have any pause functionality that I know of. But you could use synthesizeToFile() to create an audio file that contains the TTS output. Then, you would use a MediaPlayer object to play, pause, and stop playing the file. Depending on how long the text string is, it might take a little longer for audio to be produced because the synthesizeToFile() function would have to complete the entire file before you could play it, but this delay should be acceptable for most applications.

like image 191
Aaron C Avatar answered Oct 24 '22 00:10

Aaron C