Package com.sun.speech.engine.synthesis
Class BaseSynthesizer
java.lang.Object
com.sun.speech.engine.BaseEngine
com.sun.speech.engine.synthesis.BaseSynthesizer
- All Implemented Interfaces:
SpeechEventDispatcher
- Direct Known Subclasses:
FreeTTSSynthesizer,TextSynthesizer
Supports the JSAPI 1.0
Synthesizer interface that
performs the core non-engine-specific functions.
An actual JSAPI synthesizer implementation needs to extend or modify this implementation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CollectionSet of speakable listeners belonging to theSynthesizer.protected VoiceListThe set of voices available in thisSynthesizer.Fields inherited from class com.sun.speech.engine.BaseEngine
audioManager, CLEAR_ALL_STATE, engineListeners, engineModeDesc, engineProperties, engineState, engineStateLock -
Constructor Summary
ConstructorsConstructorDescriptionBaseSynthesizer(SynthesizerModeDesc mode) Creates a new Synthesizer in theDEALLOCATEDstate. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSpeakableListener(SpeakableListener listener) Adds aSpeakableListenerto thisSynthesizer.protected abstract voidPuts an item on the speaking queue and sends a queue updated event.abstract voidcancel()Cancels the item at the top of the queue.abstract voidCancels a specific object on the queue.abstract voidCancels all items on the output queue.protected BaseEnginePropertiesFactory constructor forEnginePropertiesobject.protected BaseSynthesizerQueueItemFactory method that creates aBaseSynthesizerQueueItem.voiddispatchSpeechEvent(SpeechEvent event) Dispatches aSpeechEvent.abstract EnumerationReturns an enumeration of the queue.voidfireQueueEmptied(SynthesizerEvent event) Utility function that sends aQUEUE_EMPTIEDevent to allSynthesizerListeners.voidfireQueueUpdated(SynthesizerEvent event) Utility function that sends aQUEUE_UPDATEDevent to allSynthesizerListeners.SynthesizerPropertiesReturns theSynthesizerPropertiesobject (a JavaBean).protected VoiceListReturns the list of voices for thisSynthesizer.Optional method that converts a text string to a phoneme string.voidpostQueueEmptied(long oldState, long newState) Utility function that generatesQUEUE_EMPTIEDevent and posts it to the event queue.voidpostQueueUpdated(boolean topOfQueueChanged, long oldState, long newState) Utility function that generatesQUEUE_UPDATEDevent and posts it to the event queue.voidremoveSpeakableListener(SpeakableListener listener) Removes aSpeakableListenerfrom thisSynthesizer.voidSpeaks JSML text provided as aString.voidSpeaks JSML text provided as aURL.voidspeak(Speakable jsmlText, SpeakableListener listener) Speaks JSML text provided as aSpeakableobject.voidspeakPlainText(String text, SpeakableListener listener) Speaks a plain textString.protected StringstateToString(long state) Returns a String of the names of all the states implied in the given bit pattern.Methods inherited from class com.sun.speech.engine.BaseEngine
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, waitEngineState
-
Field Details
-
speakableListeners
Set of speakable listeners belonging to theSynthesizer. Each item on queue may have an individual listener too.- See Also:
-
voiceList
The set of voices available in thisSynthesizer. The list can be created in the constructor methods.
-
-
Constructor Details
-
BaseSynthesizer
public BaseSynthesizer(SynthesizerModeDesc mode) Creates a new Synthesizer in theDEALLOCATEDstate.- Parameters:
mode- the operating mode of thisSynthesizer
-
-
Method Details
-
speak
public void speak(Speakable jsmlText, SpeakableListener listener) throws JSMLException, EngineStateError Speaks JSML text provided as aSpeakableobject.- Parameters:
jsmlText- the JSML text to speaklistener- the listener to be notified as thejsmlTextis processed
-
speak
public void speak(URL jsmlURL, SpeakableListener listener) throws JSMLException, MalformedURLException, IOException, EngineStateError Speaks JSML text provided as aURL.- Parameters:
jsmlURL- theURLcontaining JSML textlistener- the listener to be notified as the JSML text is processed
-
speak
public void speak(String jsmlText, SpeakableListener listener) throws JSMLException, EngineStateError Speaks JSML text provided as aString.- Parameters:
jsmlText- aStringcontaining JSML.listener- the listener to be notified as the JSML text is processed
-
speakPlainText
Speaks a plain textString. No JSML parsing is performed.- Parameters:
text- aStringcontaining plain text.listener- the listener to be notified as the text is processed
-
stateToString
Returns a String of the names of all the states implied in the given bit pattern.- Overrides:
stateToStringin classBaseEngine- Parameters:
state- the bit pattern of states- Returns:
- a String of the names of all the states implied in the given bit pattern.
-
appendQueue
Puts an item on the speaking queue and sends a queue updated event.- Parameters:
item- the item to add to the queue
-
phoneme
Optional method that converts a text string to a phoneme string.- Parameters:
text- plain text to be converted to phonemes- Returns:
- IPA phonemic representation of text or
null
-
enumerateQueue
Returns an enumeration of the queue.- Returns:
- an
Enumerationof the speech output queue ornull.
-
cancel
public abstract void cancel() throws EngineStateErrorCancels the item at the top of the queue. -
cancel
Cancels a specific object on the queue.- Parameters:
source- object to be removed from the speech output queue
-
cancelAll
public abstract void cancelAll() throws EngineStateErrorCancels all items on the output queue. -
getSynthesizerProperties
public SynthesizerProperties getSynthesizerProperties()Returns theSynthesizerPropertiesobject (a JavaBean). The method returns exactly the same object as thegetEnginePropertiesmethod in theEngineinterface. However, with thegetSynthesizerPropertiesmethod, an application does not need to cast the return value.- Returns:
- the
SynthesizerPropertiesobject for thisSynthesizer
-
addSpeakableListener
public void addSpeakableListener(SpeakableListener listener) Adds aSpeakableListenerto thisSynthesizer.- Parameters:
listener- the listener to add- See Also:
-
removeSpeakableListener
public void removeSpeakableListener(SpeakableListener listener) Removes aSpeakableListenerfrom thisSynthesizer.- Parameters:
listener- the listener to remove- See Also:
-
createEngineProperties
Factory constructor forEnginePropertiesobject. Gets the default speaking voice from theSynthesizerModeDesc. Takes the default prosody values (pitch, range, volume, rate) from the default voice. Override to set engine-specific defaults.- Specified by:
createEnginePropertiesin classBaseEngine- Returns:
- a
BaseEnginePropertiesobject specific to a subclass.
-
createQueueItem
Factory method that creates aBaseSynthesizerQueueItem. Override if the synthesizer specializes theBaseSynthesizerQueueItemclass. -
getVoiceList
Returns the list of voices for thisSynthesizer.- Returns:
- the list of voices for this
Synthesizer.
-
postQueueUpdated
public void postQueueUpdated(boolean topOfQueueChanged, long oldState, long newState) Utility function that generatesQUEUE_UPDATEDevent and posts it to the event queue. EventuallyfireQueueUpdatedwill be called bydispatchSpeechEventas a result of this action.- Parameters:
topOfQueueChanged-trueif the top of the queue has changedoldState- the old state of thisSynthesizernewState- the new state of thisSynthesizer- See Also:
-
fireQueueUpdated
public void fireQueueUpdated(SynthesizerEvent event) Utility function that sends aQUEUE_UPDATEDevent to allSynthesizerListeners.- Parameters:
event- theQUEUE_UPDATEDevent- See Also:
-
postQueueEmptied
public void postQueueEmptied(long oldState, long newState) Utility function that generatesQUEUE_EMPTIEDevent and posts it to the event queue. EventuallyfireQueueEmptiedwill be called bydispatchSpeechEventas a result of this action.- Parameters:
oldState- the old state of thisSynthesizernewState- the new state of thisSynthesizer- See Also:
-
fireQueueEmptied
public void fireQueueEmptied(SynthesizerEvent event) Utility function that sends aQUEUE_EMPTIEDevent to allSynthesizerListeners.- Parameters:
event- theQUEUE_EMPTIEDevent- See Also:
-
dispatchSpeechEvent
public void dispatchSpeechEvent(SpeechEvent event) Dispatches aSpeechEvent. The dispatcher should notify allSynthesizerListenersfrom this method. TheSpeechEventwas added via the various post methods of this class.- Specified by:
dispatchSpeechEventin interfaceSpeechEventDispatcher- Overrides:
dispatchSpeechEventin classBaseEngine- Parameters:
event- theSpeechEventto dispatch- See Also:
-