Class BaseSynthesizer

    • Field Detail

      • speakableListeners

        protected java.util.Collection speakableListeners
        Set of speakable listeners belonging to the Synthesizer. Each item on queue may have an individual listener too.
        See Also:
        SpeakableListener
      • voiceList

        protected VoiceList voiceList
        The set of voices available in this Synthesizer. The list can be created in the constructor methods.
    • Constructor Detail

      • BaseSynthesizer

        public BaseSynthesizer​(SynthesizerModeDesc mode)
        Creates a new Synthesizer in the DEALLOCATED state.
        Parameters:
        mode - the operating mode of this Synthesizer
    • Method Detail

      • speak

        public void speak​(Speakable jsmlText,
                          SpeakableListener listener)
                   throws JSMLException,
                          EngineStateError
        Speaks JSML text provided as a Speakable object.
        Parameters:
        jsmlText - the JSML text to speak
        listener - the listener to be notified as the jsmlText is processed
        Throws:
        JSMLException - if the JSML text contains errors
        EngineStateError - if this Synthesizer in the DEALLOCATED or DEALLOCATING_RESOURCES states
      • speak

        public void speak​(java.net.URL jsmlURL,
                          SpeakableListener listener)
                   throws JSMLException,
                          java.net.MalformedURLException,
                          java.io.IOException,
                          EngineStateError
        Speaks JSML text provided as a URL.
        Parameters:
        jsmlURL - the URL containing JSML text
        listener - the listener to be notified as the JSML text is processed
        Throws:
        EngineStateError - if this Synthesizer in the DEALLOCATED or DEALLOCATING_RESOURCES states
        java.io.IOException - if errors are encountered with the JSMLurl
        JSMLException - if the JSML text contains errors
        java.net.MalformedURLException - if errors are encountered with the JSMLurl
      • speak

        public void speak​(java.lang.String jsmlText,
                          SpeakableListener listener)
                   throws JSMLException,
                          EngineStateError
        Speaks JSML text provided as a String.
        Parameters:
        jsmlText - a String containing JSML.
        listener - the listener to be notified as the JSML text is processed
        Throws:
        EngineStateError - if this Synthesizer in the DEALLOCATED or DEALLOCATING_RESOURCES states
        JSMLException - if the JSML text contains errors
      • speakPlainText

        public void speakPlainText​(java.lang.String text,
                                   SpeakableListener listener)
                            throws EngineStateError
        Speaks a plain text String. No JSML parsing is performed.
        Parameters:
        text - a String containing plain text.
        listener - the listener to be notified as the text is processed
        Throws:
        EngineStateError - if this Synthesizer in the DEALLOCATED or DEALLOCATING_RESOURCES states
      • stateToString

        protected java.lang.String stateToString​(long state)
        Returns a String of the names of all the states implied in the given bit pattern.
        Overrides:
        stateToString in class BaseEngine
        Parameters:
        state - the bit pattern of states
        Returns:
        a String of the names of all the states implied in the given bit pattern.
      • appendQueue

        protected abstract void appendQueue​(BaseSynthesizerQueueItem item)
        Puts an item on the speaking queue and sends a queue updated event.
        Parameters:
        item - the item to add to the queue
      • phoneme

        public java.lang.String phoneme​(java.lang.String text)
                                 throws EngineStateError
        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
        Throws:
        EngineStateError - if this Synthesizer in the DEALLOCATED or DEALLOCATING_RESOURCES states
      • enumerateQueue

        public abstract java.util.Enumeration enumerateQueue()
                                                      throws EngineStateError
        Returns an enumeration of the queue.
        Returns:
        an Enumeration of the speech output queue or null.
        Throws:
        EngineStateError - if this Synthesizer in the DEALLOCATED or DEALLOCATING_RESOURCES states
      • cancel

        public abstract void cancel()
                             throws EngineStateError
        Cancels the item at the top of the queue.
        Throws:
        EngineStateError - if this Synthesizer in the DEALLOCATED or DEALLOCATING_RESOURCES states
      • cancel

        public abstract void cancel​(java.lang.Object source)
                             throws java.lang.IllegalArgumentException,
                                    EngineStateError
        Cancels a specific object on the queue.
        Parameters:
        source - object to be removed from the speech output queue
        Throws:
        java.lang.IllegalArgumentException - if the source object is not found in the speech output queue.
        EngineStateError - if this Synthesizer in the DEALLOCATED or DEALLOCATING_RESOURCES states
      • cancelAll

        public abstract void cancelAll()
                                throws EngineStateError
        Cancels all items on the output queue.
        Throws:
        EngineStateError - if this Synthesizer in the DEALLOCATED or DEALLOCATING_RESOURCES states
      • getSynthesizerProperties

        public SynthesizerProperties getSynthesizerProperties()
        Returns the 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.
        Returns:
        the SynthesizerProperties object for this Synthesizer
      • addSpeakableListener

        public void addSpeakableListener​(SpeakableListener listener)
        Adds a SpeakableListener to this Synthesizer.
        Parameters:
        listener - the listener to add
        See Also:
        removeSpeakableListener(SpeakableListener)
      • removeSpeakableListener

        public void removeSpeakableListener​(SpeakableListener listener)
        Removes a SpeakableListener from this Synthesizer.
        Parameters:
        listener - the listener to remove
        See Also:
        addSpeakableListener(SpeakableListener)
      • createEngineProperties

        protected BaseEngineProperties createEngineProperties()
        Factory constructor for 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.
        Specified by:
        createEngineProperties in class BaseEngine
        Returns:
        a BaseEngineProperties object specific to a subclass.
      • createQueueItem

        protected BaseSynthesizerQueueItem createQueueItem()
        Factory method that creates a BaseSynthesizerQueueItem. Override if the synthesizer specializes the BaseSynthesizerQueueItem class.
      • getVoiceList

        protected VoiceList getVoiceList()
        Returns the list of voices for this Synthesizer.
        Returns:
        the list of voices for this Synthesizer.
      • postQueueUpdated

        public void postQueueUpdated​(boolean topOfQueueChanged,
                                     long oldState,
                                     long newState)
        Utility function that generates QUEUE_UPDATED event and posts it to the event queue. Eventually fireQueueUpdated will be called by dispatchSpeechEvent as a result of this action.
        Parameters:
        topOfQueueChanged - true if the top of the queue has changed
        oldState - the old state of this Synthesizer
        newState - the new state of this Synthesizer
        See Also:
        fireQueueUpdated(SynthesizerEvent), dispatchSpeechEvent(SpeechEvent)
      • postQueueEmptied

        public void postQueueEmptied​(long oldState,
                                     long newState)
        Utility function that generates QUEUE_EMPTIED event and posts it to the event queue. Eventually fireQueueEmptied will be called by dispatchSpeechEvent as a result of this action.
        Parameters:
        oldState - the old state of this Synthesizer
        newState - the new state of this Synthesizer
        See Also:
        fireQueueEmptied(SynthesizerEvent), dispatchSpeechEvent(SpeechEvent)