marytts.tools.voiceimport
Class PhoneUnitLabelComputer

java.lang.Object
  extended by marytts.tools.voiceimport.VoiceImportComponent
      extended by marytts.tools.voiceimport.PhoneUnitLabelComputer
Direct Known Subclasses:
HalfPhoneUnitLabelComputer

public class PhoneUnitLabelComputer
extends VoiceImportComponent

Compute unit labels from phone labels.

Author:
schroed

Field Summary
protected  int basenameIndex
           
protected  DatabaseLayout db
           
 java.lang.String LABELDIR
           
protected  java.lang.String pauseSymbol
           
protected  int percent
           
protected  java.io.File phonelabelDir
           
protected  java.io.File unitlabelDir
           
protected  java.lang.String unitlabelExt
           
 
Fields inherited from class marytts.tools.voiceimport.VoiceImportComponent
bnl, logger, props, props2Help
 
Constructor Summary
PhoneUnitLabelComputer()
           
 
Method Summary
 boolean compute()
          Do the computations required by this component.
 void computePhoneLabel(java.lang.String baseName)
           
 java.util.SortedMap getDefaultProps(DatabaseLayout db)
          Get the map of properties2values containing the default values
protected  java.util.List<java.lang.Double> getMidTimes(java.util.List<java.lang.String> labels, java.util.List<java.lang.Double> endTimes)
          Get mid points for an utterance, given a list its phone labels and a list of corresponding end points.
 java.lang.String getName()
          Get the name of this component
 int getProgress()
          Provide the progress of computation, in percent, or -1 if that feature is not implemented.
 void initialiseComp()
          Initialise a voice import component: component specific initialisation; to be overwritten by subclasses
protected  void setupHelp()
           
protected  java.lang.String[] toUnitLabels(java.util.List<java.lang.String> labels, java.util.List<java.lang.Double> endTimes, java.util.List<java.lang.Double> midTimes)
          Generate a sequence of Strings, corresponding to the lines in an Xwaves-compatible label file, by interleaving a List of label Strings with a List of end time points.
protected  java.lang.String[] toUnitLabels(java.lang.String[] phoneLabels)
          Deprecated. 
 
Methods inherited from class marytts.tools.voiceimport.VoiceImportComponent
getHelpText, getHelpTextForProp, getProp, initialise, setProp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

phonelabelDir

protected java.io.File phonelabelDir

unitlabelDir

protected java.io.File unitlabelDir

pauseSymbol

protected java.lang.String pauseSymbol

unitlabelExt

protected java.lang.String unitlabelExt

db

protected DatabaseLayout db

percent

protected int percent

basenameIndex

protected int basenameIndex

LABELDIR

public java.lang.String LABELDIR
Constructor Detail

PhoneUnitLabelComputer

public PhoneUnitLabelComputer()
Method Detail

getName

public java.lang.String getName()
Description copied from class: VoiceImportComponent
Get the name of this component

Specified by:
getName in class VoiceImportComponent
Returns:
the name

initialiseComp

public void initialiseComp()
Description copied from class: VoiceImportComponent
Initialise a voice import component: component specific initialisation; to be overwritten by subclasses

Overrides:
initialiseComp in class VoiceImportComponent

getDefaultProps

public java.util.SortedMap getDefaultProps(DatabaseLayout db)
Description copied from class: VoiceImportComponent
Get the map of properties2values containing the default values

Specified by:
getDefaultProps in class VoiceImportComponent
Returns:
map of props2values

setupHelp

protected void setupHelp()
Specified by:
setupHelp in class VoiceImportComponent

compute

public boolean compute()
                throws java.lang.Exception
Description copied from class: VoiceImportComponent
Do the computations required by this component.

Specified by:
compute in class VoiceImportComponent
Returns:
true on success, false on failure
Throws:
java.lang.Exception

computePhoneLabel

public void computePhoneLabel(java.lang.String baseName)
                       throws java.lang.Exception
Throws:
java.lang.Exception

getMidTimes

protected java.util.List<java.lang.Double> getMidTimes(java.util.List<java.lang.String> labels,
                                                       java.util.List<java.lang.Double> endTimes)
Get mid points for an utterance, given a list its phone labels and a list of corresponding end points.

Parameters:
labels - of the phones
endTimes - of the phones
Returns:
a list of midpoint times (in seconds) for the phones

toUnitLabels

@Deprecated
protected java.lang.String[] toUnitLabels(java.lang.String[] phoneLabels)
Deprecated. 

Convert phone labels to unit labels. This base implementation returns the phone labels; subclasses may want to override that behaviour.

Parameters:
phoneLabels - the phone labels, one phone per line, with each line containing three fields: 1. the end time of the current phone, in seconds, since the beginning of the file; 2. a number to be ignored; 3. the phone symbol.
Returns:
an array of lines, in the same format as the phoneLabels input array, but with unit symbols instead of phone symbols. The number in the middle now denotes the unit index. This array may or may not have the same number of lines as phoneLabels.

toUnitLabels

protected java.lang.String[] toUnitLabels(java.util.List<java.lang.String> labels,
                                          java.util.List<java.lang.Double> endTimes,
                                          java.util.List<java.lang.Double> midTimes)
Generate a sequence of Strings, corresponding to the lines in an Xwaves-compatible label file, by interleaving a List of label Strings with a List of end time points.

Parameters:
labels - a List of label Strings
endTimes - a List of time points representing the end points of these labels
midTimes - a List of time points representing the mid points of these labels (can be null)
Returns:
the label files lines

getProgress

public int getProgress()
Provide the progress of computation, in percent, or -1 if that feature is not implemented.

Specified by:
getProgress in class VoiceImportComponent
Returns:
-1 if not implemented, or an integer between 0 and 100.