com.sun.speech.engine.synthesis
Class BaseSynthesizerQueueItem

java.lang.Object
  extended byjavax.speech.synthesis.SynthesizerQueueItem
      extended bycom.sun.speech.engine.synthesis.BaseSynthesizerQueueItem
All Implemented Interfaces:
SpeechEventDispatcher
Direct Known Subclasses:
FreeTTSSynthesizerQueueItem, TextSynthesizerQueueItem

public class BaseSynthesizerQueueItem
extends javax.speech.synthesis.SynthesizerQueueItem
implements SpeechEventDispatcher

Extends the JSAPI 1.0 SynthesizerQueueItem with handling for JSML, generation of engine-specific text, and other features.


Field Summary
protected static int itemNumber
          Global count of queue items used for debug.
protected  BaseSynthesizer synth
          Synthesizer that has queued this item.
protected  int thisItemNumber
          Count for this item used for debug.
 
Fields inherited from class javax.speech.synthesis.SynthesizerQueueItem
listener, plainText, source, text
 
Constructor Summary
BaseSynthesizerQueueItem()
          Class constructor.
 
Method Summary
 void cancelled()
          indicate that this item has been cancelled
 void completed()
          indicate that this item has been completed
 void dispatchSpeechEvent(javax.speech.SpeechEvent event)
          Dispatches a SpeechEvent.
 void fireMarkerReached(javax.speech.synthesis.SpeakableEvent event)
          Utility function that sends a MARKER_REACHED event to all speakable listeners.
 void fireSpeakableCancelled(javax.speech.synthesis.SpeakableEvent event)
          Utility function that sends a SPEAKABLE_CANCELLED event to all speakable listeners.
 void fireSpeakableEnded(javax.speech.synthesis.SpeakableEvent event)
          Utility function that sends a SPEAKABLE_ENDED event to all speakable listeners.
 void fireSpeakablePaused(javax.speech.synthesis.SpeakableEvent event)
          Utility function that sends a SPEAKABLE_PAUSED event to all speakable listeners.
 void fireSpeakableResumed(javax.speech.synthesis.SpeakableEvent event)
          Utility function that sends a SPEAKABLE_RESUMED event to all speakable listeners.
 void fireSpeakableStarted(javax.speech.synthesis.SpeakableEvent event)
          Utility function that sends a SPEAKABLE_STARTED event to all speakable listeners.
 void fireTopOfQueue(javax.speech.synthesis.SpeakableEvent event)
          Utility function that sends a TOP_OF_QUEUE event to all speakable listeners.
 void fireWordStarted(javax.speech.synthesis.SpeakableEvent event)
          Utility function that sends a WORD_STARTED event to all speakable listeners.
protected  org.w3c.dom.Document getDocument()
          Gets the DOM document for this object.
 int getItemNumber()
          Gets the item number for debug purposes only.
protected  boolean isCancelled()
          determines if this queue item has been cancelled
 boolean isCompleted()
          returns true if this queue item has been processed.
 void postMarkerReached(java.lang.String text, int markerType)
          Utility function that generates a MARKER_REACHED event and posts it to the event queue.
 void postSpeakableCancelled()
          Utility function that generates a SPEAKABLE_CANCELLED event and posts it to the event queue.
 void postSpeakableEnded()
          Utility function that generates a SPEAKABLE_ENDED event and posts it to the event queue.
 void postSpeakablePaused()
          Utility function that generates a SPEAKABLE_PAUSED event and posts it to the event queue.
 void postSpeakableResumed()
          Utility function that generates a SPEAKABLE_RESUMED event and posts it to the event queue.
 void postSpeakableStarted()
          Utility function that generates a SPEAKABLE_STARTED event and posts it to the event queue.
 void postTopOfQueue()
          Utility function that generates a TOP_OF_QUEUE event and posts it to the event queue.
 void postWordStarted(java.lang.String text, int wordStart, int wordEnd)
          Utility function that generates a WORD_STARTED event and posts it to the event queue.
protected  void setData(BaseSynthesizer synth, javax.speech.synthesis.Speakable source, javax.speech.synthesis.SpeakableListener listener)
          Sets queue item data with a Speakable source.
protected  void setData(BaseSynthesizer synth, java.lang.String source, boolean plainText, javax.speech.synthesis.SpeakableListener listener)
          Sets queue item data with a String source that is either plain text or JSML.
protected  void setData(BaseSynthesizer synth, java.net.URL source, javax.speech.synthesis.SpeakableListener listener)
          Sets queue item data with a URL source.
 void started()
          indicate that this item has been started
 boolean waitCompleted()
          wait for this queue item to be completed
 
