JSAPI 2.0

javax.speech.synthesis
Class SynthesizerEvent

Object
  extended by SpeechEvent
      extended by EngineEvent
          extended by SynthesizerEvent

public class SynthesizerEvent
extends EngineEvent

Event issued by a Synthesizer to indicate a change in state or other activity. A SynthesizerEvent is issued to each SynthesizerListener attached to a Synthesizer using the addSynthesizerListener method in the Synthesizer interface.

See Also:
Synthesizer, SynthesizerListener, addSynthesizerListener, removeSynthesizerListener

Field Summary
static int DEFAULT_MASK
          The default mask for events in this class.
static int QUEUE_EMPTIED
          Event issued when the Synthesizer output queue has emptied and the Synthesizer has changed to the QUEUE_EMPTY state.
static int QUEUE_UPDATED
          Event issued when the Synthesizer output queue updates.
static int SYNTHESIZER_BUFFER_READY
          Event issued once audio output begins to flow normally after a gap.
static int SYNTHESIZER_BUFFER_UNFILLED
          Event issued when a gap in synthesis output is detected.
 
Fields inherited from class EngineEvent
ENGINE_ALLOCATED, ENGINE_ALLOCATING_RESOURCES, ENGINE_DEALLOCATED, ENGINE_DEALLOCATING_RESOURCES, ENGINE_DEFOCUSED, ENGINE_ERROR, ENGINE_FOCUSED, ENGINE_PAUSED, ENGINE_RESUMED
 
Fields inherited from class SpeechEvent
DISABLE_ALL, ENABLE_ALL
 
Constructor Summary
SynthesizerEvent(Synthesizer source, int id, long oldEngineState, long newEngineState, Throwable problem, boolean topOfQueueChanged)
          Constructs a SynthesizerEvent to indicate a change in state or other activity.
 
Method Summary
 boolean isTopOfQueueChanged()
          Returns the change status of the top of the Synthesizer output queue.
 String paramString()
          Returns a parameter String that contains the event ID in text form.
 String toString()
          Returns a printable String.
 
Methods inherited from class EngineEvent
getEngineError, getNewEngineState, getOldEngineState
 
Methods inherited from class SpeechEvent
getId, getSource
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

QUEUE_EMPTIED

public static final int QUEUE_EMPTIED
Event issued when the Synthesizer output queue has emptied and the Synthesizer has changed to the QUEUE_EMPTY state. The queue may become empty because output completes for all queued items or because the items have been cancelled.

The isTopOfQueueChanged method always returns true for this event.

This event follows the SPEAKABLE_ENDED or SPEAKABLE_CANCELLED event that removed the last item from the queue.

See Also:
QUEUE_UPDATED, QUEUE_EMPTY, isTopOfQueueChanged(), SPEAKABLE_ENDED, SPEAKABLE_CANCELLED, cancel(), cancel(int), cancelAll(), DEFAULT_MASK, Constant Field Values

QUEUE_UPDATED

public static final int QUEUE_UPDATED
Event issued when the Synthesizer output queue updates. This event may indicate a change in Synthesizer state from QUEUE_EMPTY to QUEUE_NOT_EMPTY. This event may also occur in the QUEUE_NOT_EMPTY state without changing state.

The Synthesizer output queue updates when

If the queue empties, a QUEUE_EMPTIED event is issued rather than this event.

The isTopOfQueueChanged method returns true if the top item on the queue has changed.

This event follows the SPEAKABLE_ENDED or SPEAKABLE_CANCELLED event that updated the queue.

This event is not enabled by default. It may be enabled with setEngineMask.

See Also:
QUEUE_EMPTIED, QUEUE_EMPTY, QUEUE_NOT_EMPTY, isTopOfQueueChanged(), SPEAKABLE_ENDED, SPEAKABLE_CANCELLED, cancel(), cancel(int), cancelAll(), DEFAULT_MASK, setEngineMask, Constant Field Values

SYNTHESIZER_BUFFER_UNFILLED

