# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Ctors | Methods | Inherited Methods

# 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 `TextToSpeech#speak` or `TextToSpeech#synthesizeToFile` with an associated utterance identifier, as per `TextToSpeech.Engine#KEY_PARAM_UTTERANCE_ID`. The callbacks specified in this method can be called from multiple threads.

## Summary

### Public constructors
`UtteranceProgressListener()`

### Public methods
`void` | `onAudioAvailable(String utteranceId, byte[] audio)` This is called when a chunk of audio is ready for consumption.
`void` | `onBeginSynthesis(String utteranceId, int sampleRateInHz, int audioFormat, int channelCount)` Called when the TTS engine begins to synthesize the audio for a request.
`abstract void` | `onDone(String utteranceId)` Called when an utterance has successfully completed processing.
`abstract void` | `onError(String utteranceId)` This method is deprecated. Use `onError(java.lang.String, int)` instead
`void` | `onError(String utteranceId, int errorCode)` Called when an error has occurred during processing.
`void` | `onRangeStart(String utteranceId, int start, int end, int frame)` This is called when the TTS service is about to speak the specified range of the utterance with the given utteranceId.
`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`
`Object` | `clone()` Creates and returns a copy of this object.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`final Class<?>` | `getClass()` Returns the runtime class of this `Object`.
`int` | `hashCode()` Returns a hash code value for the object.
`final void` | `notify()` Wakes up a single thread that is waiting on this object's monitor.
`final void` | `notifyAll()` Wakes up all threads that are waiting on this object's monitor.
`String` | `toString()` Returns a string representation of the object.
`final void` | `wait(long timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.

## Public constructors

### UtteranceProgressListener

    public UtteranceProgressListener ()

## Public methods

### onAudioAvailable

    public void onAudioAvailable (String utteranceId,
                    byte[] audio)

This is called when a chunk of audio is ready for consumption.

The audio parameter is a copy of what will be synthesized to the speakers (when synthesis was initiated with a `TextToSpeech#speak` call) or written to the file system (for `TextToSpeech#synthesizeToFile`). The audio bytes are delivered in one or more chunks; if `onDone(String)` or `onError(String)` is called all chunks have been received.

The audio received here may not be played for some time depending on buffer sizes and the amount of items on the synthesis queue.

Parameters
`utteranceId` | `String`: The utterance ID of the utterance.
`audio` | `byte`: A chunk of audio; the format can be known by listening to `onBeginSynthesis(java.lang.String, int, int, int)`.

### onBeginSynthesis

    public void onBeginSynthesis (String utteranceId,
                    int sampleRateInHz,
                    int audioFormat,
                    int channelCount)

Called when the TTS engine begins to synthesize the audio for a request.

It provides information about the format of the byte array for subsequent `onAudioAvailable(String, byte[])` calls.

This is called when the TTS engine starts synthesizing audio for the request. If an application wishes to know when the audio is about to start playing, {#onStart(String)} should be used instead.

Parameters
`utteranceId` | `String`: The utterance ID of the utterance.
`sampleRateInHz` | `int`: Sample rate in hertz of the generated audio.
`audioFormat` | `int`: Audio format of the generated audio. Should be one of `AudioFormat#ENCODING_PCM_8BIT`, `AudioFormat#ENCODING_PCM_16BIT` or `AudioFormat#ENCODING_PCM_FLOAT`.
`channelCount` | `int`: The number of channels.

### onDone

    public abstract 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(java.lang.String)`.

Parameters
`utteranceId` | `String`: The utterance ID of the utterance.

### onError

    public abstract void onError (String utteranceId)

This method is deprecated.
Use `onError(java.lang.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(java.lang.String)` for specified utteranceId but there will never be a call to both `onDone(java.lang.String)` and `onError(java.lang.String)` for the same utterance.

Parameters
`utteranceId` | `String`: The utterance ID of the utterance.

### onError

    public 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(java.lang.String)` for specified utteranceId but there will never be a call to both `onDone(java.lang.String)` and `onError(java.lang.String, int)` for the same utterance. The default implementation calls `onError(java.lang.String)`.

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

### onRangeStart

    public void onRangeStart (String utteranceId,
                    int start,
                    int end,
                    int frame)

This is called when the TTS service is about to speak the specified range of the utterance with the given utteranceId.

This method is called when the audio is expected to start playing on the speaker. Note that this is different from `onAudioAvailable(String, byte[])` which is called as soon as the audio is generated.

This information can be used, for example, to highlight ranges of the text while it is spoken.

Only called if the engine supplies timing information by calling `SynthesisCallback#rangeStart(int, int, int)`.

Parameters
`utteranceId` | `String`: Unique id identifying the synthesis request.
`start` | `int`: The start index of the range in the utterance text.
`end` | `int`: The end index of the range (exclusive) in the utterance text.
`frame` | `int`: The position in frames in the audio of the request where this range is spoken.

### onStart

    public abstract 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 `TextToSpeech#speak` or before the first bytes of a file are written to the file system in the case of `TextToSpeech#synthesizeToFile`.

Parameters
`utteranceId` | `String`: The utterance ID of the utterance.

### onStop

    public 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 `TextToSpeech#stop()` or uses `TextToSpeech#QUEUE_FLUSH` as an argument with the `TextToSpeech#speak` or `TextToSpeech#synthesizeToFile` 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.

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*