Methods inherited from class javax.speech.synthesis.SynthesizerQueueItem
getSource, getSpeakableListener, getText, isPlainText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

itemNumber

protected static int itemNumber
Global count of queue items used for debug.


thisItemNumber

protected int thisItemNumber
Count for this item used for debug.


synth

protected BaseSynthesizer synth
Synthesizer that has queued this item.

Constructor Detail

BaseSynthesizerQueueItem

public BaseSynthesizerQueueItem()
Class constructor.

Method Detail

setData

protected void setData(BaseSynthesizer synth,
                       javax.speech.synthesis.Speakable source,
                       javax.speech.synthesis.SpeakableListener listener)
                throws javax.speech.synthesis.JSMLException
Sets queue item data with a Speakable source.

Parameters:
synth - the synthesizer
source - the Speakable
listener - the SpeakableListener to be notified as this object is processed
Throws:
javax.speech.synthesis.JSMLException - if the source contains JSML errors

setData

protected void setData(BaseSynthesizer synth,
                       java.lang.String source,
                       boolean plainText,
                       javax.speech.synthesis.SpeakableListener listener)
                throws javax.speech.synthesis.JSMLException
Sets queue item data with a String source that is either plain text or JSML.

Parameters:
synth - the synthesizer
source - the text
plainText - true only if the source is plain text
listener - the SpeakableListener to be notified as this object is processed
Throws:
javax.speech.synthesis.JSMLException - if the source contains JSML errors

setData

protected void setData(BaseSynthesizer synth,
                       java.net.URL source,
                       javax.speech.synthesis.SpeakableListener listener)
                throws javax.speech.synthesis.JSMLException,
                       java.io.IOException
Sets queue item data with a URL source.

Parameters:
synth - the synthesizer
source - the URL containing JSML text
listener - the SpeakableListener to be notified as this object is processed
Throws:
javax.speech.synthesis.JSMLException - if the source contains JSML errors
java.io.IOException - if there are problems working with the URL.

getDocument

protected org.w3c.dom.Document getDocument()
Gets the DOM document for this object.

Returns:
the DOM document for this object.

isCancelled

protected boolean isCancelled()
determines if this queue item has been cancelled

Returns:
true if this item has been cancelled; otherwise false

isCompleted

public boolean isCompleted()
returns true if this queue item has been processed.

Returns:
true if it has been processed

waitCompleted

public boolean waitCompleted()
wait for this queue item to be completed

Returns:
true if the item was completed successfully, false if the item was cancelled or an error occurred.

cancelled

public void cancelled()
indicate that this item has been cancelled


completed

public void completed()
indicate that this item has been completed


started

public void started()
indicate that this item has been started


getItemNumber

public int getItemNumber()
Gets the item number for debug purposes only. Each queue item is given a unique ID.

Returns:
the unique ID for this queue item

postMarkerReached

public void postMarkerReached(java.lang.String text,
                              int markerType)
Utility function that generates a MARKER_REACHED event and posts it to the event queue. Eventually fireMarkerReached will be called by dispatchSpeechEvent as a result of this action.

Parameters:
text - the text of the marker
markerType - the type of marker
See Also:
SpeakableEvent.getMarkerType(), fireMarkerReached(javax.speech.synthesis.SpeakableEvent), dispatchSpeechEvent(javax.speech.SpeechEvent)

fireMarkerReached

public void fireMarkerReached(javax.speech.synthesis.SpeakableEvent event)
Utility function that sends a MARKER_REACHED event to all speakable listeners.

Parameters:
event - the MARKER_REACHED event
See Also:
postMarkerReached(java.lang.String, int)

postSpeakableCancelled

public void postSpeakableCancelled()
Utility function that generates a SPEAKABLE_CANCELLED event and posts it to the event queue. Eventually fireSpeakableCancelled will be called by dispatchSpeechEvent as a result of this action.

See Also:
fireSpeakableCancelled(javax.speech.synthesis.SpeakableEvent), dispatchSpeechEvent(javax.speech.SpeechEvent)

fireSpeakableCancelled

public void fireSpeakableCancelled(javax.speech.synthesis.SpeakableEvent event)
Utility function that sends a SPEAKABLE_CANCELLED event to all speakable listeners.

Parameters:
event - the SPEAKABLE_CANCELLED event
See Also:
postSpeakableCancelled()

postSpeakableEnded

public void postSpeakableEnded()
Utility function that generates a SPEAKABLE_ENDED event and posts it to the event queue. Eventually fireSpeakableEnded will be called by dispatchSpeechEvent as a result of this action.

