Package com.sun.speech.engine.synthesis
Class BaseSynthesizerQueueItem
- java.lang.Object
-
- SynthesizerQueueItem
-
- com.sun.speech.engine.synthesis.BaseSynthesizerQueueItem
-
- All Implemented Interfaces:
SpeechEventDispatcher
- Direct Known Subclasses:
FreeTTSSynthesizerQueueItem,TextSynthesizerQueueItem
public class BaseSynthesizerQueueItem extends SynthesizerQueueItem implements SpeechEventDispatcher
Extends the JSAPI 1.0SynthesizerQueueItemwith handling for JSML, generation of engine-specific text, and other features.
-
-
Field Summary
Fields Modifier and Type Field Description protected static intitemNumberGlobal count of queue items used for debug.protected BaseSynthesizersynthSynthesizerthat has queued this item.protected intthisItemNumberCount for this item used for debug.
-
Constructor Summary
Constructors Constructor Description BaseSynthesizerQueueItem()Class constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancelled()indicate that this item has been canceledvoidcompleted()indicate that this item has been completedvoiddispatchSpeechEvent(SpeechEvent event)Dispatches aSpeechEvent.voidfireMarkerReached(SpeakableEvent event)Utility function that sends aMARKER_REACHEDevent to all speakable listeners.voidfireSpeakableCancelled(SpeakableEvent event)Utility function that sends aSPEAKABLE_CANCELLEDevent to all speakable listeners.voidfireSpeakableEnded(SpeakableEvent event)Utility function that sends aSPEAKABLE_ENDEDevent to all speakable listeners.voidfireSpeakablePaused(SpeakableEvent event)Utility function that sends aSPEAKABLE_PAUSEDevent to all speakable listeners.voidfireSpeakableResumed(SpeakableEvent event)Utility function that sends aSPEAKABLE_RESUMEDevent to all speakable listeners.voidfireSpeakableStarted(SpeakableEvent event)Utility function that sends aSPEAKABLE_STARTEDevent to all speakable listeners.voidfireTopOfQueue(SpeakableEvent event)Utility function that sends aTOP_OF_QUEUEevent to all speakable listeners.voidfireWordStarted(SpeakableEvent event)Utility function that sends aWORD_STARTEDevent to all speakable listeners.protected org.w3c.dom.DocumentgetDocument()Gets the DOM document for this object.intgetItemNumber()Gets the item number for debug purposes only.protected booleanisCancelled()determines if this queue item has been canceledbooleanisCompleted()returns true if this queue item has been processed.voidpostMarkerReached(java.lang.String text, int markerType)Utility function that generates aMARKER_REACHEDevent and posts it to the event queue.voidpostSpeakableCancelled()Utility function that generates aSPEAKABLE_CANCELLEDevent and posts it to the event queue.voidpostSpeakableEnded()Utility function that generates aSPEAKABLE_ENDEDevent and posts it to the event queue.voidpostSpeakablePaused()Utility function that generates aSPEAKABLE_PAUSEDevent and posts it to the event queue.voidpostSpeakableResumed()Utility function that generates aSPEAKABLE_RESUMEDevent and posts it to the event queue.voidpostSpeakableStarted()Utility function that generates aSPEAKABLE_STARTEDevent and posts it to the event queue.voidpostTopOfQueue()Utility function that generates aTOP_OF_QUEUEevent and posts it to the event queue.voidpostWordStarted(java.lang.String text, int wordStart, int wordEnd)Utility function that generates aWORD_STARTEDevent and posts it to the event queue.protected voidsetData(BaseSynthesizer synth, java.lang.String source, boolean plainText, SpeakableListener listener)Sets queue item data with aStringsource that is either plain text or JSML.protected voidsetData(BaseSynthesizer synth, java.net.URL source, SpeakableListener listener)Sets queue item data with aURLsource.protected voidsetData(BaseSynthesizer synth, Speakable source, SpeakableListener listener)Sets queue item data with aSpeakablesource.voidstarted()indicate that this item has been startedbooleanwaitCompleted()wait for this queue item to be completed
-
-
-
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
Synthesizerthat has queued this item.
-
-
Method Detail
-
setData
protected void setData(BaseSynthesizer synth, Speakable source, SpeakableListener listener) throws JSMLException
Sets queue item data with aSpeakablesource.- Parameters:
synth- the synthesizersource- theSpeakablelistener- theSpeakableListenerto be notified as this object is processed- Throws:
JSMLException- if thesourcecontains JSML errors
-
setData
protected void setData(BaseSynthesizer synth, java.lang.String source, boolean plainText, SpeakableListener listener) throws JSMLException
Sets queue item data with aStringsource that is either plain text or JSML.- Parameters:
synth- the synthesizersource- the textplainText-trueonly if thesourceis plain textlistener- theSpeakableListenerto be notified as this object is processed- Throws:
JSMLException- if thesourcecontains JSML errors
-
setData
protected void setData(BaseSynthesizer synth, java.net.URL source, SpeakableListener listener) throws JSMLException, java.io.IOException
Sets queue item data with aURLsource.- Parameters:
synth- the synthesizersource- theURLcontaining JSML textlistener- theSpeakableListenerto be notified as this object is processed- Throws:
JSMLException- if thesourcecontains JSML errorsjava.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 canceled- Returns:
trueif this item has been canceled; otherwisefalse
-
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 canceled or an error occurred.
-
cancelled
public void cancelled()
indicate that this item has been canceled
-
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 aMARKER_REACHEDevent and posts it to the event queue. EventuallyfireMarkerReachedwill be called bydispatchSpeechEventas a result of this action.- Parameters:
text- the text of the markermarkerType- the type of marker- See Also:
SpeakableEvent#getMarkerType,fireMarkerReached(SpeakableEvent),dispatchSpeechEvent(SpeechEvent)
-
fireMarkerReached
public void fireMarkerReached(SpeakableEvent event)
Utility function that sends aMARKER_REACHEDevent to all speakable listeners.- Parameters:
event- theMARKER_REACHEDevent- See Also:
postMarkerReached(java.lang.String, int)
-
postSpeakableCancelled
public void postSpeakableCancelled()
Utility function that generates aSPEAKABLE_CANCELLEDevent and posts it to the event queue. EventuallyfireSpeakableCancelledwill be called bydispatchSpeechEventas a result of this action.
-
fireSpeakableCancelled
public void fireSpeakableCancelled(SpeakableEvent event)
Utility function that sends aSPEAKABLE_CANCELLEDevent to all speakable listeners.- Parameters:
event- theSPEAKABLE_CANCELLEDevent- See Also:
postSpeakableCancelled()
-
postSpeakableEnded
public void postSpeakableEnded()
Utility function that generates aSPEAKABLE_ENDEDevent and posts it to the event queue. EventuallyfireSpeakableEndedwill be called bydispatchSpeechEventas a result of this action.
-
fireSpeakableEnded
public void fireSpeakableEnded(SpeakableEvent event)
Utility function that sends aSPEAKABLE_ENDEDevent to all speakable listeners.- Parameters:
event- theSPEAKABLE_ENDEDevent- See Also:
postSpeakableEnded()
-
postSpeakablePaused
public void postSpeakablePaused()
Utility function that generates aSPEAKABLE_PAUSEDevent and posts it to the event queue. EventuallyfireSpeakablePausedwill be called bydispatchSpeechEventas a result of this action.
-
fireSpeakablePaused
public void fireSpeakablePaused(SpeakableEvent event)
Utility function that sends aSPEAKABLE_PAUSEDevent to all speakable listeners.- Parameters:
event- theSPEAKABLE_PAUSEDevent- See Also:
postSpeakablePaused()
-
postSpeakableResumed
public void postSpeakableResumed()
Utility function that generates aSPEAKABLE_RESUMEDevent and posts it to the event queue. EventuallyfireSpeakableResumedwill be called bydispatchSpeechEventas a result of this action.
-
fireSpeakableResumed
public void fireSpeakableResumed(SpeakableEvent event)
Utility function that sends aSPEAKABLE_RESUMEDevent to all speakable listeners.- Parameters:
event- theSPEAKABLE_RESUMEDevent- See Also:
postSpeakableResumed()
-
postSpeakableStarted
public void postSpeakableStarted()
Utility function that generates aSPEAKABLE_STARTEDevent and posts it to the event queue. EventuallyfireSpeakableStartedwill be called bydispatchSpeechEventas a result of this action.
-
fireSpeakableStarted
public void fireSpeakableStarted(SpeakableEvent event)
Utility function that sends aSPEAKABLE_STARTEDevent to all speakable listeners.- Parameters:
event- theSPEAKABLE_STARTEDevent- See Also:
postSpeakableStarted()
-
postTopOfQueue
public void postTopOfQueue()
Utility function that generates aTOP_OF_QUEUEevent and posts it to the event queue. EventuallyfireTopOfQueuewill be called bydispatchSpeechEventas a result of this action.
-
fireTopOfQueue
public void fireTopOfQueue(SpeakableEvent event)
Utility function that sends aTOP_OF_QUEUEevent to all speakable listeners.- Parameters:
event- theTOP_OF_QUEUEevent- See Also:
postTopOfQueue()
-
postWordStarted
public void postWordStarted(java.lang.String text, int wordStart, int wordEnd)Utility function that generates aWORD_STARTEDevent and posts it to the event queue. EventuallyfireWordStartedwill be called bydispatchSpeechEventas a result of this action.
-
fireWordStarted
public void fireWordStarted(SpeakableEvent event)
Utility function that sends aWORD_STARTEDevent to all speakable listeners.- Parameters:
event- theWORD_STARTEDevent- See Also:
postWordStarted(java.lang.String, int, int)
-
dispatchSpeechEvent
public void dispatchSpeechEvent(SpeechEvent event)
Dispatches aSpeechEvent. The dispatcher should notify allEngineListenersfrom this method. TheSpeechEventwas added via the various post methods of this class.- Specified by:
dispatchSpeechEventin interfaceSpeechEventDispatcher- Parameters:
event- theSpeechEventto dispatch- See Also:
postMarkerReached(java.lang.String, int),postSpeakableCancelled(),postSpeakableEnded(),postSpeakablePaused(),postSpeakableResumed(),postSpeakableStarted(),postTopOfQueue(),postWordStarted(java.lang.String, int, int)
-
-