de.dfki.lt.mary.modules
Class Utt2XMLBase

java.lang.Object
  extended by de.dfki.lt.mary.modules.InternalModule
      extended by de.dfki.lt.mary.modules.Utt2XMLBase
All Implemented Interfaces:
MaryModule
Direct Known Subclasses:
Utt2XMLAcoustParams, Utt2XMLDurationsEn, Utt2XMLIntonationEn, Utt2XMLPausesEn, Utt2XMLPhrasesEn, Utt2XMLPosEn, Utt2XMLPostprocessedEn, Utt2XMLSegmentsEn, Utt2XMLTokensEn, Utt2XMLWordsEn

public abstract class Utt2XMLBase
extends InternalModule

Convert FreeTTS utterances into MaryXML format. This abstract base class is to provide the common part for all Utterance to MaryXML converters.

Author:
Marc Schröder

Field Summary
protected  javax.xml.parsers.DocumentBuilder docBuilder
           
protected  javax.xml.parsers.DocumentBuilderFactory factory
           
 
Fields inherited from class de.dfki.lt.mary.modules.InternalModule
logger, state
 
Fields inherited from interface de.dfki.lt.mary.modules.MaryModule
MODULE_OFFLINE, MODULE_RUNNING
 
Constructor Summary
Utt2XMLBase(java.lang.String name, MaryDataType input, MaryDataType output)
           
 
Method Summary
protected abstract  void fillSentence(org.w3c.dom.Element sentence, com.sun.speech.freetts.Utterance utterance)
          Depending on the data type, find the right information in the utterance and insert it into the sentence.
protected  java.lang.String insertSegment(com.sun.speech.freetts.Item segmentItem, org.w3c.dom.Element syllable, boolean deep)
          Convert an item in the Segment relation into XML, inserting it at the specified location in the XML tree.
protected  java.lang.String insertSyllable(com.sun.speech.freetts.Item syllableItem, org.w3c.dom.Element token, boolean deep)
          Convert an item in the Syllable relation into XML, inserting it at the specified location in the XML tree.
protected  void insertToken(com.sun.speech.freetts.Item tokenItem, org.w3c.dom.Element parent)
          Convert an item in the Token relation into XML, inserting it at the specified location in the XML tree.
protected  void insertToken(com.sun.speech.freetts.Item tokenItem, org.w3c.dom.Element parent, boolean deep)
          Convert an item in the Token relation into XML, inserting it at the specified location in the XML tree.
 MaryData process(MaryData d)
          Perform this module's processing on abstract "MaryData" input d.
 void startup()
          Allow the module to start up, performing whatever is necessary to become operational.
 
Methods inherited from class de.dfki.lt.mary.modules.InternalModule
getState, inputType, name, outputType, powerOnSelfTest, shutdown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

factory

protected javax.xml.parsers.DocumentBuilderFactory factory

docBuilder

protected javax.xml.parsers.DocumentBuilder docBuilder
Constructor Detail

Utt2XMLBase

public Utt2XMLBase(java.lang.String name,
                   MaryDataType input,
                   MaryDataType output)
Method Detail

startup

public void startup()
             throws java.lang.Exception
Description copied from interface: MaryModule
Allow the module to start up, performing whatever is necessary to become operational. After successful completion, getState() should return MODULE_RUNNING.

Specified by:
startup in interface MaryModule
Overrides:
startup in class InternalModule
Throws:
java.lang.Exception

process

public MaryData process(MaryData d)
                 throws java.lang.Exception
Description copied from class: InternalModule
Perform this module's processing on abstract "MaryData" input d. Subclasses need to make sure that the process() method is thread-safe, because in server-mode, it will be called from different threads at the same time. A sensible way to do this seems to be not to use any global or static variables, or to use them read-only.

Specified by:
process in interface MaryModule
Overrides:
process in class InternalModule
Returns:
A MaryData object of type outputType() encapsulating the processing result.

This method just returns its input. Subclasses should override this.

Throws:
java.lang.Exception

fillSentence

protected abstract void fillSentence(org.w3c.dom.Element sentence,
                                     com.sun.speech.freetts.Utterance utterance)
Depending on the data type, find the right information in the utterance and insert it into the sentence.


insertToken

protected void insertToken(com.sun.speech.freetts.Item tokenItem,
                           org.w3c.dom.Element parent)
Convert an item in the Token relation into XML, inserting it at the specified location in the XML tree.


insertToken

protected void insertToken(com.sun.speech.freetts.Item tokenItem,
                           org.w3c.dom.Element parent,
                           boolean deep)
Convert an item in the Token relation into XML, inserting it at the specified location in the XML tree.

Parameters:
deep - whether to create a deep structure of and elements or not.

insertSyllable

protected java.lang.String insertSyllable(com.sun.speech.freetts.Item syllableItem,
                                          org.w3c.dom.Element token,
                                          boolean deep)
Convert an item in the Syllable relation into XML, inserting it at the specified location in the XML tree.

Parameters:
deep - whether to create a deep structure of and elements or not.

insertSegment

protected java.lang.String insertSegment(com.sun.speech.freetts.Item segmentItem,
                                         org.w3c.dom.Element syllable,
                                         boolean deep)
Convert an item in the Segment relation into XML, inserting it at the specified location in the XML tree.

Parameters:
deep - whether to create a deep structure of and elements or not.