OnUtteranceCompleted not called unless you specify an utterance id?

1,283 views
Skip to first unread message

GregM

unread,
Oct 11, 2009, 2:37:16 PM10/11/09
to TTS-for-Android
Hi,

I wasted two hours tracking this down.

If you just do this:
int result = tts.setOnUtteranceCompletedListener(whenTextDone);
tts.speak(say, TextToSpeech.QUEUE_FLUSH, params);

onUtteranceComplete doesn't get called, event thought result ==
SUCCESS.

You have to add a dummy parameter to get the darn thing to call your
onUtteranceCompleted.

int result = tts.setOnUtteranceCompletedListener(whenTextDone);
HashMap<String, String> params = new HashMap<String, String>();
params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "theUtId");
tts.speak(say, TextToSpeech.QUEUE_FLUSH, params);

Please fix this some day.

CLC

unread,
Oct 12, 2009, 3:34:20 PM10/12/09
to TTS-for-Android
Hi Greg, this is working as intended.

http://developer.android.com/reference/android/speech/tts/TextToSpeech.OnUtteranceCompletedListener.html
"Interface definition of a callback to be invoked indicating the
TextToSpeech engine has completed synthesizing an utterance with an
utterance ID set. "
"Called to signal the completion of the synthesis of the utterance
that was identified with the string parameter."

The parameter you are adding is actually NOT intended as just a dummy
parameter; it plays a useful role as it identifies which utterance has
completed. For example, if you queue up "Hello.", "How are you
today?", and "My name is Greg." in rapid succession, then there will
be 3 utterances that are completed. The only way for you to know which
utterance was just completed (short of counting how many utterances
you sent vs how many completions you are getting yourself) is to get
something that identifies which utterance it is.

This could be especially useful if you are working on something like
say an ebook reader. You probably only want to queue up a few strings,
and then read more out of the text and queue it as the earlier
utterances get completed. If your source is online, then fetching a
page or so ahead is probably a good idea too. Furthermore, if you are
doing any textual highlighting you would also want to move the
highlight along. You can give each utterance a unique ID so that you
can track progress easily.

If on the other hand, you only have one utterance at any given time,
then yes, you can use it as a dummy parameter and always give it the
same thing.

-Charles

GregM

unread,
Oct 14, 2009, 7:57:37 PM10/14/09
to TTS-for-Android
I understand that it can be useful for the application you are talking
about. My point is that the method's behavior is unintuitive. Is there
any reason to force us to put in an utterance id? If so, then I think
it should be part of the method signature rather than within the Map
of parameters.

On Oct 12, 3:34 pm, CLC <clchen+...@google.com> wrote:
> Hi Greg, this is working as intended.
>
> http://developer.android.com/reference/android/speech/tts/TextToSpeec...

Markus Gursch

unread,
Oct 28, 2009, 9:51:47 AM10/28/09
to TTS-for-Android
hello i have a similar problem, but i get result
at .setOnUtteranceCompletedListener(whenTextDone) is equal
TextToSpeech.ERROR ( -1 )

what are issues for that??

t2s works fine, but the event will not be fired.

Reply all
Reply to author
Forward
0 new messages