SpeechEventDispatcherFreeTTSSynthesizer, TextSynthesizerpublic abstract class BaseSynthesizer extends BaseEngine implements SpeechEventDispatcher
Synthesizer interface that
performs the core non-engine-specific functions.
An actual JSAPI synthesizer implementation needs to extend or modify this implementation.
| Modifier and Type | Field | Description |
|---|---|---|
protected java.util.Collection |
speakableListeners |
Set of speakable listeners belonging to the
Synthesizer. |
protected VoiceList |
voiceList |
The set of voices available in this
Synthesizer. |
audioManager, CLEAR_ALL_STATE, engineListeners, engineModeDesc, engineProperties, engineState, engineStateLock| Constructor | Description |
|---|---|
BaseSynthesizer(SynthesizerModeDesc mode) |
Creates a new Synthesizer in the
DEALLOCATED state. |
| Modifier and Type | Method | Description |
|---|---|---|
void |
addSpeakableListener(SpeakableListener listener) |
Adds a
SpeakableListener to this Synthesizer. |
protected abstract void |
appendQueue(BaseSynthesizerQueueItem item) |
Puts an item on the speaking queue and sends a queue updated
event.
|
abstract void |
cancel() |
Cancels the item at the top of the queue.
|
abstract void |
cancel(java.lang.Object source) |
Cancels a specific object on the queue.
|
abstract void |
cancelAll() |
Cancels all items on the output queue.
|
protected BaseEngineProperties |
createEngineProperties() |
Factory constructor for
EngineProperties object. |
protected BaseSynthesizerQueueItem |
createQueueItem() |
Factory method that creates a
BaseSynthesizerQueueItem. |
void |
dispatchSpeechEvent(SpeechEvent event) |
Dispatches a
SpeechEvent. |
abstract java.util.Enumeration |
enumerateQueue() |
Returns an enumeration of the queue.
|
void |
fireQueueEmptied(SynthesizerEvent event) |
Utility function that sends a
QUEUE_EMPTIED
event to all SynthesizerListeners. |
void |
fireQueueUpdated(SynthesizerEvent event) |
Utility function that sends a
QUEUE_UPDATED
event to all SynthesizerListeners. |
SynthesizerProperties |
getSynthesizerProperties() |
Returns the
SynthesizerProperties object (a JavaBean). |
protected VoiceList |
getVoiceList() |
Returns the list of voices for this
Synthesizer. |
java.lang.String |
phoneme(java.lang.String text) |
Optional method that converts a text string to a phoneme string.
|
void |
postQueueEmptied(long oldState,
long newState) |
Utility function that generates
QUEUE_EMPTIED
event and posts it to the event queue. |
void |
postQueueUpdated(boolean topOfQueueChanged,
long oldState,
long newState) |
Utility function that generates
QUEUE_UPDATED
event and posts it to the event queue. |
void |
removeSpeakableListener(SpeakableListener listener) |
Removes a
SpeakableListener from this
Synthesizer. |
void |
speak(java.lang.String jsmlText,
SpeakableListener listener) |
Speaks JSML text provided as a
String. |
void |
speak(java.net.URL jsmlURL,
SpeakableListener listener) |
Speaks JSML text provided as a
URL. |
void |
speak(Speakable jsmlText,
SpeakableListener listener) |
Speaks JSML text provided as a
Speakable object. |
void |
speakPlainText(java.lang.String text,
SpeakableListener listener) |
Speaks a plain text
String. |
protected java.lang.String |
stateToString(long state) |
Returns a String of the names of all the states implied
in the given bit pattern.
|
addEngineListener, allocate, checkEngineState, deallocate, fireEngineAllocated, fireEngineAllocatingResources, fireEngineDeallocated, fireEngineDeallocatingResources, fireEnginePaused, fireEngineResumed, getAudioManager, getEngineModeDesc, getEngineProperties, getEngineState, getVocabManager, handleAllocate, handleDeallocate, handlePause, handleResume, pause, postEngineAllocated, postEngineAllocatingResources, postEngineDeallocated, postEngineDeallocatingResources, postEnginePaused, postEngineResumed, removeEngineListener, resume, setEngineModeDesc, setEngineState, testEngineState, toString, waitEngineStateprotected java.util.Collection speakableListeners
Synthesizer.
Each item on queue may have an individual listener too.SpeakableListenerprotected VoiceList voiceList
Synthesizer.
The list can be created in the constructor methods.public BaseSynthesizer(SynthesizerModeDesc mode)
DEALLOCATED state.mode - the operating mode of this Synthesizerpublic void speak(Speakable jsmlText,
SpeakableListener listener)
throws JSMLException,
EngineStateError
Speakable object.jsmlText - the JSML text to speaklistener - the listener to be notified as the
jsmlText is processedJSMLException - if the JSML text contains errorsEngineStateError - if this Synthesizer in the DEALLOCATED or
DEALLOCATING_RESOURCES statespublic void speak(java.net.URL jsmlURL,
SpeakableListener listener)
throws JSMLException,
java.net.MalformedURLException,
java.io.IOException,
EngineStateError
URL.jsmlURL - the URL containing JSML textlistener - the listener to be notified as the
JSML text is processedEngineStateError - if this Synthesizer in the DEALLOCATED or
DEALLOCATING_RESOURCES statesjava.io.IOException - if errors are encountered with the JSMLurlJSMLException - if the JSML text contains errorsjava.net.MalformedURLException - if errors are encountered with the JSMLurlpublic void speak(java.lang.String jsmlText,
SpeakableListener listener)
throws JSMLException,
EngineStateError
String.jsmlText - a String containing JSML.listener - the listener to be notified as the
JSML text is processedEngineStateError - if this Synthesizer in the DEALLOCATED or
DEALLOCATING_RESOURCES statesJSMLException - if the JSML text contains errorspublic void speakPlainText(java.lang.String text,
SpeakableListener listener)
throws EngineStateError
String. No JSML parsing is
performed.text - a String containing plain text.listener - the listener to be notified as the
text is processedEngineStateError - if this Synthesizer in the DEALLOCATED or
DEALLOCATING_RESOURCES statesprotected java.lang.String stateToString(long state)
stateToString in class BaseEnginestate - the bit pattern of statesprotected abstract void appendQueue(BaseSynthesizerQueueItem item)
item - the item to add to the queuepublic java.lang.String phoneme(java.lang.String text)
throws EngineStateError
text - plain text to be converted to phonemesnullEngineStateError - if this Synthesizer in the DEALLOCATED or
DEALLOCATING_RESOURCES statespublic abstract java.util.Enumeration enumerateQueue()
throws EngineStateError
Enumeration of the speech output queue or
null.EngineStateError - if this Synthesizer in the DEALLOCATED or
DEALLOCATING_RESOURCES statespublic abstract void cancel()
throws EngineStateError
EngineStateError - if this Synthesizer in the DEALLOCATED or
DEALLOCATING_RESOURCES statespublic abstract void cancel(java.lang.Object source)
throws java.lang.IllegalArgumentException,
EngineStateError
source - object to be removed from the speech output queuejava.lang.IllegalArgumentException - if the source object is not found in the speech output queue.EngineStateError - if this Synthesizer in the DEALLOCATED or
DEALLOCATING_RESOURCES statespublic abstract void cancelAll()
throws EngineStateError
EngineStateError - if this Synthesizer in the DEALLOCATED or
DEALLOCATING_RESOURCES statespublic SynthesizerProperties getSynthesizerProperties()
SynthesizerProperties object (a JavaBean).
The method returns exactly the same object as the
getEngineProperties method in the Engine
interface. However, with the getSynthesizerProperties
method, an application does not need to cast the return value.SynthesizerProperties object for this
Synthesizerpublic void addSpeakableListener(SpeakableListener listener)
SpeakableListener to this Synthesizer.listener - the listener to addremoveSpeakableListener(SpeakableListener)public void removeSpeakableListener(SpeakableListener listener)
SpeakableListener from this
Synthesizer.listener - the listener to removeaddSpeakableListener(SpeakableListener)protected BaseEngineProperties createEngineProperties()
EngineProperties object.
Gets the default speaking voice from the
SynthesizerModeDesc.
Takes the default prosody values (pitch, range, volume, rate)
from the default voice. Override to set engine-specific defaults.createEngineProperties in class BaseEngineBaseEngineProperties object specific to
a subclass.protected BaseSynthesizerQueueItem createQueueItem()
BaseSynthesizerQueueItem.
Override if the synthesizer specializes the
BaseSynthesizerQueueItem class.protected VoiceList getVoiceList()
Synthesizer.Synthesizer.public void postQueueUpdated(boolean topOfQueueChanged,
long oldState,
long newState)
QUEUE_UPDATED
event and posts it to the event queue. Eventually
fireQueueUpdated will be called
by dispatchSpeechEvent as a result of this action.topOfQueueChanged - true if the top of the
queue has changedoldState - the old state of this SynthesizernewState - the new state of this SynthesizerfireQueueUpdated(SynthesizerEvent),
dispatchSpeechEvent(SpeechEvent)public void fireQueueUpdated(SynthesizerEvent event)
QUEUE_UPDATED
event to all SynthesizerListeners.event - the QUEUE_UPDATED eventpostQueueUpdated(boolean, long, long),
dispatchSpeechEvent(SpeechEvent)public void postQueueEmptied(long oldState,
long newState)
QUEUE_EMPTIED
event and posts it to the event queue. Eventually
fireQueueEmptied will be called
by dispatchSpeechEvent as a result of this action.oldState - the old state of this SynthesizernewState - the new state of this SynthesizerfireQueueEmptied(SynthesizerEvent),
dispatchSpeechEvent(SpeechEvent)public void fireQueueEmptied(SynthesizerEvent event)
QUEUE_EMPTIED
event to all SynthesizerListeners.event - the QUEUE_EMPTIED eventpostQueueEmptied(long, long),
dispatchSpeechEvent(SpeechEvent)public void dispatchSpeechEvent(SpeechEvent event)
SpeechEvent.
The dispatcher should notify all SynthesizerListeners
from this method. The SpeechEvent was added
via the various post methods of this class.dispatchSpeechEvent in interface SpeechEventDispatcherdispatchSpeechEvent in class BaseEngineevent - the SpeechEvent to dispatchpostQueueUpdated(boolean, long, long),
postQueueEmptied(long, long)