marytts.modules
Class Utt2XMLBase

java.lang.Object
  extended by marytts.modules.InternalModule
      extended by marytts.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 marytts.modules.InternalModule
logger, state
 
Fields inherited from interface marytts.modules.MaryModule
MODULE_OFFLINE, MODULE_RUNNING
 
Constructor Summary
Utt2XMLBase(java.lang.String name, MaryDataType input, MaryDataType output, java.util.Locale locale)
           
 
Method Summary
protected  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  org.w3c.dom.Element insertProsodySettings(org.w3c.dom.Element insertHere, com.sun.speech.freetts.FeatureSet featureSet)
          For a given utterance or token, see if there are any prosodic settings defined, and if so, create a corresponding prosody element as a child of insertHere.
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.
 java.lang.String phoneArray2phoneString(AllophoneSet allophoneSet, java.lang.String[] voicePhones)
          Converts an array of phone symbol strings into a single phone string.
 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 marytts.modules.InternalModule
getLocale, 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,
                   java.util.Locale locale)
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 final 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.

insertProsodySettings

protected org.w3c.dom.Element insertProsodySettings(org.w3c.dom.Element insertHere,
                                                    com.sun.speech.freetts.FeatureSet featureSet)
For a given utterance or token, see if there are any prosodic settings defined, and if so, create a corresponding prosody element as a child of insertHere.

Parameters:
featureSet - an utterance, optionally containing prosody settings
insertHere - an element into which to insert the new prosody element if required.
Returns:
the new prosody element, or null if none was created.

phoneArray2phoneString

public java.lang.String phoneArray2phoneString(AllophoneSet allophoneSet,
                                               java.lang.String[] voicePhones)
Converts an array of phone symbol strings into a single phone string. If stress is marked on input phone symbols ("1" appended), a crude syllabification is done on the phone string.