Skip to content

Most visited

Recently visited

navigation
Added in API level 15

UtteranceProgressListener

public abstract class UtteranceProgressListener
extends Object

java.lang.Object
   ↳ android.speech.tts.UtteranceProgressListener


Listener for events relating to the progress of an utterance through the synthesis queue. Each utterance is associated with a call to speak(CharSequence, int, Bundle, String) or synthesizeToFile(CharSequence, Bundle, File, String) with an associated utterance identifier, as per KEY_PARAM_UTTERANCE_ID. The callbacks specified in this method can be called from multiple threads.

Summary

Public constructors

UtteranceProgressListener()

Public methods

abstract void onDone(String utteranceId)

Called when an utterance has successfully completed processing.

abstract void onError(String utteranceId)

This method was deprecated in API level 21. Use onError(String, int) instead

void onError(String utteranceId, int errorCode)

Called when an error has occurred during processing.

abstract void onStart(String utteranceId)

Called when an utterance "starts" as perceived by the caller.

void onStop(String utteranceId, boolean interrupted)

Called when an utterance has been stopped while in progress or flushed from the synthesis queue.

Inherited methods

From class java.lang.Object

Public constructors

UtteranceProgressListener

Added in API level 15
UtteranceProgressListener ()

Public methods

onDone

Added in API level 15
void onDone (String utteranceId)

Called when an utterance has successfully completed processing. All audio will have been played back by this point for audible output, and all output will have been written to disk for file synthesis requests. This request is guaranteed to be called after onStart(String).

Parameters
utteranceId String: the utterance ID of the utterance.

onError

Added in API level 15
void onError (String utteranceId)

This method was deprecated in API level 21.
Use onError(String, int) instead

Called when an error has occurred during processing. This can be called at any point in the synthesis process. Note that there might be calls to onStart(String) for specified utteranceId but there will never be a call to both onDone(String) and onError(String) for the same utterance.

Parameters
utteranceId String: the utterance ID of the utterance.

onError

Added in API level 21
void onError (String utteranceId, 
                int errorCode)

Called when an error has occurred during processing. This can be called at any point in the synthesis process. Note that there might be calls to onStart(String) for specified utteranceId but there will never be a call to both onDone(String) and onError(String, int) for the same utterance. The default implementation calls onError(String).

Parameters
utteranceId String: the utterance ID of the utterance.
errorCode int: one of the ERROR_* codes from TextToSpeech

onStart

Added in API level 15
void onStart (String utteranceId)

Called when an utterance "starts" as perceived by the caller. This will be soon before audio is played back in the case of a speak(CharSequence, int, Bundle, String) or before the first bytes of a file are written to storage in the case of synthesizeToFile(CharSequence, Bundle, File, String).

Parameters
utteranceId String: the utterance ID of the utterance.

onStop

Added in API level 23
void onStop (String utteranceId, 
                boolean interrupted)

Called when an utterance has been stopped while in progress or flushed from the synthesis queue. This can happen if a client calls stop() or uses QUEUE_FLUSH as an argument with the speak(CharSequence, int, Bundle, String) or synthesizeToFile(CharSequence, Bundle, File, String) methods.

Parameters
utteranceId String: the utterance ID of the utterance.
interrupted boolean: If true, then the utterance was interrupted while being synthesized and its output is incomplete. If false, then the utterance was flushed before the synthesis started.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.