10

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.'

Rookie
  • 8,660
  • 17
  • 58
  • 91

2 Answers2

4

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

Community
  • 1
  • 1
hasanghaforian
  • 13,858
  • 11
  • 76
  • 167
  • yea..Thats what i thought..I will set utterencecompletedlistener after period(.) and will note the index of each period. – Rookie Sep 26 '12 at 11:57
  • @raghav: please let me know..how you did ? – Ketan Ahir Feb 20 '13 at 10:53
  • This seems the only possible way to identify a spoken word. But what are the drawbacks? Does the Speech suffer in quality if each word is spoken individually? Does it have performance issues if you queue up each word instead of the whole sentence? – mcanti May 22 '13 at 12:05
  • 1
    Unfortunately the quality of the output of synthesis of a set of single words is far worse than the quality of a synthesis of the whole text portion (sentence / paragraph) at once.. it basically sounds like saying word, pause, word, pause - no connection between them. – Dale Cooper May 09 '17 at 10:03
  • @Madhav_nimavat Sorry, I did not write code for this. I only proposed a way. – hasanghaforian Jul 21 '17 at 13:02
  • @hasanghaforian i'm not asking to write code for me but at least try to elaborate it so i can understand because i had never work with TTS so. – Madhav_nimavat Jul 21 '17 at 13:04
  • @hasanghaforian setOnUtteranceCompletedListener() not call on single word over i tried with it – Madhav_nimavat Jul 22 '17 at 04:13
  • give me sample demo @hasanghaforian – mr.hir Nov 05 '19 at 04:49
0
Put it in handler.Create two handler one for to add ;
tts1.speak("your text to speech", TextToSpeech.QUEUE_FLUSH, null);
  viewItem.setBackgroundColor(Color.RED);
view item means your textview....

and add another handler...
and make your view as transparent..
  viewItem.setBackgroundColor(Color.TRANSPARENT);


it's work for me perfectly....
Sunisha Guptan
  • 1,555
  • 17
  • 44