marytts.tools.voiceimport
Class PhoneLabelFeatureAligner

java.lang.Object
  extended by marytts.tools.voiceimport.VoiceImportComponent
      extended by marytts.tools.voiceimport.PhoneLabelFeatureAligner
Direct Known Subclasses:
HalfPhoneLabelFeatureAligner

public class PhoneLabelFeatureAligner
extends VoiceImportComponent

Compare unit label and unit feature files. If they don't align, flag a problem; let the user decide how to fix it -- either by editing the unit label file or by editing a rawmaryxml file and recomputing the features file.

Author:
schroed

Nested Class Summary
static class PhoneLabelFeatureAligner.EditFrameShower
           
 
Field Summary
protected  AllophonesExtractor allophoneExtractor
           
protected  boolean correctedPauses
           
protected  DatabaseLayout db
           
protected  java.lang.String featsDir
           
protected  java.lang.String featsExt
           
protected  PhoneUnitFeatureComputer featureComputer
           
protected  java.lang.String labDir
           
protected  PhoneUnitLabelComputer labelComputer
           
protected  java.lang.String labExt
           
protected  java.lang.String pauseSymbol
           
protected  int percent
           
protected  java.util.Map<java.lang.String,java.lang.String> problems
           
protected static int REMOVE
           
protected static int REMOVEALL
           
protected static int SKIP
           
protected static int SKIPALL
           
protected  TranscriptionAligner transcriptionAligner
           
protected static int TRYAGAIN
           
 
Fields inherited from class marytts.tools.voiceimport.VoiceImportComponent
bnl, logger, props, props2Help
 
Constructor Summary
PhoneLabelFeatureAligner()
           
 
Method Summary
 boolean compute()
          Align labels and features.
protected  int correctPauses()
          Try to automatically correct misalignment caused by pauses: If there is a pause in the label file and not in the feature file, it is removed in the label file.
protected  int correctPausesYesNo(int numProblems)
          Let the user select if he wants to run the the automatic correction of pauses.
protected  void customInitialisation()
           
protected  void defineReplacementInfo(java.lang.String text)
           
protected  void defineReplacements(java.lang.String text)
           
protected  void defineReplacementWindow()
           
protected  void deleteProblemsYesNo(java.util.Map<java.lang.String,java.lang.String> someProblems, java.lang.String basename)
          Let the user select if he wants to run the the automatic correction of pauses.
 java.util.SortedMap<java.lang.String,java.lang.String> getDefaultProps(DatabaseLayout theDb)
          Get the map of properties2values containing the default values
 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  int letUserCorrect(java.lang.String basename, java.lang.String errorMessage)
           
static void main(java.lang.String[] args)
           
protected  void setupHelp()
           
protected  java.lang.String verifyAlignment(java.lang.String basename)
          Verify if the feature and label files for basename align OK.
 
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

featureComputer

protected PhoneUnitFeatureComputer featureComputer

allophoneExtractor

protected AllophonesExtractor allophoneExtractor

labelComputer

protected PhoneUnitLabelComputer labelComputer

transcriptionAligner

protected TranscriptionAligner transcriptionAligner

pauseSymbol

protected java.lang.String pauseSymbol

db

protected DatabaseLayout db

percent

protected int percent

problems

protected java.util.Map<java.lang.String,java.lang.String> problems

correctedPauses

protected boolean correctedPauses

featsExt

protected java.lang.String featsExt

labExt

protected java.lang.String labExt

labDir

protected java.lang.String labDir

featsDir

protected java.lang.String featsDir

TRYAGAIN

protected static final int TRYAGAIN
See Also:
Constant Field Values

SKIP

protected static final int SKIP
See Also:
Constant Field Values

SKIPALL

protected static final int SKIPALL
See Also:
Constant Field Values

REMOVE

protected static final int REMOVE
See Also:
Constant Field Values

REMOVEALL

protected static final int REMOVEALL
See Also:
Constant Field Values
Constructor Detail

PhoneLabelFeatureAligner

public PhoneLabelFeatureAligner()
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

customInitialisation

protected void customInitialisation()

initialiseComp

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

Overrides:
initialiseComp in class VoiceImportComponent
Throws:
java.lang.Exception

getDefaultProps

public java.util.SortedMap<java.lang.String,java.lang.String> getDefaultProps(DatabaseLayout theDb)
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
Align labels and features. For each .phonelab file in the phone label directory, verify whether the chain of units given is identical to the chain of units in the corresponding unit feature file. For those files that are not perfectly aligned, give the user the opportunity to correct alignment.

Specified by:
compute in class VoiceImportComponent
Returns:
a boolean indicating whether or not the database is fully aligned.
Throws:
java.lang.Exception

correctPausesYesNo

protected int correctPausesYesNo(int numProblems)
                          throws java.io.IOException
Let the user select if he wants to run the the automatic correction of pauses.

Parameters:
numProblems - the number of problems
Returns:
the number of problems remaining
Throws:
java.io.IOException

deleteProblemsYesNo

protected void deleteProblemsYesNo(java.util.Map<java.lang.String,java.lang.String> someProblems,
                                   java.lang.String basename)
                            throws java.io.IOException
Let the user select if he wants to run the the automatic correction of pauses.

Parameters:
someProblems -
Throws:
java.io.IOException

defineReplacementWindow

protected void defineReplacementWindow()

defineReplacementInfo

protected void defineReplacementInfo(java.lang.String text)

correctPauses

protected int correctPauses()
                     throws java.io.IOException
Try to automatically correct misalignment caused by pauses: If there is a pause in the label file and not in the feature file, it is removed in the label file. If there is a pause in the feature file and not in the label file, a pause of length zero is inserted in the label file

Parameters:
basename -
Returns:
the number of problems remaining
Throws:
java.io.IOException

defineReplacements

protected void defineReplacements(java.lang.String text)
                           throws java.lang.Exception
Throws:
java.lang.Exception

verifyAlignment

protected java.lang.String verifyAlignment(java.lang.String basename)
                                    throws java.io.IOException
Verify if the feature and label files for basename align OK. This method should be called after firstVerifyAlignment for subsequent alignment tries.

Parameters:
basename -
Returns:
null if the alignment was OK, or a String containing an error message.
Throws:
java.io.IOException

letUserCorrect

protected int letUserCorrect(java.lang.String basename,
                             java.lang.String errorMessage)
                      throws java.lang.Exception
Throws:
java.lang.Exception

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception

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.