See Also:
fireSpeakableEnded(javax.speech.synthesis.SpeakableEvent), dispatchSpeechEvent(javax.speech.SpeechEvent)

fireSpeakableEnded

public void fireSpeakableEnded(javax.speech.synthesis.SpeakableEvent event)
Utility function that sends a SPEAKABLE_ENDED event to all speakable listeners.

Parameters:
event - the SPEAKABLE_ENDED event
See Also:
postSpeakableEnded()

postSpeakablePaused

public void postSpeakablePaused()
Utility function that generates a SPEAKABLE_PAUSED event and posts it to the event queue. Eventually fireSpeakablePaused will be called by dispatchSpeechEvent as a result of this action.

See Also:
fireSpeakablePaused(javax.speech.synthesis.SpeakableEvent), dispatchSpeechEvent(javax.speech.SpeechEvent)

fireSpeakablePaused

public void fireSpeakablePaused(javax.speech.synthesis.SpeakableEvent event)
Utility function that sends a SPEAKABLE_PAUSED event to all speakable listeners.

Parameters:
event - the SPEAKABLE_PAUSED event
See Also:
postSpeakablePaused()

postSpeakableResumed

public void postSpeakableResumed()
Utility function that generates a SPEAKABLE_RESUMED event and posts it to the event queue. Eventually fireSpeakableResumed will be called by dispatchSpeechEvent as a result of this action.

See Also:
fireSpeakableResumed(javax.speech.synthesis.SpeakableEvent), dispatchSpeechEvent(javax.speech.SpeechEvent)

fireSpeakableResumed

public void fireSpeakableResumed(javax.speech.synthesis.SpeakableEvent event)
Utility function that sends a SPEAKABLE_RESUMED event to all speakable listeners.

Parameters:
event - the SPEAKABLE_RESUMED event
See Also:
postSpeakableResumed()

postSpeakableStarted

public void postSpeakableStarted()
Utility function that generates a SPEAKABLE_STARTED event and posts it to the event queue. Eventually fireSpeakableStarted will be called by dispatchSpeechEvent as a result of this action.

See Also:
fireSpeakableStarted(javax.speech.synthesis.SpeakableEvent), dispatchSpeechEvent(javax.speech.SpeechEvent)

fireSpeakableStarted

public void fireSpeakableStarted(javax.speech.synthesis.SpeakableEvent event)
Utility function that sends a SPEAKABLE_STARTED event to all speakable listeners.

Parameters:
event - the SPEAKABLE_STARTED event
See Also:
postSpeakableStarted()

postTopOfQueue

public void postTopOfQueue()
Utility function that generates a TOP_OF_QUEUE event and posts it to the event queue. Eventually fireTopOfQueue will be called by dispatchSpeechEvent as a result of this action.

See Also:
fireTopOfQueue(javax.speech.synthesis.SpeakableEvent), dispatchSpeechEvent(javax.speech.SpeechEvent)

fireTopOfQueue

public void fireTopOfQueue(javax.speech.synthesis.SpeakableEvent event)
Utility function that sends a TOP_OF_QUEUE event to all speakable listeners.

Parameters:
event - the TOP_OF_QUEUE event
See Also:
postTopOfQueue()

postWordStarted

public void postWordStarted(java.lang.String text,
                            int wordStart,
                            int wordEnd)
Utility function that generates a WORD_STARTED event and posts it to the event queue. Eventually fireWordStarted will be called by dispatchSpeechEvent as a result of this action.

See Also:
fireWordStarted(javax.speech.synthesis.SpeakableEvent), dispatchSpeechEvent(javax.speech.SpeechEvent)

fireWordStarted

public void fireWordStarted(javax.speech.synthesis.SpeakableEvent event)
Utility function that sends a WORD_STARTED event to all speakable listeners.

Parameters:
event - the WORD_STARTED event
See Also:
postWordStarted(java.lang.String, int, int)

dispatchSpeechEvent

public void dispatchSpeechEvent(javax.speech.SpeechEvent event)
Dispatches a SpeechEvent. The dispatcher should notify all EngineListeners from this method. The SpeechEvent was added via the various post methods of this class.

Specified by:
dispatchSpeechEvent in interface SpeechEventDispatcher
Parameters:
event - the SpeechEvent to dispatch
See Also:
postMarkerReached(java.lang.String, int), postSpeakableCancelled(), postSpeakableEnded(), postSpeakablePaused(), postSpeakableResumed(), postSpeakableStarted(), postTopOfQueue(), postWordStarted(java.lang.String, int, int)