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 Collection
Set of speakable listeners belonging to theSynthesizer
.protected VoiceList
The 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 theDEALLOCATED
state. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSpeakableListener
(SpeakableListener listener) Adds aSpeakableListener
to thisSynthesizer
.protected abstract void
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
Cancels a specific object on the queue.abstract void
Cancels all items on the output queue.protected BaseEngineProperties
Factory constructor forEngineProperties
object.protected BaseSynthesizerQueueItem
Factory method that creates aBaseSynthesizerQueueItem
.void
dispatchSpeechEvent
(SpeechEvent event) Dispatches aSpeechEvent
.abstract Enumeration
Returns an enumeration of the queue.void
fireQueueEmptied
(SynthesizerEvent event) Utility function that sends aQUEUE_EMPTIED
event to allSynthesizerListeners
.void
fireQueueUpdated
(SynthesizerEvent event) Utility function that sends aQUEUE_UPDATED
event to allSynthesizerListeners
.SynthesizerProperties
Returns theSynthesizerProperties
object (a JavaBean).protected VoiceList
Returns the list of voices for thisSynthesizer
.Optional method that converts a text string to a phoneme string.void
postQueueEmptied
(long oldState, long newState) Utility function that generatesQUEUE_EMPTIED
event and posts it to the event queue.void
postQueueUpdated
(boolean topOfQueueChanged, long oldState, long newState) Utility function that generatesQUEUE_UPDATED
event and posts it to the event queue.void
removeSpeakableListener
(SpeakableListener listener) Removes aSpeakableListener
from thisSynthesizer
.void
Speaks JSML text provided as aString
.void
Speaks JSML text provided as aURL
.void
speak
(Speakable jsmlText, SpeakableListener listener) Speaks JSML text provided as aSpeakable
object.void
speakPlainText
(String text, SpeakableListener listener) Speaks a plain textString
.protected String
stateToString
(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 theDEALLOCATED
state.- 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 aSpeakable
object.- Parameters:
jsmlText
- the JSML text to speaklistener
- the listener to be notified as thejsmlText
is processed
-
speak
public void speak(URL jsmlURL, SpeakableListener listener) throws JSMLException, MalformedURLException, IOException, EngineStateError Speaks JSML text provided as aURL
.- Parameters:
jsmlURL
- theURL
containing 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
- aString
containing 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
- aString
containing 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:
stateToString
in 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
Enumeration
of 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 theSynthesizerProperties
object (a JavaBean). The method returns exactly the same object as thegetEngineProperties
method in theEngine
interface. However, with thegetSynthesizerProperties
method, an application does not need to cast the return value.- Returns:
- the
SynthesizerProperties
object for thisSynthesizer
-
addSpeakableListener
public void addSpeakableListener(SpeakableListener listener) Adds aSpeakableListener
to thisSynthesizer
.- Parameters:
listener
- the listener to add- See Also:
-
removeSpeakableListener
public void removeSpeakableListener(SpeakableListener listener) Removes aSpeakableListener
from thisSynthesizer
.- Parameters:
listener
- the listener to remove- See Also:
-
createEngineProperties
Factory constructor forEngineProperties
object. 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:
createEngineProperties
in classBaseEngine
- Returns:
- a
BaseEngineProperties
object specific to a subclass.
-
createQueueItem
Factory method that creates aBaseSynthesizerQueueItem
. Override if the synthesizer specializes theBaseSynthesizerQueueItem
class. -
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_UPDATED
event and posts it to the event queue. EventuallyfireQueueUpdated
will be called bydispatchSpeechEvent
as a result of this action.- Parameters:
topOfQueueChanged
-true
if the top of the queue has changedoldState
- the old state of thisSynthesizer
newState
- the new state of thisSynthesizer
- See Also:
-
fireQueueUpdated
public void fireQueueUpdated(SynthesizerEvent event) Utility function that sends aQUEUE_UPDATED
event to allSynthesizerListeners
.- Parameters:
event
- theQUEUE_UPDATED
event- See Also:
-
postQueueEmptied
public void postQueueEmptied(long oldState, long newState) Utility function that generatesQUEUE_EMPTIED
event and posts it to the event queue. EventuallyfireQueueEmptied
will be called bydispatchSpeechEvent
as a result of this action.- Parameters:
oldState
- the old state of thisSynthesizer
newState
- the new state of thisSynthesizer
- See Also:
-
fireQueueEmptied
public void fireQueueEmptied(SynthesizerEvent event) Utility function that sends aQUEUE_EMPTIED
event to allSynthesizerListeners
.- Parameters:
event
- theQUEUE_EMPTIED
event- See Also:
-
dispatchSpeechEvent
public void dispatchSpeechEvent(SpeechEvent event) Dispatches aSpeechEvent
. The dispatcher should notify allSynthesizerListeners
from this method. TheSpeechEvent
was added via the various post methods of this class.- Specified by:
dispatchSpeechEvent
in interfaceSpeechEventDispatcher
- Overrides:
dispatchSpeechEvent
in classBaseEngine
- Parameters:
event
- theSpeechEvent
to dispatch- See Also:
-