public static final int SYNTHESIZER_BUFFER_UNFILLED
Event issued when a gap in synthesis output is detected. This can happen after synthesis output has begun and the Synthesizer output queue contains more items to synthesize, but the Synthesizer's internal audio buffer is empty.

This can indicate that the Synthesizer is not keeping up with real-time requirements to ensure that the generated audio plays continuously. If significant gaps occur, an application may wish to resubmit the affected items.

A SYNTHESIZER_BUFFER_READY event is issued once audio begins to flow normally.

See Also:
SYNTHESIZER_BUFFER_READY, Constant Field Values

SYNTHESIZER_BUFFER_READY

public static final int SYNTHESIZER_BUFFER_READY
Event issued once audio output begins to flow normally after a gap. Each SYNTHESIZER_BUFFER_UNFILLED event is followed by this event. SYNTHESIZER_BUFFER_UNFILLED provides more detail about gaps in synthesis.

See Also:
SYNTHESIZER_BUFFER_UNFILLED, Constant Field Values

DEFAULT_MASK

public static final int DEFAULT_MASK
The default mask for events in this class.

The following events, in addition to events in EngineEvent.DEFAULT_MASK, are delivered by default: QUEUE_EMPTIED, SYNTHESIZER_BUFFER_UNFILLED, and SYNTHESIZER_BUFFER_READY.

The QUEUE_UPDATED event may be enabled if desired with setEngineMask.

See Also:
EngineEvent.DEFAULT_MASK, QUEUE_EMPTIED, QUEUE_UPDATED, SYNTHESIZER_BUFFER_UNFILLED, SYNTHESIZER_BUFFER_READY, setEngineMask, Constant Field Values
Constructor Detail

SynthesizerEvent

public SynthesizerEvent(Synthesizer source,
                        int id,
                        long oldEngineState,
                        long newEngineState,
                        Throwable problem,
                        boolean topOfQueueChanged)
                 throws IllegalArgumentException
Constructs a SynthesizerEvent to indicate a change in state or other activity.

oldEngineState and newEngineState are 0 if the Engine states are unknown or undefined.

problem applies to ENGINE_ERROR and must be null for other events.

The topOfQueueChanged flag applies to QUEUE_UPDATED and QUEUE_EMPTIED. It is true if the top item on the Synthesizer output queue changed. This flag must be false for all other events.

Parameters:
source - the Synthesizer that issued the event
id - the event identifier
oldEngineState - the Engine state prior to this event
newEngineState - the Engine state following this event
problem - non-null for ENGINE_ERROR, otherwise null
topOfQueueChanged - boolean flag for QUEUE_UPDATED and QUEUE_EMPTIED, otherwise false
Throws:
IllegalArgumentException - if called with an inappropriate event identifier or an invalid parameter value
See Also:
isTopOfQueueChanged, ENGINE_ERROR, QUEUE_EMPTIED, QUEUE_UPDATED, SYNTHESIZER_BUFFER_UNFILLED, SYNTHESIZER_BUFFER_READY
Method Detail

isTopOfQueueChanged

public boolean isTopOfQueueChanged()
Returns the change status of the top of the Synthesizer output queue. The value is true when the top item in the Synthesizer output queue has changed.

This method applies to the QUEUE_UPDATED and QUEUE_EMPTIED events. For all other events, this method returns false.

Returns:
true when the top of the Synthesizer output queue has changed
See Also:
QUEUE_UPDATED, QUEUE_EMPTIED

paramString

public String paramString()
Returns a parameter String that contains the event ID in text form.

This method is useful for event-logging and for debugging. The method toString may provide more detail.

Overrides:
paramString in class EngineEvent
Returns:
a String that contains the event ID in text form
See Also:
toString

toString

public String toString()
Returns a printable String. Useful for event-logging and debugging.

The method paramString also provides printable information.

Specified by:
toString in class SpeechEvent
Returns:
A printable string.
See Also:
paramString

JSAPI 2.0

JavaTM Speech API 2.0, Final Release v2.0.6.
© 2008, Conversay and Sun Microsystems.

Free Web Hosting