Search code examples
androidtext-to-speech

Highlight the current word that TTS engine is speaking


I'm working on Text to speech application but I encounter a problem that I couldn't know the present word that TTS is speaking. Is there any way to find this.?

For Example: If TTS is speaking this string: Questions that may already have your answer and when it reaches 'already', how can I highlight 'already.'


Solution

  • I propose that use sequence of TextToSpeech.speak():

      • start speaking first word.
      • highlight first word.
      • detect that synthesizing of first word has finished.
      • start speaking second word.
      • highlight second word.
      • detect that synthesizing of second word has finished.
      • and so on ...

    Now it only remains How to detect that synthesizing of a word has finished?Use TextToSpeech.setOnUtteranceCompletedListener() to detect utterance has completed.

    You can see these pages for more details:
    How to know when TTS is finished?
    An introduction to Text-To-Speech in Android