marytts.modules.acoustic
Class Model

java.lang.Object
  extended by marytts.modules.acoustic.Model
Direct Known Subclasses:
BoundaryModel, CARTModel, HMMModel, SoPModel

public abstract class Model
extends java.lang.Object

Base class for acoustic modeling; specific Models should extend this and override methods as needed.

Author:
steiner

Field Summary
protected  java.lang.String applyTo
           
protected  java.lang.String dataFile
          The file name from which we will read our acoustic model.
protected  TargetFeatureComputer featureComputer
          The producer of feature vectors for the features in predictionFeatureNames as computed by the feature processors in featureManager.
protected  FeatureProcessorManager featureManager
          The feature processors used for prediction.
protected  java.lang.String featureName
          The name of the predicted acoustic feature, if any.
protected  java.lang.String predictFrom
           
protected  java.lang.String predictionFeatureNames
          The names of the features used for prediction.
protected  java.lang.String targetAttributeFormat
           
protected  java.lang.String targetAttributeName
          The attribute into which the predicted acoustic feature should be written.
 
Constructor Summary
protected Model(FeatureProcessorManager featureManager, java.lang.String dataFileName, java.lang.String targetAttributeName, java.lang.String targetAttributeFormat, java.lang.String featureName, java.lang.String predictFrom, java.lang.String applyTo)
          Model constructor
 
Method Summary
 void applyFromTo(java.util.List<org.w3c.dom.Element> predictFromElements, java.util.List<org.w3c.dom.Element> applyToElements)
          Apply this Model to a List of Elements, predicting from a different List of Elements
 void applyTo(java.util.List<org.w3c.dom.Element> elements)
          Apply this Model to a List of Elements, predicting from those same Elements
protected abstract  float evaluate(Target target)
          Evaluate model on a Target to obtain the target value as a float.
 java.lang.String getApplyTo()
           
 java.lang.String getDataFileName()
           
 java.lang.String getFeatureName()
           
 java.lang.String getPredictFrom()
           
 java.lang.String getTargetAttributeName()
           
protected  java.util.List<Target> getTargets(java.util.List<org.w3c.dom.Element> elements)
          For a list of PHONE elements, return a list of Targets, where each Target is constructed from the corresponding Element.
protected  void load()
          Try to load this model and set the target feature computer appropriately.
protected abstract  void loadDataFile()
          Load dataFile for this model; only extension classes know how to do this
protected  void setupFeatureComputer()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataFile

protected java.lang.String dataFile
The file name from which we will read our acoustic model.


targetAttributeName

protected java.lang.String targetAttributeName
The attribute into which the predicted acoustic feature should be written.


targetAttributeFormat

protected java.lang.String targetAttributeFormat

featureName

protected java.lang.String featureName
The name of the predicted acoustic feature, if any. The feature processor that will be created from this will read the value from targetAttributeName.


featureManager

protected FeatureProcessorManager featureManager
The feature processors used for prediction.


predictionFeatureNames

protected java.lang.String predictionFeatureNames
The names of the features used for prediction.


featureComputer

protected TargetFeatureComputer featureComputer
The producer of feature vectors for the features in predictionFeatureNames as computed by the feature processors in featureManager.


predictFrom

protected java.lang.String predictFrom

applyTo

protected java.lang.String applyTo
Constructor Detail

Model

protected Model(FeatureProcessorManager featureManager,
                java.lang.String dataFileName,
                java.lang.String targetAttributeName,
                java.lang.String targetAttributeFormat,
                java.lang.String featureName,
                java.lang.String predictFrom,
                java.lang.String applyTo)
Model constructor

Parameters:
featureManager - the feature processor manager used to compute the symbolic features used for prediction
dataFileName - data file for this Model
targetAttributeName - attribute in MaryXML to predict
targetAttributeFormat - printf-style format String to specify the attribute value, i.e. "%.3f" to round to 3 decimal places; "%s" by default
featureName - name of the custom continuous feature predicted by this model, or null
predictFrom - key of Element Lists from which to predict values; "segments" by default
applyTo - key of Element Lists to which to apply values; "segments" by default
Method Detail

load

protected final void load()
                   throws MaryConfigurationException
Try to load this model and set the target feature computer appropriately. This must be called from the constructor of subclasses, so that the subclass implementation of loadDataFile() is visible.

Throws:
MaryConfigurationException - if the model cannot be set up properly.

loadDataFile

protected abstract void loadDataFile()
                              throws java.io.IOException,
                                     MaryConfigurationException
Load dataFile for this model; only extension classes know how to do this

Throws:
java.io.IOException - if any files cannot be properly read
MaryConfigurationException - if files can be read but contain problematic content

setupFeatureComputer

protected final void setupFeatureComputer()
                                   throws MaryConfigurationException
Throws:
MaryConfigurationException

applyTo

public void applyTo(java.util.List<org.w3c.dom.Element> elements)
             throws MaryConfigurationException
Apply this Model to a List of Elements, predicting from those same Elements

Parameters:
elements - Elements for which to predict the values
Throws:
MaryConfigurationException - if attribute values cannot be predicted because of an invalid voice configuration

applyFromTo

public void applyFromTo(java.util.List<org.w3c.dom.Element> predictFromElements,
                        java.util.List<org.w3c.dom.Element> applyToElements)
                 throws MaryConfigurationException
Apply this Model to a List of Elements, predicting from a different List of Elements

Parameters:
predictFromElements - Elements from which to predict the values
applyToElements - Elements to which to apply the values predicted by this Model
Throws:
MaryConfigurationException - if attribute values cannot be predicted because of an invalid voice configuration

getTargets

protected java.util.List<Target> getTargets(java.util.List<org.w3c.dom.Element> elements)
For a list of PHONE elements, return a list of Targets, where each Target is constructed from the corresponding Element.

Parameters:
elements - List of Elements
Returns:
List of Targets

evaluate

protected abstract float evaluate(Target target)
                           throws java.lang.Exception
Evaluate model on a Target to obtain the target value as a float.

Parameters:
target -
Returns:
target value
Throws:
java.lang.Exception - if the target value cannot be predicted

getDataFileName

public java.lang.String getDataFileName()
Returns:
the dataFile name

getFeatureName

public java.lang.String getFeatureName()
Returns:
the featureName

getTargetAttributeName

public java.lang.String getTargetAttributeName()
Returns:
the targetAttributeName

getPredictFrom

public java.lang.String getPredictFrom()
Returns:
the key of Element Lists from which to predict with this Model

getApplyTo

public java.lang.String getApplyTo()
Returns:
the key of Element Lists to which to apply this Model