de.dfki.lt.mary.modules
Class XML2UttBase

java.lang.Object
  extended by de.dfki.lt.mary.modules.InternalModule
      extended by de.dfki.lt.mary.modules.XML2UttBase
All Implemented Interfaces:
MaryModule
Direct Known Subclasses:
XML2UttAcoustParams, XML2UttDurationsEn, XML2UttIntonationEn, XML2UttPausesEn, XML2UttPhrasesEn, XML2UttPosEn, XML2UttPostprocessedEn, XML2UttSegmentsEn, XML2UttTokensEn, XML2UttWordsEn

public abstract class XML2UttBase
extends InternalModule

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

Author:
Marc Schröder

Field Summary
protected  int lastTargetIndex
           
protected  int nextTargetIndex
           
 
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
XML2UttBase(java.lang.String name, MaryDataType input, MaryDataType output)
           
 
Method Summary
protected  java.lang.String addOneElement(com.sun.speech.freetts.Utterance utterance, org.w3c.dom.Element element, boolean createWordRelation, boolean createSylStructRelation, boolean createTargetRelation)
          To a given utterance in which relations have already been created appropriately, add a single boundary, t or mtu element.
protected  com.sun.speech.freetts.Item appendTokenItem(com.sun.speech.freetts.Relation tokenRelation, java.lang.String tokenText)
          Append one item to the token relation, and return it.
protected  com.sun.speech.freetts.Item createSylStructure(com.sun.speech.freetts.Item wordItem, org.w3c.dom.Element t, boolean createTargetRelation)
           
protected abstract  void fillUtterance(com.sun.speech.freetts.Utterance utterance, org.w3c.dom.Element sentence)
          Depending on the data type, find the right information in the sentence and insert it into the utterance.
protected  void fillUtterance(com.sun.speech.freetts.Utterance utterance, org.w3c.dom.Element sentence, boolean createWordRelation, boolean createSylStructRelation, boolean createTargetRelation)
          Depending on the data type, find the right information in the sentence and insert it into the utterance.
protected  com.sun.speech.freetts.Item insertWordItem(com.sun.speech.freetts.Relation wordRelation, com.sun.speech.freetts.Relation phraseRelation, com.sun.speech.freetts.Item tokenItem, org.w3c.dom.Element wordElement)
           
 MaryData process(MaryData d)
          Perform this module's processing on abstract "MaryData" input d.
protected  java.lang.String searchFollowingMarks(org.w3c.dom.Element element)
          Search forewards for mark elements that occur between the given element and the preceding (if any) element with the same tagname.
protected  java.lang.String searchFollowingMarks(org.w3c.dom.Element element, java.lang.String[] tagnames)
          Search forewards for mark elements that occur between the given element and the preceding (if any) element with one of the given tagnames.
protected  java.lang.String searchPrecedingMarks(org.w3c.dom.Element element)
          Search backwards for mark elements that occur between the given element and the preceding (if any) element with the same tagname.
protected  java.lang.String searchPrecedingMarks(org.w3c.dom.Element element, java.lang.String[] tagnames)
          Search backwards for mark elements that occur between the given element and the preceding (if any) element with one of the given tagnames.
 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

lastTargetIndex

protected int lastTargetIndex

nextTargetIndex

protected int nextTargetIndex
Constructor Detail

XML2UttBase

public XML2UttBase(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

fillUtterance

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


fillUtterance

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


addOneElement

protected java.lang.String addOneElement(com.sun.speech.freetts.Utterance utterance,
                                         org.w3c.dom.Element element,
                                         boolean createWordRelation,
                                         boolean createSylStructRelation,
                                         boolean createTargetRelation)
To a given utterance in which relations have already been created appropriately, add a single boundary, t or mtu element.

Parameters:
utterance -
element -
createWordRelation -
createSylStructRelation -
createTargetRelation -
Returns:
a string containing the text in this element, or an empty string

appendTokenItem

protected com.sun.speech.freetts.Item appendTokenItem(com.sun.speech.freetts.Relation tokenRelation,
                                                      java.lang.String tokenText)
Append one item to the token relation, and return it. If tokenText is null, a "placeholder" token item will be created, in which no "name" feature is present, but to which other features can already be added. If the tail of tokenRelation is such a placeholder token, the tokenText will be set as that placeholder's name feature, and the ex-placeholder item will be returned. If the tail of tokenRelation is a placeholder and tokenText is null, no new placeholder will be created, i.e. it is not possible to create two subsequent placeholder items.

Parameters:
tokenRelation -
tokenText -
Returns:
the new item

insertWordItem

protected com.sun.speech.freetts.Item insertWordItem(com.sun.speech.freetts.Relation wordRelation,
                                                     com.sun.speech.freetts.Relation phraseRelation,
                                                     com.sun.speech.freetts.Item tokenItem,
                                                     org.w3c.dom.Element wordElement)

createSylStructure

protected com.sun.speech.freetts.Item createSylStructure(com.sun.speech.freetts.Item wordItem,
                                                         org.w3c.dom.Element t,
                                                         boolean createTargetRelation)

searchPrecedingMarks

protected java.lang.String searchPrecedingMarks(org.w3c.dom.Element element)
Search backwards for mark elements that occur between the given element and the preceding (if any) element with the same tagname.

Parameters:
element -
Returns:
A String containing a comma-separated list of all marks found between the given element and the preceding element with the same name, or null if no mark was found.

searchPrecedingMarks

protected java.lang.String searchPrecedingMarks(org.w3c.dom.Element element,
                                                java.lang.String[] tagnames)
Search backwards for mark elements that occur between the given element and the preceding (if any) element with one of the given tagnames.

Parameters:
element -
tagnames -
Returns:
A String containing a comma-separated list of all marks found between the given element and the preceding element with the same name, or null if no mark was found.

searchFollowingMarks

protected java.lang.String searchFollowingMarks(org.w3c.dom.Element element)
Search forewards for mark elements that occur between the given element and the preceding (if any) element with the same tagname.

Parameters:
element -
Returns:
A String containing a comma-separated list of all marks found between the given element and the preceding element with the same name, or null if no mark was found.

searchFollowingMarks

protected java.lang.String searchFollowingMarks(org.w3c.dom.Element element,
                                                java.lang.String[] tagnames)
Search forewards for mark elements that occur between the given element and the preceding (if any) element with one of the given tagnames.

Parameters:
element -
tagnames -
Returns:
A String containing a comma-separated list of all marks found between the given element and the preceding element with the same name, or null if no mark was found.