Overview | Package | Class | Tree | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class javax.speech.synthesis.SpeakableEvent

java.lang.Object
  |
  +--java.util.EventObject
        |
        +--javax.speech.SpeechEvent
              |
              +--javax.speech.synthesis.SpeakableEvent

public class SpeakableEvent
extends SpeechEvent
Event issued during spoken output of text.

SpeakableEvents are issued to SpeakableListeners. A single SpeakableListener can be provided to any of the speak and speakPlainText methods of a Synthesizer to monitor progress of a single item on the speech output queue. Any number of SpeakableListener objects can be attached to a Synthesizer with the addSpeakableListener method. These listeners receive every SpeakableEvent for every item on the speech output queue of the Synthesizer. The SpeakableListener attached to an individual item on the speech output queue is notified before the SpeakableListeners attached to the Synthesizer.

The source for a SpeakableEvent is the object from which the JSML text was obtained: a Speakable object, a URL, or a String.

The normal sequence of events during output of the item of the top of the synthesizer's speech output is:

A SPEAKABLE_PAUSED may occur any time after the TOP_OF_QUEUE but before the SPEAKABLE_ENDED event. A SPEAKABLE_PAUSED event can only be followed by a SPEAKABLE_RESUMED or SPEAKABLE_CANCELLED.

A SPEAKABLE_CANCELLED event can occur at any time before an SPEAKABLE_ENDED (including before a TOP_OF_QUEUE event). No other events can follow the SPEAKABLE_CANCELLED event since the item has been removed from the speech output queue.

A SPEAKABLE_CANCELLED event can be issued for items that are not at the top of the speech output queue. The other events are only issued for the top-of-queue item.

See Also:
SpeakableListener, addSpeakableListener, Speakable, speak(javax.speech.synthesis.Speakable, javax.speech.synthesis.SpeakableListener), speak(java.net.URL, javax.speech.synthesis.SpeakableListener), speak(java.lang.String, javax.speech.synthesis.SpeakableListener), speakPlainText(java.lang.String, javax.speech.synthesis.SpeakableListener), Serialized Form

Field Summary
static int ELEMENT_CLOSE
          The type of MARKER_REACHED event issued at the close of a JSML container element that has a MARK attribute on the matching openning tag.
static int ELEMENT_EMPTY
          The type of MARKER_REACHED event issued when an empty JSML element with a MARK attribute is reached.
static int ELEMENT_OPEN
          The type of MARKER_REACHED event issued at the openning of a JSML container element with a MARK attribute.
static int MARKER_REACHED
          Issued when audio output reaches a marker contained in the JSML text of a speech output queue item.
int markerType
          Marker type for a MARKER_REACHED event.
static int SPEAKABLE_CANCELLED
          Issued when an item on the synthesizer's speech output queue is cancelled and removed from the queue.
static int SPEAKABLE_ENDED
          Issued with the completion of audio output of an object on the speech output queue as the object is removed from the queue.
static int SPEAKABLE_PAUSED
          Issued when audio output of the item at the top of a synthesizer's speech output queue is paused.
static int SPEAKABLE_RESUMED
          Issued when audio output of the item at the top of a synthesizer's speech output queue is resumed after a previous pause.
static int SPEAKABLE_STARTED
          Issued at the start of audio output of an item on the speech output queue.
String text
          The text associated with the SpeakableEvent.
static int TOP_OF_QUEUE
          Issued when an item on the synthesizer's speech output queue reaches the top of the queue.
static int WORD_STARTED
          Issued when a synthesis engine starts the audio output of a word in the speech output queue item.
int wordEnd
          Index of last character of of word in JSML text for a WORD_STARTED event.
int wordStart
          Index of first character of of word in JSML text for a WORD_STARTED event.
 
Fields inherited from class javax.speech.SpeechEvent
id
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
SpeakableEvent(Object source, int id)
          Constructs an SpeakableEvent with a specified source and identifier.
SpeakableEvent(Object source, int id, String text, int markerType)
          Constructs an SpeakableEvent with a specified source, identifier, text and marker type (used for a MARKER_REACHED event).
