Package com.sun.speech.freetts
Class Utterance
- java.lang.Object
-
- com.sun.speech.freetts.Utterance
-
- All Implemented Interfaces:
Dumpable,FeatureSet,java.io.Serializable
public class Utterance extends java.lang.Object implements FeatureSet, java.io.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:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RelationcreateRelation(java.lang.String name)Creates a new relation with the given name and adds it to this utterance.voiddump(java.io.PrintWriter output, int pad, java.lang.String title)Dumps this utterance in textual form.voiddump(java.io.PrintWriter output, int pad, java.lang.String title, boolean justRelations)Dumps this utterance in textual form.voiddump(java.io.PrintWriter output, java.lang.String title)Dumps this utterance in textual form.voiddump(java.lang.String title)Dumps this utterance in textual form.voiddumpRelations(java.lang.String title)Dumps the utterance in textual formfloatgetDuration()Returns the duration of this Utterance in seconds.floatgetFloat(java.lang.String name)Convenience method that returns the named feature as a float.intgetInt(java.lang.String name)Convenience method that returns the named feature as a int.ItemgetItem(java.lang.String relation, float time)Returns the Item in the given Relation associated with the given time.java.lang.ObjectgetObject(java.lang.String name)Returns the named feature as an object.RelationgetRelation(java.lang.String name)Retrieves a relation from this utterance.FreeTTSSpeakablegetSpeakable()Returns the queueitem associated with this utterance.java.lang.StringgetString(java.lang.String name)Convenience method that returns the named feature as a string.VoicegetVoice()Retrieves the Voice associated with this Utterance.booleanhasRelation(java.lang.String name)Determines if this utterance contains a relation with the given name.booleanisFirst()Returns true if this utterance is the first is a series of utterances.booleanisLast()Returns true if this utterance is the last is a series of utterances.booleanisPresent(java.lang.String name)Determines if the given feature is present.voidremove(java.lang.String name)Removes the named feature from this set of features.voidsetFirst(boolean first)Sets this utterance as the first in a series.voidsetFloat(java.lang.String name, float value)Convenience method that sets the named feature as a float.voidsetInt(java.lang.String name, int value)Convenience method that sets the named feature as an int.voidsetLast(boolean last)Sets this utterance as the last in a series.voidsetObject(java.lang.String name, java.lang.Object value)Sets the named feature.voidsetSpeakable(FreeTTSSpeakable speakable)Sets the speakable item for this utterance.voidsetString(java.lang.String name, java.lang.String value)Convenience method that sets the named feature as a String.
-
-
-
Constructor Detail
-
Utterance
public Utterance(Voice voice)
Creates a new, empty utterance.- Parameters:
voice- the voice associated with the utterance
-
Utterance
public Utterance(Voice voice, java.util.List tokenList)
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 Detail
-
setSpeakable
public void setSpeakable(FreeTTSSpeakable speakable)
Sets the speakable item for this utterance.- Parameters:
speakable- the speakable item for this utterance
-
getSpeakable
public FreeTTSSpeakable getSpeakable()
Returns the queueitem associated with this utterance.- Returns:
- the queue item
-
createRelation
public Relation createRelation(java.lang.String name)
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
public Relation getRelation(java.lang.String name)
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
public boolean hasRelation(java.lang.String name)
Determines if this utterance contains a relation with the given name.- Parameters:
name- the name of the relation of interest.
-
getVoice
public Voice getVoice()
Retrieves the Voice associated with this Utterance.- Returns:
- the voice associated with this utterance.
-
dump
public void dump(java.io.PrintWriter output, int pad, java.lang.String title, boolean justRelations)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
public void dump(java.io.PrintWriter output, int pad, java.lang.String title)Dumps this utterance in textual form.- Specified by:
dumpin interfaceDumpable- Specified by:
dumpin interfaceFeatureSet- Parameters:
output- where to send the formatted outputpad- the initial paddingtitle- the title to print when dumping out the utterance
-
dump
public void dump(java.io.PrintWriter output, java.lang.String title)Dumps this utterance in textual form.- Parameters:
output- where to send the formatted outputtitle- the title to print when dumping out the utterance
-
dump
public void dump(java.lang.String title)
Dumps this utterance in textual form.- Parameters:
title- the title to print when dumping out the utterance
-
dumpRelations
public void dumpRelations(java.lang.String title)
Dumps the utterance in textual form- Parameters:
title- the title to print when dumping out the utterance
-
isPresent
public boolean isPresent(java.lang.String name)
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:
isPresentin interfaceFeatureSet- Parameters:
name- the name of the feature of interest- Returns:
- true if the named feature is present
-
remove
public void remove(java.lang.String name)
Removes the named feature from this set of features.- Specified by:
removein interfaceFeatureSet- Parameters:
name- the name of the feature of interest
-
getString
public java.lang.String getString(java.lang.String name)
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:
getStringin interfaceFeatureSet- Parameters:
name- the name of the feature- Returns:
- the value associated with the name or null if the value is not found
- Throws:
java.lang.ClassCastException- if the associated value is not a String
-
getInt
public int getInt(java.lang.String name)
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:
getIntin interfaceFeatureSet- Parameters:
name- the name of the feature- Returns:
- the value associated with the name or null if the value is not found
- Throws:
java.lang.ClassCastException- if the associated value is not an int
-
getFloat
public float getFloat(java.lang.String name)
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:
getFloatin interfaceFeatureSet- Parameters:
name- the name of the feature- Returns:
- the value associated with the name or null if the value is not found
- Throws:
java.lang.ClassCastException- if the associated value is not a float
-
getObject
public java.lang.Object getObject(java.lang.String name)
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:
getObjectin interfaceFeatureSet- Parameters:
name- the name of the feature- Returns:
- the value associated with the name or null if the value is not found
-
setInt
public void setInt(java.lang.String name, int value)Convenience method that sets the named feature as an int.- Specified by:
setIntin interfaceFeatureSet- Parameters:
name- the name of the featurevalue- the value of the feature
-
setFloat
public void setFloat(java.lang.String name, float value)Convenience method that sets the named feature as a float.- Specified by:
setFloatin interfaceFeatureSet- Parameters:
name- the name of the featurevalue- the value of the feature
-
setString
public void setString(java.lang.String name, java.lang.String value)Convenience method that sets the named feature as a String.- Specified by:
setStringin interfaceFeatureSet- Parameters:
name- the name of the featurevalue- the value of the feature
-
setObject
public void setObject(java.lang.String name, java.lang.Object value)Sets the named feature.- Specified by:
setObjectin interfaceFeatureSet- Parameters:
name- the name of the featurevalue- the value of the feature
-
getItem
public Item getItem(java.lang.String relation, float time)
Returns the Item in the given Relation associated with the given time.- Parameters:
relation- the name of the relationtime- the time- Throws:
java.lang.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
-
-