Package com.sun.speech.freetts
Class Utterance
java.lang.Object
com.sun.speech.freetts.Utterance
- All Implemented Interfaces:
Dumpable
,FeatureSet
,Serializable
Holds all the data for an utterance to be spoken.
It is incrementally modified by various UtteranceProcessor
implementations. An utterance contains a set of Features (essential
a set of properties) and a set of Relations. A Relation is an
ordered set of Item graphs. The utterance contains a set of
features and implements FeatureSet so that applications can set/get
features directly from the utterance. If a feature query is not
found in the utterance feature set, the query is forwarded to the
FeatureSet of the voice associated with the utterance.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateRelation
(String name) Creates a new relation with the given name and adds it to this utterance.void
dump
(PrintWriter output, int pad, String title) Dumps this utterance in textual form.void
dump
(PrintWriter output, int pad, String title, boolean justRelations) Dumps this utterance in textual form.void
dump
(PrintWriter output, String title) Dumps this utterance in textual form.void
Dumps this utterance in textual form.void
dumpRelations
(String title) Dumps the utterance in textual formfloat
Returns the duration of this Utterance in seconds.float
Convenience method that returns the named feature as a float.int
Convenience method that returns the named feature as a int.Returns the Item in the given Relation associated with the given time.Returns the named feature as an object.getRelation
(String name) Retrieves a relation from this utterance.Returns the queueitem associated with this utterance.Convenience method that returns the named feature as a string.getVoice()
Retrieves the Voice associated with this Utterance.boolean
hasRelation
(String name) Determines if this utterance contains a relation with the given name.boolean
isFirst()
Returns true if this utterance is the first is a series of utterances.boolean
isLast()
Returns true if this utterance is the last is a series of utterances.boolean
Determines if the given feature is present.void
Removes the named feature from this set of features.void
setFirst
(boolean first) Sets this utterance as the first in a series.void
Convenience method that sets the named feature as a float.void
Convenience method that sets the named feature as an int.void
setLast
(boolean last) Sets this utterance as the last in a series.void
Sets the named feature.void
setSpeakable
(FreeTTSSpeakable speakable) Sets the speakable item for this utterance.void
Convenience method that sets the named feature as a String.
-
Constructor Details
-
Utterance
Creates a new, empty utterance.- Parameters:
voice
- the voice associated with the utterance
-
Utterance
Creates an utterance with the given set of tokenized text.- Parameters:
voice
- the voice associated with the utterancetokenList
- the list of tokens for this utterance
-
-
Method Details
-
setSpeakable
Sets the speakable item for this utterance.- Parameters:
speakable
- the speakable item for this utterance
-
getSpeakable
Returns the queueitem associated with this utterance.- Returns:
- the queue item
-
createRelation
Creates a new relation with the given name and adds it to this utterance.- Parameters:
name
- the name of the new relation- Returns:
- the newly created relation
-
getRelation
Retrieves a relation from this utterance.- Parameters:
name
- the name of the Relation- Returns:
- the relation or null if the relation is not found
-
hasRelation
Determines if this utterance contains a relation with the given name.- Parameters:
name
- the name of the relation of interest.
-
getVoice
Retrieves the Voice associated with this Utterance.- Returns:
- the voice associated with this utterance.
-
dump
Dumps this utterance in textual form.- Parameters:
output
- where to send the formatted outputpad
- the initial paddingtitle
- the title to print when dumping out the utterancejustRelations
- if true don't print voice features
-
dump
Dumps this utterance in textual form.- Specified by:
dump
in interfaceDumpable
- Specified by:
dump
in interfaceFeatureSet
- Parameters:
output
- where to send the formatted outputpad
- the initial paddingtitle
- the title to print when dumping out the utterance
-
dump
Dumps this utterance in textual form.- Parameters:
output
- where to send the formatted outputtitle
- the title to print when dumping out the utterance
-
dump
Dumps this utterance in textual form.- Parameters:
title
- the title to print when dumping out the utterance
-
dumpRelations
Dumps the utterance in textual form- Parameters:
title
- the title to print when dumping out the utterance
-
isPresent
Determines if the given feature is present. If the feature is not present in the utterance, the feature set of the voice is checked.- Specified by:
isPresent
in interfaceFeatureSet
- Parameters:
name
- the name of the feature of interest- Returns:
- true if the named feature is present
-
remove
Removes the named feature from this set of features.- Specified by:
remove
in interfaceFeatureSet
- Parameters:
name
- the name of the feature of interest
-
getString
Convenience method that returns the named feature as a string. If the named feature is not present in the utterance, then this attempts to retrieve it from the voice.- Specified by:
getString
in interfaceFeatureSet
- Parameters:
name
- the name of the feature- Returns:
- the value associated with the name or null if the value is not found
- Throws:
ClassCastException
- if the associated value is not a String
-
getInt
Convenience method that returns the named feature as a int. If the named feature is not present in the utterance, then this attempts to retrieve it from the voice.- Specified by:
getInt
in interfaceFeatureSet
- Parameters:
name
- the name of the feature- Returns:
- the value associated with the name or null if the value is not found
- Throws:
ClassCastException
- if the associated value is not an int
-
getFloat
Convenience method that returns the named feature as a float. If the named feature is not present in the utterance, then this attempts to retrieve it from the voice.- Specified by:
getFloat
in interfaceFeatureSet
- Parameters:
name
- the name of the feature- Returns:
- the value associated with the name or null if the value is not found
- Throws:
ClassCastException
- if the associated value is not a float
-
getObject
Returns the named feature as an object. If the named feature is not present in the utterance, then this attempts to retrieve it from the voice.- Specified by:
getObject
in interfaceFeatureSet
- Parameters:
name
- the name of the feature- Returns:
- the value associated with the name or null if the value is not found
-
setInt
Convenience method that sets the named feature as an int.- Specified by:
setInt
in interfaceFeatureSet
- Parameters:
name
- the name of the featurevalue
- the value of the feature
-
setFloat
Convenience method that sets the named feature as a float.- Specified by:
setFloat
in interfaceFeatureSet
- Parameters:
name
- the name of the featurevalue
- the value of the feature
-
setString
Convenience method that sets the named feature as a String.- Specified by:
setString
in interfaceFeatureSet
- Parameters:
name
- the name of the featurevalue
- the value of the feature
-
setObject
Sets the named feature.- Specified by:
setObject
in interfaceFeatureSet
- Parameters:
name
- the name of the featurevalue
- the value of the feature
-
getItem
Returns the Item in the given Relation associated with the given time.- Parameters:
relation
- the name of the relationtime
- the time- Throws:
IllegalStateException
- if the Segment durations have not been calculated in the Utterance or if the given relation is not present in the Utterance
-
getDuration
public float getDuration()Returns the duration of this Utterance in seconds. It does this by looking at last Item in the following Relations, in this order: Segment, Target. If none of these Relations exist, or if these Relations contain no Items, an IllegalStateException will be thrown.- Returns:
- the duration of this Utterance in seconds
-
isFirst
public boolean isFirst()Returns true if this utterance is the first is a series of utterances.- Returns:
- true if this is the first utterance in a series of connected utterances.
-
setFirst
public void setFirst(boolean first) Sets this utterance as the first in a series.- Parameters:
first
- if true, the item is the first in a series
-
isLast
public boolean isLast()Returns true if this utterance is the last is a series of utterances.- Returns:
- true if this is the last utterance in a series of connected utterances.
-
setLast
public void setLast(boolean last) Sets this utterance as the last in a series.- Parameters:
last
- if true, the item is the last in a series
-