SpeakableEvent(Object source, int id, String text, int wordStart, int wordEnd)
          Constructor for a specified source, identifier, text, wordStart and wordEnd (called for a WORD_STARTED event).
 
Method Summary
int getMarkerType()
          Return the type of a MARKER_REACHED event.
String getText()
          Get the text associated with the event.
int getWordEnd()
          For a WORD_STARTED event, return the index of the last character of the word in the JSML text.
int getWordStart()
          For a WORD_STARTED event, return the index of the first character of the word in the JSML text.
String paramString()
          Returns a parameter string identifying this event.
 
Methods inherited from class javax.speech.SpeechEvent
getId, paramString, toString
 
Methods inherited from class java.util.EventObject
getSource, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Field Detail

TOP_OF_QUEUE

public static final int TOP_OF_QUEUE
Issued when an item on the synthesizer's speech output queue reaches the top of the queue. If the Synthesizer is not paused, the TOP_OF_QUEUE event will be followed immediately by the SPEAKABLE_STARTED event. If the Synthesizer is paused, the SPEAKABLE_STARTED event will be delayed until the Synthesizer is resumed.

A QUEUE_UPDATED is also issued when the speech output queue changes (e.g. a new item at the top of the queue). The SpeakableEvent is issued prior to the SynthesizerEvent.

See Also:
topOfQueue, QUEUE_UPDATED, PAUSED

SPEAKABLE_STARTED

public static final int SPEAKABLE_STARTED
Issued at the start of audio output of an item on the speech output queue. This event immediately follows the TOP_OF_QUEUE unless the Synthesizer is paused when the speakable text is promoted to the top of the output queue.

See Also:
speakableStarted

SPEAKABLE_ENDED

public static final int SPEAKABLE_ENDED
Issued with the completion of audio output of an object on the speech output queue as the object is removed from the queue.

A QUEUE_UPDATED or QUEUE_EMPTIED event is also issued when the speech output queue changes because the speech output of the item at the top of queue is completed. The SpeakableEvent is issued prior to the SynthesizerEvent.

See Also:
speakableEnded, QUEUE_EMPTIED, QUEUE_UPDATED

SPEAKABLE_PAUSED

public static final int SPEAKABLE_PAUSED
Issued when audio output of the item at the top of a synthesizer's speech output queue is paused. The SPEAKABLE_PAUSED SpeakableEvent is issued prior to the ENGINE_PAUSED event that is issued to the SynthesizerListener.

See Also:
speakablePaused, ENGINE_PAUSED

SPEAKABLE_RESUMED

public static final int SPEAKABLE_RESUMED
Issued when audio output of the item at the top of a synthesizer's speech output queue is resumed after a previous pause. The SPEAKABLE_RESUMED SpeakableEvent is issued prior to the ENGINE_RESUMED event that is issued to the SynthesizerListener.

See Also:
speakableResumed, ENGINE_RESUMED

SPEAKABLE_CANCELLED

public static final int SPEAKABLE_CANCELLED
Issued when an item on the synthesizer's speech output queue is cancelled and removed from the queue. A speech output queue item may be cancelled at any time following a call to speak. An item can be cancelled even if it is not at the top of the speech output queue (other SpeakableEvents are issued only to the top-of-queue item). Once cancelled, the listener for the cancelled object receives no further SpeakableEvents.

The SPEAKABLE_CANCELLED SpeakableEvent is issued prior to the QUEUE_UPDATED or QUEUE_EMPTIED event that is issued to the SynthesizerListener.

See Also:
speakableCancelled, cancel(), cancel(Object), cancelAll(), QUEUE_UPDATED, QUEUE_EMPTIED

WORD_STARTED

public static final int WORD_STARTED
Issued when a synthesis engine starts the audio output of a word in the speech output queue item. The text, wordStart and wordEnd parameters defines the segment of the speakable's string which is now being spoken.

See Also:
wordStarted, getText, getWordStart, getWordEnd

MARKER_REACHED

public static final int MARKER_REACHED
Issued when audio output reaches a marker contained in the JSML text of a speech output queue item. The event text is the string of the MARK attribute. The markerType indicates whether the mark is at the openning or close of a JSML element or is an attribute of an empty element (no close).

See Also:
markerReached, getText, getMarkerType, ELEMENT_OPEN, ELEMENT_CLOSE, ELEMENT_EMPTY

ELEMENT_OPEN

public static final int ELEMENT_OPEN
The type of MARKER_REACHED event issued at the openning of a JSML container element with a MARK attribute. An ELEMENT_OPEN event is followed by an ELEMENT_CLOSE event for the closing of the element (unless the Speakable is cancelled).

Example: the event for the MARK attribute on the openning SENT tag will be issued before the start of the word "Testing" in:

     <SENT MARK="open">Testing one, <MARKER MARK="here"/> two, three.</SENT>
 

See Also:
MARKER_REACHED, getMarkerType

ELEMENT_CLOSE

public static final int ELEMENT_CLOSE
The type of MARKER_REACHED event issued at the close of a JSML container element that has a MARK attribute on the matching openning tag. The ELEMENT_CLOSE event always follows a matching ELEMENT_OPEN event for the matching openning tag.

Example: the event for the closing SENT tag for the MARK attribute at the openning of the SENT element. The event will be issued after the word "three" is spoken.

     <SENT MARK="open">Testing one, <MARKER MARK="here"/> two, three.</SENT>
 

See Also:
MARKER_REACHED, getMarkerType

ELEMENT_EMPTY

public static final int ELEMENT_EMPTY
The type of MARKER_REACHED event issued when an empty JSML element with a MARK attribute is reached. (An empty JSML has no closing tag and is indicated by a slash ('/') before the '>' character.)

Example: the MARKER tag below is empty event so an ELEMENT_EMPTY type of MARKER_REACHED event is issued before the word "two" is spoken in:

     <SENT MARK="open">Testing one, <MARKER MARK="here"/> two, three.</SENT>
 

See Also:
MARKER_REACHED, getMarkerType

text

protected String text
The text associated with the SpeakableEvent.

markerType

protected int markerType
Marker type for a MARKER_REACHED event.

See Also:
getMarkerType, ELEMENT_OPEN, ELEMENT_CLOSE, ELEMENT_EMPTY

wordStart

protected int wordStart
Index of first character of of word in JSML text for a WORD_STARTED event.

See Also:
WORD_STARTED, getWordStart

wordEnd

protected int wordEnd
Index of last character of of word in JSML text for a WORD_STARTED event.

See Also:
WORD_STARTED, getWordEnd
Constructor Detail

SpeakableEvent

public SpeakableEvent(Object source,
                      int id)
Constructs an SpeakableEvent with a specified source and identifier.

SpeakableEvent

public SpeakableEvent(Object source,
                      int id,
                      String text,
                      int markerType)
Constructs an SpeakableEvent with a specified source, identifier, text and marker type (used for a MARKER_REACHED event).

SpeakableEvent

public SpeakableEvent(Object source,
                      int id,
                      String text,
                      int wordStart,
                      int wordEnd)
Constructor for a specified source, identifier, text, wordStart and wordEnd (called for a WORD_STARTED event).
Method Detail

getMarkerType

public int getMarkerType()
Return the type of a MARKER_REACHED event.

See Also:
MARKER_REACHED, ELEMENT_OPEN, ELEMENT_CLOSE, ELEMENT_EMPTY

getText

public String getText()
Get the text associated with the event.

For WORD_STARTED, the text is the next word to be spoken. This text may differ from the text between the wordStart and wordEnd points is the original JSML text.

For MARKER_REACHED, the text is the MARK attribute in the JSML text.

See Also:
WORD_STARTED, MARKER_REACHED

getWordStart

public int getWordStart()
For a WORD_STARTED event, return the index of the first character of the word in the JSML text.

getWordEnd

public int getWordEnd()
For a WORD_STARTED event, return the index of the last character of the word in the JSML text.

paramString

public String paramString()
Returns a parameter string identifying this event. This method is useful for event-logging and for debugging.

Returns:
a string identifying the event
Overrides:
paramString in class SpeechEvent

Overview | Package | Class | Tree | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

JavaTM Speech API
Copyright 1997-1998 Sun Microsystems, Inc. All rights reserved
Send comments to javaspeech-comments@sun.com