зеркало из https://github.com/mozilla/marytts.git
format java code in marytts-lang-en
incantation: $ mvn com.googlecode.maven-java-formatter-plugin:maven-java-formatter-plugin:format -pl marytts-languages/marytts-lang-en
This commit is contained in:
Родитель
6b091740df
Коммит
7c6ec7933d
|
@ -22,7 +22,6 @@ package marytts.language.en;
|
|||
import marytts.config.LanguageConfig;
|
||||
import marytts.exceptions.MaryConfigurationException;
|
||||
|
||||
|
||||
public class EnglishConfig extends LanguageConfig {
|
||||
public EnglishConfig() throws MaryConfigurationException {
|
||||
super(EnglishConfig.class.getResourceAsStream("en.config"));
|
||||
|
|
|
@ -32,54 +32,38 @@ import com.sun.speech.freetts.Utterance;
|
|||
import com.sun.speech.freetts.UtteranceProcessor;
|
||||
import com.sun.speech.freetts.en.ContourGenerator;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Use an individual FreeTTS module for English synthesis.
|
||||
*
|
||||
*
|
||||
* @author Marc Schröder
|
||||
*/
|
||||
|
||||
public class FreeTTSContourGenerator extends InternalModule
|
||||
{
|
||||
private UtteranceProcessor processor;
|
||||
public class FreeTTSContourGenerator extends InternalModule {
|
||||
private UtteranceProcessor processor;
|
||||
|
||||
public FreeTTSContourGenerator()
|
||||
{
|
||||
super("ContourGenerator",
|
||||
USEnglishDataTypes.FREETTS_DURATIONS,
|
||||
USEnglishDataTypes.FREETTS_CONTOUR,
|
||||
Locale.ENGLISH
|
||||
);
|
||||
}
|
||||
|
||||
public void startup() throws Exception
|
||||
{
|
||||
super.startup();
|
||||
|
||||
// Initialise FreeTTS
|
||||
FreeTTSVoices.load();
|
||||
processor = new ContourGenerator
|
||||
(com.sun.speech.freetts.en.us.CMUVoice.class.
|
||||
getResource("f0_lr_terms.txt"), 170.0f, 34.0f);
|
||||
}
|
||||
|
||||
public MaryData process(MaryData d)
|
||||
throws Exception
|
||||
{
|
||||
List utterances = d.getUtterances();
|
||||
Iterator it = utterances.iterator();
|
||||
while (it.hasNext()) {
|
||||
Utterance utterance = (Utterance) it.next();
|
||||
processor.processUtterance(utterance);
|
||||
}
|
||||
MaryData output = new MaryData(outputType(), d.getLocale());
|
||||
output.setUtterances(utterances);
|
||||
return output;
|
||||
}
|
||||
public FreeTTSContourGenerator() {
|
||||
super("ContourGenerator", USEnglishDataTypes.FREETTS_DURATIONS, USEnglishDataTypes.FREETTS_CONTOUR, Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public void startup() throws Exception {
|
||||
super.startup();
|
||||
|
||||
// Initialise FreeTTS
|
||||
FreeTTSVoices.load();
|
||||
processor = new ContourGenerator(com.sun.speech.freetts.en.us.CMUVoice.class.getResource("f0_lr_terms.txt"), 170.0f,
|
||||
34.0f);
|
||||
}
|
||||
|
||||
public MaryData process(MaryData d) throws Exception {
|
||||
List utterances = d.getUtterances();
|
||||
Iterator it = utterances.iterator();
|
||||
while (it.hasNext()) {
|
||||
Utterance utterance = (Utterance) it.next();
|
||||
processor.processUtterance(utterance);
|
||||
}
|
||||
MaryData output = new MaryData(outputType(), d.getLocale());
|
||||
output.setUtterances(utterances);
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -33,56 +33,39 @@ import com.sun.speech.freetts.UtteranceProcessor;
|
|||
import com.sun.speech.freetts.cart.CARTImpl;
|
||||
import com.sun.speech.freetts.cart.Intonator;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Use an individual FreeTTS module for English synthesis.
|
||||
*
|
||||
*
|
||||
* @author Marc Schröder
|
||||
*/
|
||||
|
||||
public class FreeTTSIntonator extends InternalModule
|
||||
{
|
||||
private UtteranceProcessor processor;
|
||||
public class FreeTTSIntonator extends InternalModule {
|
||||
private UtteranceProcessor processor;
|
||||
|
||||
public FreeTTSIntonator()
|
||||
{
|
||||
super("Intonator",
|
||||
USEnglishDataTypes.FREETTS_PAUSES,
|
||||
USEnglishDataTypes.FREETTS_INTONATION,
|
||||
Locale.ENGLISH
|
||||
);
|
||||
}
|
||||
|
||||
public void startup() throws Exception
|
||||
{
|
||||
super.startup();
|
||||
|
||||
// Initialise FreeTTS
|
||||
FreeTTSVoices.load();
|
||||
CARTImpl accentCart = new CARTImpl(
|
||||
com.sun.speech.freetts.en.us.CMUVoice.class.getResource("int_accent_cart.txt"));
|
||||
CARTImpl toneCart = new CARTImpl(
|
||||
com.sun.speech.freetts.en.us.CMUVoice.class.getResource("int_tone_cart.txt"));
|
||||
processor = new Intonator(accentCart, toneCart);
|
||||
}
|
||||
|
||||
public MaryData process(MaryData d)
|
||||
throws Exception
|
||||
{
|
||||
List utterances = d.getUtterances();
|
||||
Iterator it = utterances.iterator();
|
||||
while (it.hasNext()) {
|
||||
Utterance utterance = (Utterance) it.next();
|
||||
processor.processUtterance(utterance);
|
||||
}
|
||||
MaryData output = new MaryData(outputType(), d.getLocale());
|
||||
output.setUtterances(utterances);
|
||||
return output;
|
||||
}
|
||||
public FreeTTSIntonator() {
|
||||
super("Intonator", USEnglishDataTypes.FREETTS_PAUSES, USEnglishDataTypes.FREETTS_INTONATION, Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public void startup() throws Exception {
|
||||
super.startup();
|
||||
|
||||
// Initialise FreeTTS
|
||||
FreeTTSVoices.load();
|
||||
CARTImpl accentCart = new CARTImpl(com.sun.speech.freetts.en.us.CMUVoice.class.getResource("int_accent_cart.txt"));
|
||||
CARTImpl toneCart = new CARTImpl(com.sun.speech.freetts.en.us.CMUVoice.class.getResource("int_tone_cart.txt"));
|
||||
processor = new Intonator(accentCart, toneCart);
|
||||
}
|
||||
|
||||
public MaryData process(MaryData d) throws Exception {
|
||||
List utterances = d.getUtterances();
|
||||
Iterator it = utterances.iterator();
|
||||
while (it.hasNext()) {
|
||||
Utterance utterance = (Utterance) it.next();
|
||||
processor.processUtterance(utterance);
|
||||
}
|
||||
MaryData output = new MaryData(outputType(), d.getLocale());
|
||||
output.setUtterances(utterances);
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -42,99 +42,81 @@ import com.sun.speech.freetts.Item;
|
|||
import com.sun.speech.freetts.Relation;
|
||||
import com.sun.speech.freetts.Utterance;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Use an individual FreeTTS module for English synthesis.
|
||||
*
|
||||
*
|
||||
* @author Marc Schröder
|
||||
*/
|
||||
|
||||
public class FreeTTSPartOfSpeechTagger extends InternalModule
|
||||
{
|
||||
//private UtteranceProcessor processor;
|
||||
private Logger logger;
|
||||
|
||||
private Map posMap;
|
||||
|
||||
|
||||
public FreeTTSPartOfSpeechTagger()
|
||||
{
|
||||
super("PartOfSpeechTagger",
|
||||
USEnglishDataTypes.FREETTS_WORDS,
|
||||
USEnglishDataTypes.FREETTS_POS,
|
||||
Locale.ENGLISH
|
||||
);
|
||||
|
||||
}
|
||||
public class FreeTTSPartOfSpeechTagger extends InternalModule {
|
||||
// private UtteranceProcessor processor;
|
||||
private Logger logger;
|
||||
|
||||
public void startup() throws Exception
|
||||
{
|
||||
super.startup();
|
||||
this.logger = MaryUtils.getLogger("FreeTTSPOSTagger");
|
||||
buildPosMap();
|
||||
// Initialise FreeTTS
|
||||
FreeTTSVoices.load();
|
||||
//processor = new PartOfSpeechTagger();
|
||||
}
|
||||
private Map posMap;
|
||||
|
||||
public MaryData process(MaryData d)
|
||||
throws Exception
|
||||
{
|
||||
List utterances = d.getUtterances();
|
||||
Iterator it = utterances.iterator();
|
||||
while (it.hasNext()) {
|
||||
Utterance utterance = (Utterance) it.next();
|
||||
//processor.processUtterance(utterance);
|
||||
processUtterance(utterance);
|
||||
}
|
||||
MaryData output = new MaryData(outputType(), d.getLocale());
|
||||
output.setUtterances(utterances);
|
||||
return output;
|
||||
}
|
||||
public FreeTTSPartOfSpeechTagger() {
|
||||
super("PartOfSpeechTagger", USEnglishDataTypes.FREETTS_WORDS, USEnglishDataTypes.FREETTS_POS, Locale.ENGLISH);
|
||||
|
||||
private void buildPosMap(){
|
||||
posMap = new HashMap();
|
||||
try{
|
||||
String posFile =
|
||||
MaryProperties.getFilename("english.freetts.posfile");
|
||||
BufferedReader reader =
|
||||
new BufferedReader(new FileReader(new File (posFile)));
|
||||
String line = reader.readLine();
|
||||
while (line!=null){
|
||||
if(!(line.startsWith("***"))){
|
||||
//System.out.println(line);
|
||||
StringTokenizer st =
|
||||
new StringTokenizer(line," ");
|
||||
String word = st.nextToken();
|
||||
String pos = st.nextToken();
|
||||
posMap.put(word,pos);}
|
||||
line = reader.readLine();
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
throw new Error("Unable to build PoS-Map");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void processUtterance(Utterance utt){
|
||||
logger.debug("Tagging part of speech...");
|
||||
for(Item word = utt.getRelation(Relation.WORD).getHead();
|
||||
word != null; word = word.getNext()){
|
||||
String pos = null;
|
||||
if (posMap.containsKey(word.toString())){
|
||||
pos = (String) posMap.get(word.toString());
|
||||
logger.debug("Assigning pos \""+pos+"\" to word \""
|
||||
+word.toString()+"\"");
|
||||
}
|
||||
else {pos = "content";}
|
||||
word.getFeatures().setString("pos",pos);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public void startup() throws Exception {
|
||||
super.startup();
|
||||
this.logger = MaryUtils.getLogger("FreeTTSPOSTagger");
|
||||
buildPosMap();
|
||||
// Initialise FreeTTS
|
||||
FreeTTSVoices.load();
|
||||
// processor = new PartOfSpeechTagger();
|
||||
}
|
||||
|
||||
|
||||
public MaryData process(MaryData d) throws Exception {
|
||||
List utterances = d.getUtterances();
|
||||
Iterator it = utterances.iterator();
|
||||
while (it.hasNext()) {
|
||||
Utterance utterance = (Utterance) it.next();
|
||||
// processor.processUtterance(utterance);
|
||||
processUtterance(utterance);
|
||||
}
|
||||
MaryData output = new MaryData(outputType(), d.getLocale());
|
||||
output.setUtterances(utterances);
|
||||
return output;
|
||||
}
|
||||
|
||||
private void buildPosMap() {
|
||||
posMap = new HashMap();
|
||||
try {
|
||||
String posFile = MaryProperties.getFilename("english.freetts.posfile");
|
||||
BufferedReader reader = new BufferedReader(new FileReader(new File(posFile)));
|
||||
String line = reader.readLine();
|
||||
while (line != null) {
|
||||
if (!(line.startsWith("***"))) {
|
||||
// System.out.println(line);
|
||||
StringTokenizer st = new StringTokenizer(line, " ");
|
||||
String word = st.nextToken();
|
||||
String pos = st.nextToken();
|
||||
posMap.put(word, pos);
|
||||
}
|
||||
line = reader.readLine();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new Error("Unable to build PoS-Map");
|
||||
}
|
||||
}
|
||||
|
||||
private void processUtterance(Utterance utt) {
|
||||
logger.debug("Tagging part of speech...");
|
||||
for (Item word = utt.getRelation(Relation.WORD).getHead(); word != null; word = word.getNext()) {
|
||||
String pos = null;
|
||||
if (posMap.containsKey(word.toString())) {
|
||||
pos = (String) posMap.get(word.toString());
|
||||
logger.debug("Assigning pos \"" + pos + "\" to word \"" + word.toString() + "\"");
|
||||
} else {
|
||||
pos = "content";
|
||||
}
|
||||
word.getFeatures().setString("pos", pos);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -32,52 +32,37 @@ import com.sun.speech.freetts.Utterance;
|
|||
import com.sun.speech.freetts.UtteranceProcessor;
|
||||
import com.sun.speech.freetts.en.PauseGenerator;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Use an individual FreeTTS module for English synthesis.
|
||||
*
|
||||
*
|
||||
* @author Marc Schröder
|
||||
*/
|
||||
|
||||
public class FreeTTSPauseGenerator extends InternalModule
|
||||
{
|
||||
private UtteranceProcessor processor;
|
||||
public class FreeTTSPauseGenerator extends InternalModule {
|
||||
private UtteranceProcessor processor;
|
||||
|
||||
public FreeTTSPauseGenerator()
|
||||
{
|
||||
super("PauseGenerator",
|
||||
USEnglishDataTypes.FREETTS_SEGMENTS,
|
||||
USEnglishDataTypes.FREETTS_PAUSES,
|
||||
Locale.ENGLISH
|
||||
);
|
||||
}
|
||||
|
||||
public void startup() throws Exception
|
||||
{
|
||||
super.startup();
|
||||
|
||||
// Initialise FreeTTS
|
||||
FreeTTSVoices.load();
|
||||
processor = new PauseGenerator();
|
||||
}
|
||||
|
||||
public MaryData process(MaryData d)
|
||||
throws Exception
|
||||
{
|
||||
List utterances = d.getUtterances();
|
||||
Iterator it = utterances.iterator();
|
||||
while (it.hasNext()) {
|
||||
Utterance utterance = (Utterance) it.next();
|
||||
processor.processUtterance(utterance);
|
||||
}
|
||||
MaryData output = new MaryData(outputType(), d.getLocale());
|
||||
output.setUtterances(utterances);
|
||||
return output;
|
||||
}
|
||||
public FreeTTSPauseGenerator() {
|
||||
super("PauseGenerator", USEnglishDataTypes.FREETTS_SEGMENTS, USEnglishDataTypes.FREETTS_PAUSES, Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public void startup() throws Exception {
|
||||
super.startup();
|
||||
|
||||
// Initialise FreeTTS
|
||||
FreeTTSVoices.load();
|
||||
processor = new PauseGenerator();
|
||||
}
|
||||
|
||||
public MaryData process(MaryData d) throws Exception {
|
||||
List utterances = d.getUtterances();
|
||||
Iterator it = utterances.iterator();
|
||||
while (it.hasNext()) {
|
||||
Utterance utterance = (Utterance) it.next();
|
||||
processor.processUtterance(utterance);
|
||||
}
|
||||
MaryData output = new MaryData(outputType(), d.getLocale());
|
||||
output.setUtterances(utterances);
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -33,54 +33,38 @@ import com.sun.speech.freetts.UtteranceProcessor;
|
|||
import com.sun.speech.freetts.cart.CARTImpl;
|
||||
import com.sun.speech.freetts.cart.Phraser;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Use an individual FreeTTS module for English synthesis.
|
||||
*
|
||||
*
|
||||
* @author Marc Schröder
|
||||
*/
|
||||
|
||||
public class FreeTTSPhraser extends InternalModule
|
||||
{
|
||||
private UtteranceProcessor processor;
|
||||
public class FreeTTSPhraser extends InternalModule {
|
||||
private UtteranceProcessor processor;
|
||||
|
||||
public FreeTTSPhraser()
|
||||
{
|
||||
super("Phraser",
|
||||
USEnglishDataTypes.FREETTS_POS,
|
||||
USEnglishDataTypes.FREETTS_PHRASES,
|
||||
Locale.ENGLISH
|
||||
);
|
||||
}
|
||||
|
||||
public void startup() throws Exception
|
||||
{
|
||||
super.startup();
|
||||
|
||||
// Initialise FreeTTS
|
||||
FreeTTSVoices.load();
|
||||
CARTImpl phrasingCart = new CARTImpl(
|
||||
com.sun.speech.freetts.en.us.CMUVoice.class.getResource("phrasing_cart.txt"));
|
||||
processor = new Phraser(phrasingCart);
|
||||
}
|
||||
|
||||
public MaryData process(MaryData d)
|
||||
throws Exception
|
||||
{
|
||||
List utterances = d.getUtterances();
|
||||
Iterator it = utterances.iterator();
|
||||
while (it.hasNext()) {
|
||||
Utterance utterance = (Utterance) it.next();
|
||||
processor.processUtterance(utterance);
|
||||
}
|
||||
MaryData output = new MaryData(outputType(), d.getLocale());
|
||||
output.setUtterances(utterances);
|
||||
return output;
|
||||
}
|
||||
public FreeTTSPhraser() {
|
||||
super("Phraser", USEnglishDataTypes.FREETTS_POS, USEnglishDataTypes.FREETTS_PHRASES, Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public void startup() throws Exception {
|
||||
super.startup();
|
||||
|
||||
// Initialise FreeTTS
|
||||
FreeTTSVoices.load();
|
||||
CARTImpl phrasingCart = new CARTImpl(com.sun.speech.freetts.en.us.CMUVoice.class.getResource("phrasing_cart.txt"));
|
||||
processor = new Phraser(phrasingCart);
|
||||
}
|
||||
|
||||
public MaryData process(MaryData d) throws Exception {
|
||||
List utterances = d.getUtterances();
|
||||
Iterator it = utterances.iterator();
|
||||
while (it.hasNext()) {
|
||||
Utterance utterance = (Utterance) it.next();
|
||||
processor.processUtterance(utterance);
|
||||
}
|
||||
MaryData output = new MaryData(outputType(), d.getLocale());
|
||||
output.setUtterances(utterances);
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -44,87 +44,67 @@ import com.sun.speech.freetts.Tokenizer;
|
|||
import com.sun.speech.freetts.Utterance;
|
||||
import com.sun.speech.freetts.en.us.USEnglish;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Use an individual FreeTTS module for English synthesis.
|
||||
*
|
||||
*
|
||||
* @author Marc Schröder
|
||||
*/
|
||||
|
||||
public class FreeTTSTextToTokens extends InternalModule
|
||||
{
|
||||
public FreeTTSTextToTokens()
|
||||
{
|
||||
super("TextToTokens",
|
||||
MaryDataType.TEXT,
|
||||
USEnglishDataTypes.FREETTS_TOKENS,
|
||||
Locale.ENGLISH
|
||||
);
|
||||
}
|
||||
public class FreeTTSTextToTokens extends InternalModule {
|
||||
public FreeTTSTextToTokens() {
|
||||
super("TextToTokens", MaryDataType.TEXT, USEnglishDataTypes.FREETTS_TOKENS, Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public void startup() throws Exception
|
||||
{
|
||||
super.startup();
|
||||
|
||||
// Initialise FreeTTS
|
||||
FreeTTSVoices.load();
|
||||
}
|
||||
|
||||
public MaryData process(MaryData d)
|
||||
throws Exception
|
||||
{
|
||||
String text = d.getPlainText();
|
||||
// create a basic utterance from text
|
||||
Tokenizer tokenizer = new com.sun.speech.freetts.en.TokenizerImpl();
|
||||
tokenizer.setWhitespaceSymbols(USEnglish.WHITESPACE_SYMBOLS);
|
||||
tokenizer.setSingleCharSymbols(USEnglish.SINGLE_CHAR_SYMBOLS);
|
||||
tokenizer.setPrepunctuationSymbols(USEnglish.PREPUNCTUATION_SYMBOLS);
|
||||
tokenizer.setPostpunctuationSymbols(USEnglish.PUNCTUATION_SYMBOLS);
|
||||
tokenizer.setInputText(text);
|
||||
ArrayList utteranceList = new ArrayList();
|
||||
Token savedToken = null;
|
||||
boolean first = true;
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
// Fill a new Utterance:
|
||||
ArrayList tokenList = new ArrayList();
|
||||
Utterance utterance = null;
|
||||
if (savedToken != null) {
|
||||
tokenList.add(savedToken);
|
||||
savedToken = null;
|
||||
}
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
Token token = tokenizer.getNextToken();
|
||||
if ((token.getWord().length() == 0) ||
|
||||
(tokenList.size() > 500) ||
|
||||
tokenizer.isBreak()) {
|
||||
savedToken = token;
|
||||
break;
|
||||
}
|
||||
tokenList.add(token);
|
||||
}
|
||||
marytts.modules.synthesis.Voice maryVoice =
|
||||
d.getDefaultVoice();
|
||||
if (maryVoice == null ||
|
||||
!maryVoice.getLocale().equals(Locale.US)) {
|
||||
maryVoice = marytts.modules.synthesis.Voice.
|
||||
getDefaultVoice(Locale.US);
|
||||
}
|
||||
|
||||
utterance = new Utterance
|
||||
(FreeTTSVoices.getFreeTTSVoice(maryVoice), tokenList);
|
||||
//utterance.setSpeakable(speakable);
|
||||
utterance.setFirst(first);
|
||||
first = false;
|
||||
utterance.setLast(!tokenizer.hasMoreTokens());
|
||||
utteranceList.add(utterance);
|
||||
}
|
||||
MaryData output = new MaryData(outputType(), d.getLocale());
|
||||
output.setUtterances(utteranceList);
|
||||
return output;
|
||||
}
|
||||
public void startup() throws Exception {
|
||||
super.startup();
|
||||
|
||||
// Initialise FreeTTS
|
||||
FreeTTSVoices.load();
|
||||
}
|
||||
|
||||
public MaryData process(MaryData d) throws Exception {
|
||||
String text = d.getPlainText();
|
||||
// create a basic utterance from text
|
||||
Tokenizer tokenizer = new com.sun.speech.freetts.en.TokenizerImpl();
|
||||
tokenizer.setWhitespaceSymbols(USEnglish.WHITESPACE_SYMBOLS);
|
||||
tokenizer.setSingleCharSymbols(USEnglish.SINGLE_CHAR_SYMBOLS);
|
||||
tokenizer.setPrepunctuationSymbols(USEnglish.PREPUNCTUATION_SYMBOLS);
|
||||
tokenizer.setPostpunctuationSymbols(USEnglish.PUNCTUATION_SYMBOLS);
|
||||
tokenizer.setInputText(text);
|
||||
ArrayList utteranceList = new ArrayList();
|
||||
Token savedToken = null;
|
||||
boolean first = true;
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
// Fill a new Utterance:
|
||||
ArrayList tokenList = new ArrayList();
|
||||
Utterance utterance = null;
|
||||
if (savedToken != null) {
|
||||
tokenList.add(savedToken);
|
||||
savedToken = null;
|
||||
}
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
Token token = tokenizer.getNextToken();
|
||||
if ((token.getWord().length() == 0) || (tokenList.size() > 500) || tokenizer.isBreak()) {
|
||||
savedToken = token;
|
||||
break;
|
||||
}
|
||||
tokenList.add(token);
|
||||
}
|
||||
marytts.modules.synthesis.Voice maryVoice = d.getDefaultVoice();
|
||||
if (maryVoice == null || !maryVoice.getLocale().equals(Locale.US)) {
|
||||
maryVoice = marytts.modules.synthesis.Voice.getDefaultVoice(Locale.US);
|
||||
}
|
||||
|
||||
utterance = new Utterance(FreeTTSVoices.getFreeTTSVoice(maryVoice), tokenList);
|
||||
// utterance.setSpeakable(speakable);
|
||||
utterance.setFirst(first);
|
||||
first = false;
|
||||
utterance.setLast(!tokenizer.hasMoreTokens());
|
||||
utteranceList.add(utterance);
|
||||
}
|
||||
MaryData output = new MaryData(outputType(), d.getLocale());
|
||||
output.setUtterances(utteranceList);
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -46,57 +46,40 @@ import com.sun.speech.freetts.en.us.PrefixFSM;
|
|||
import com.sun.speech.freetts.en.us.PronounceableFSM;
|
||||
import com.sun.speech.freetts.en.us.SuffixFSM;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Use an individual FreeTTS module for English synthesis.
|
||||
*
|
||||
*
|
||||
* @author Marc Schröder
|
||||
*/
|
||||
|
||||
public class FreeTTSTokenToWords extends InternalModule
|
||||
{
|
||||
private UtteranceProcessor processor;
|
||||
public class FreeTTSTokenToWords extends InternalModule {
|
||||
private UtteranceProcessor processor;
|
||||
|
||||
public FreeTTSTokenToWords()
|
||||
{
|
||||
super("TokenToWords",
|
||||
USEnglishDataTypes.FREETTS_TOKENS,
|
||||
USEnglishDataTypes.FREETTS_WORDS,
|
||||
Locale.ENGLISH
|
||||
);
|
||||
}
|
||||
|
||||
public void startup() throws Exception
|
||||
{
|
||||
super.startup();
|
||||
|
||||
// Initialise FreeTTS
|
||||
FreeTTSVoices.load();
|
||||
CARTImpl numbersCart = new CARTImpl
|
||||
(com.sun.speech.freetts.en.us.CMUVoice.class.getResource("nums_cart.txt"));
|
||||
PronounceableFSM prefixFSM = new PrefixFSM
|
||||
(com.sun.speech.freetts.en.us.CMUVoice.class.getResource("prefix_fsm.txt"));
|
||||
PronounceableFSM suffixFSM = new SuffixFSM
|
||||
(com.sun.speech.freetts.en.us.CMUVoice.class.getResource("suffix_fsm.txt"));
|
||||
processor = new TokenToWords(numbersCart, prefixFSM, suffixFSM);
|
||||
}
|
||||
|
||||
public MaryData process(MaryData d)
|
||||
throws Exception
|
||||
{
|
||||
List utterances = d.getUtterances();
|
||||
Iterator it = utterances.iterator();
|
||||
while (it.hasNext()) {
|
||||
Utterance utterance = (Utterance) it.next();
|
||||
processor.processUtterance(utterance);
|
||||
}
|
||||
MaryData output = new MaryData(outputType(), d.getLocale());
|
||||
output.setUtterances(utterances);
|
||||
return output;
|
||||
}
|
||||
public FreeTTSTokenToWords() {
|
||||
super("TokenToWords", USEnglishDataTypes.FREETTS_TOKENS, USEnglishDataTypes.FREETTS_WORDS, Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public void startup() throws Exception {
|
||||
super.startup();
|
||||
|
||||
// Initialise FreeTTS
|
||||
FreeTTSVoices.load();
|
||||
CARTImpl numbersCart = new CARTImpl(com.sun.speech.freetts.en.us.CMUVoice.class.getResource("nums_cart.txt"));
|
||||
PronounceableFSM prefixFSM = new PrefixFSM(com.sun.speech.freetts.en.us.CMUVoice.class.getResource("prefix_fsm.txt"));
|
||||
PronounceableFSM suffixFSM = new SuffixFSM(com.sun.speech.freetts.en.us.CMUVoice.class.getResource("suffix_fsm.txt"));
|
||||
processor = new TokenToWords(numbersCart, prefixFSM, suffixFSM);
|
||||
}
|
||||
|
||||
public MaryData process(MaryData d) throws Exception {
|
||||
List utterances = d.getUtterances();
|
||||
Iterator it = utterances.iterator();
|
||||
while (it.hasNext()) {
|
||||
Utterance utterance = (Utterance) it.next();
|
||||
processor.processUtterance(utterance);
|
||||
}
|
||||
MaryData output = new MaryData(outputType(), d.getLocale());
|
||||
output.setUtterances(utterances);
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,75 +34,68 @@ import org.w3c.dom.traversal.DocumentTraversal;
|
|||
import org.w3c.dom.traversal.NodeFilter;
|
||||
import org.w3c.dom.traversal.NodeIterator;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Marc Schröder
|
||||
*/
|
||||
public class JTokeniser extends marytts.modules.JTokeniser {
|
||||
|
||||
/**
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public JTokeniser() {
|
||||
super(MaryDataType.RAWMARYXML,
|
||||
MaryDataType.TOKENS,
|
||||
Locale.ENGLISH);
|
||||
}
|
||||
public JTokeniser() {
|
||||
super(MaryDataType.RAWMARYXML, MaryDataType.TOKENS, Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public MaryData process(MaryData d) throws Exception
|
||||
{
|
||||
MaryData result = super.process(d);
|
||||
normaliseToAscii(result);
|
||||
propagateForceAccent(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
protected void normaliseToAscii(MaryData d)
|
||||
{
|
||||
Document doc = d.getDocument();
|
||||
NodeIterator ni = ((DocumentTraversal) doc).createNodeIterator(doc,
|
||||
NodeFilter.SHOW_ELEMENT, new NameNodeFilter(MaryXML.TOKEN), false);
|
||||
Element t = null;
|
||||
while ((t = (Element) ni.nextNode()) != null) {
|
||||
String s = MaryDomUtils.tokenText(t);
|
||||
String normalised = MaryUtils.normaliseUnicodeLetters(s, Locale.ENGLISH);
|
||||
if (!s.equals(normalised)) {
|
||||
MaryDomUtils.setTokenText(t, normalised);
|
||||
}
|
||||
}
|
||||
}
|
||||
public MaryData process(MaryData d) throws Exception {
|
||||
MaryData result = super.process(d);
|
||||
normaliseToAscii(result);
|
||||
propagateForceAccent(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* In current FreeTTS code, prosody elements get lost. So remember
|
||||
* at least the force-accent element on individual tokens:
|
||||
* @param d
|
||||
*/
|
||||
protected void propagateForceAccent(MaryData d)
|
||||
{
|
||||
Document doc = d.getDocument();
|
||||
NodeIterator prosodyNI = ((DocumentTraversal)doc).createNodeIterator(doc,
|
||||
NodeFilter.SHOW_ELEMENT, new NameNodeFilter(MaryXML.PROSODY), false);
|
||||
Element prosody = null;
|
||||
while ((prosody = (Element) prosodyNI.nextNode()) != null) {
|
||||
if (prosody.hasAttribute("force-accent")) {
|
||||
String forceAccent = prosody.getAttribute("force-accent");
|
||||
String accent = null;
|
||||
if (forceAccent.equals("none")) {
|
||||
accent = "none";
|
||||
} else {
|
||||
accent = "unknown";
|
||||
}
|
||||
NodeIterator tNI = ((DocumentTraversal)doc).createNodeIterator(prosody,
|
||||
NodeFilter.SHOW_ELEMENT, new NameNodeFilter(MaryXML.TOKEN), false);
|
||||
Element t = null;
|
||||
while ((t = (Element) tNI.nextNode()) != null) {
|
||||
if (!t.hasAttribute("accent")) {
|
||||
t.setAttribute("accent", accent);
|
||||
}
|
||||
} // while t
|
||||
}
|
||||
} // while prosody
|
||||
}
|
||||
protected void normaliseToAscii(MaryData d) {
|
||||
Document doc = d.getDocument();
|
||||
NodeIterator ni = ((DocumentTraversal) doc).createNodeIterator(doc, NodeFilter.SHOW_ELEMENT, new NameNodeFilter(
|
||||
MaryXML.TOKEN), false);
|
||||
Element t = null;
|
||||
while ((t = (Element) ni.nextNode()) != null) {
|
||||
String s = MaryDomUtils.tokenText(t);
|
||||
String normalised = MaryUtils.normaliseUnicodeLetters(s, Locale.ENGLISH);
|
||||
if (!s.equals(normalised)) {
|
||||
MaryDomUtils.setTokenText(t, normalised);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* In current FreeTTS code, prosody elements get lost. So remember at least the force-accent element on individual tokens:
|
||||
*
|
||||
* @param d
|
||||
*/
|
||||
protected void propagateForceAccent(MaryData d) {
|
||||
Document doc = d.getDocument();
|
||||
NodeIterator prosodyNI = ((DocumentTraversal) doc).createNodeIterator(doc, NodeFilter.SHOW_ELEMENT, new NameNodeFilter(
|
||||
MaryXML.PROSODY), false);
|
||||
Element prosody = null;
|
||||
while ((prosody = (Element) prosodyNI.nextNode()) != null) {
|
||||
if (prosody.hasAttribute("force-accent")) {
|
||||
String forceAccent = prosody.getAttribute("force-accent");
|
||||
String accent = null;
|
||||
if (forceAccent.equals("none")) {
|
||||
accent = "none";
|
||||
} else {
|
||||
accent = "unknown";
|
||||
}
|
||||
NodeIterator tNI = ((DocumentTraversal) doc).createNodeIterator(prosody, NodeFilter.SHOW_ELEMENT,
|
||||
new NameNodeFilter(MaryXML.TOKEN), false);
|
||||
Element t = null;
|
||||
while ((t = (Element) tNI.nextNode()) != null) {
|
||||
if (!t.hasAttribute("accent")) {
|
||||
t.setAttribute("accent", accent);
|
||||
}
|
||||
} // while t
|
||||
}
|
||||
} // while prosody
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,514 +15,445 @@ import com.sun.speech.freetts.Item;
|
|||
import com.sun.speech.freetts.util.Utilities;
|
||||
|
||||
/**
|
||||
* Expands Strings containing digits characters into
|
||||
* a list of words representing those digits.
|
||||
*
|
||||
* It translates the following code from flite:
|
||||
* <code>lang/usEnglish/us_expand.c</code>
|
||||
* Expands Strings containing digits characters into a list of words representing those digits.
|
||||
*
|
||||
* It translates the following code from flite: <code>lang/usEnglish/us_expand.c</code>
|
||||
*/
|
||||
public class NumberExpander {
|
||||
|
||||
private static final String[] digit2num = {
|
||||
"zero",
|
||||
"one",
|
||||
"two",
|
||||
"three",
|
||||
"four",
|
||||
"five",
|
||||
"six",
|
||||
"seven",
|
||||
"eight",
|
||||
"nine" };
|
||||
|
||||
private static final String[] digit2teen = {
|
||||
"ten", /* shouldn't get called */
|
||||
"eleven",
|
||||
"twelve",
|
||||
"thirteen",
|
||||
"fourteen",
|
||||
"fifteen",
|
||||
"sixteen",
|
||||
"seventeen",
|
||||
"eighteen",
|
||||
"nineteen" };
|
||||
|
||||
private static final String[] digit2enty = {
|
||||
"zero", /* shouldn't get called */
|
||||
"ten",
|
||||
"twenty",
|
||||
"thirty",
|
||||
"forty",
|
||||
"fifty",
|
||||
"sixty",
|
||||
"seventy",
|
||||
"eighty",
|
||||
"ninety" };
|
||||
|
||||
private static final String[] ord2num = {
|
||||
"zeroth",
|
||||
"first",
|
||||
"second",
|
||||
"third",
|
||||
"fourth",
|
||||
"fifth",
|
||||
"sixth",
|
||||
"seventh",
|
||||
"eighth",
|
||||
"ninth" };
|
||||
|
||||
private static final String[] ord2teen = {
|
||||
"tenth", /* shouldn't get called */
|
||||
"eleventh",
|
||||
"twelfth",
|
||||
"thirteenth",
|
||||
"fourteenth",
|
||||
"fifteenth",
|
||||
"sixteenth",
|
||||
"seventeenth",
|
||||
"eighteenth",
|
||||
"nineteenth" };
|
||||
|
||||
private static final String[] ord2enty = {
|
||||
"zeroth", /* shouldn't get called */
|
||||
"tenth",
|
||||
"twentieth",
|
||||
"thirtieth",
|
||||
"fortieth",
|
||||
"fiftieth",
|
||||
"sixtieth",
|
||||
"seventieth",
|
||||
"eightieth",
|
||||
"ninetieth" };
|
||||
|
||||
private static final String[] digit2num = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };
|
||||
|
||||
/**
|
||||
* Unconstructable
|
||||
*/
|
||||
private NumberExpander() {
|
||||
}
|
||||
private static final String[] digit2teen = { "ten", /* shouldn't get called */
|
||||
"eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" };
|
||||
|
||||
private static final String[] digit2enty = { "zero", /* shouldn't get called */
|
||||
"ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" };
|
||||
|
||||
/**
|
||||
* Expands a digit string into a list of English words of those digits.
|
||||
* For example, "1234" expands to "one two three four"
|
||||
*
|
||||
* @param numberString the digit string to expand.
|
||||
* @param wordRelation words are added to this Relation
|
||||
*/
|
||||
public static void expandNumber(String numberString,
|
||||
WordRelation wordRelation, Item tokenItem) {
|
||||
int numDigits = numberString.length();
|
||||
|
||||
if (numDigits == 0) {
|
||||
// wordRelation = null;
|
||||
} else if (numDigits == 1) {
|
||||
expandDigits(numberString, wordRelation, tokenItem);
|
||||
} else if (numDigits == 2) {
|
||||
expand2DigitNumber(numberString, wordRelation, tokenItem);
|
||||
} else if (numDigits == 3) {
|
||||
expand3DigitNumber(numberString, wordRelation, tokenItem);
|
||||
} else if (numDigits < 7) {
|
||||
expandBelow7DigitNumber(numberString, wordRelation, tokenItem);
|
||||
} else if (numDigits < 10) {
|
||||
expandBelow10DigitNumber(numberString, wordRelation, tokenItem);
|
||||
} else if (numDigits < 13) {
|
||||
expandBelow13DigitNumber(numberString, wordRelation, tokenItem);
|
||||
} else {
|
||||
expandDigits(numberString, wordRelation, tokenItem);
|
||||
private static final String[] ord2num = { "zeroth", "first", "second", "third", "fourth", "fifth", "sixth", "seventh",
|
||||
"eighth", "ninth" };
|
||||
|
||||
private static final String[] ord2teen = { "tenth", /* shouldn't get called */
|
||||
"eleventh", "twelfth", "thirteenth", "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteenth", "nineteenth" };
|
||||
|
||||
private static final String[] ord2enty = { "zeroth", /* shouldn't get called */
|
||||
"tenth", "twentieth", "thirtieth", "fortieth", "fiftieth", "sixtieth", "seventieth", "eightieth", "ninetieth" };
|
||||
|
||||
/**
|
||||
* Unconstructable
|
||||
*/
|
||||
private NumberExpander() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Expands a digit string into a list of English words of those digits. For example, "1234" expands to "one two three four"
|
||||
*
|
||||
* @param numberString
|
||||
* the digit string to expand.
|
||||
* @param wordRelation
|
||||
* words are added to this Relation
|
||||
*/
|
||||
public static void expandNumber(String numberString, WordRelation wordRelation, Item tokenItem) {
|
||||
int numDigits = numberString.length();
|
||||
|
||||
/**
|
||||
* Expands a two-digit string into a list of English words.
|
||||
*
|
||||
* @param numberString the string which is the number to expand
|
||||
* @param wordRelation words are added to this Relation
|
||||
*/
|
||||
private static void expand2DigitNumber(String numberString,
|
||||
WordRelation wordRelation, Item tokenItem) {
|
||||
if (numberString.charAt(0) == '0') {
|
||||
// numberString is "0X"
|
||||
if (numberString.charAt(1) == '0') {
|
||||
// numberString is "00", do nothing
|
||||
} else {
|
||||
// numberString is "01", "02" ...
|
||||
String number = digit2num[numberString.charAt(1)-'0'];
|
||||
wordRelation.addWord(tokenItem,number);
|
||||
}
|
||||
} else if (numberString.charAt(1) == '0') {
|
||||
// numberString is "10", "20", ...
|
||||
String number = digit2enty[numberString.charAt(0)-'0'];
|
||||
wordRelation.addWord(tokenItem,number);
|
||||
} else if (numberString.charAt(0) == '1') {
|
||||
// numberString is "11", "12", ..., "19"
|
||||
String number = digit2teen[numberString.charAt(1)-'0'];
|
||||
wordRelation.addWord(tokenItem,number);
|
||||
} else {
|
||||
// numberString is "2X", "3X", ...
|
||||
String enty = digit2enty[numberString.charAt(0)-'0'];
|
||||
wordRelation.addWord(tokenItem,enty);
|
||||
expandDigits(numberString.substring(1,numberString.length()),
|
||||
wordRelation, tokenItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Expands a three-digit string into a list of English words.
|
||||
*
|
||||
* @param numberString the string which is the number to expand
|
||||
* @param wordRelation words are added to this Relation
|
||||
*/
|
||||
private static void expand3DigitNumber(String numberString,
|
||||
WordRelation wordRelation,Item tokenItem) {
|
||||
if (numberString.charAt(0) == '0') {
|
||||
expandNumberAt(numberString, 1, wordRelation, tokenItem);
|
||||
} else {
|
||||
String hundredDigit = digit2num[numberString.charAt(0)-'0'];
|
||||
wordRelation.addWord(tokenItem,hundredDigit);
|
||||
wordRelation.addWord(tokenItem,"hundred");
|
||||
expandNumberAt(numberString, 1, wordRelation, tokenItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Expands a string that is a 4 to 6 digits number into a list
|
||||
* of English words. For example, "333000" into "three hundred
|
||||
* and thirty-three thousand".
|
||||
*
|
||||
* @param numberString the string which is the number to expand
|
||||
* @param wordRelation words are added to this Relation
|
||||
*/
|
||||
private static void expandBelow7DigitNumber(String numberString,
|
||||
WordRelation wordRelation,Item tokenItem) {
|
||||
expandLargeNumber(numberString, "thousand", 3, wordRelation, tokenItem);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Expands a string that is a 7 to 9 digits number into a list
|
||||
* of English words. For example, "19000000" into nineteen million.
|
||||
*
|
||||
* @param numberString the string which is the number to expand
|
||||
* @param wordRelation words are added to this Relation
|
||||
*/
|
||||
private static void expandBelow10DigitNumber(String numberString,
|
||||
WordRelation wordRelation,Item tokenItem) {
|
||||
expandLargeNumber(numberString, "million", 6, wordRelation, tokenItem);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Expands a string that is a 10 to 12 digits number into a list
|
||||
* of English words. For example, "27000000000" into twenty-seven
|
||||
* billion.
|
||||
*
|
||||
* @param numberString the string which is the number to expand
|
||||
* @param wordRelation words are added to this Relation
|
||||
*/
|
||||
private static void expandBelow13DigitNumber(String numberString,
|
||||
WordRelation wordRelation,Item tokenItem) {
|
||||
expandLargeNumber(numberString, "billion", 9, wordRelation, tokenItem);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Expands a string that is a number longer than 3 digits into a list
|
||||
* of English words. For example, "1000" into one thousand.
|
||||
*
|
||||
* @param numberString the string which is the number to expand
|
||||
* @param order either "thousand", "million", or "billion"
|
||||
* @param numberZeroes the number of zeroes, depending on the order, so
|
||||
* its either 3, 6, or 9
|
||||
* @param wordRelation words are added to this Relation
|
||||
*/
|
||||
private static void expandLargeNumber(String numberString,
|
||||
String order,
|
||||
int numberZeroes,
|
||||
WordRelation wordRelation,Item tokenItem) {
|
||||
int numberDigits = numberString.length();
|
||||
|
||||
// parse out the prefix, e.g., "113" in "113,000"
|
||||
int i = numberDigits - numberZeroes;
|
||||
String part = numberString.substring(0, i);
|
||||
|
||||
// get how many thousands/millions/billions
|
||||
Item oldTail = wordRelation.getTail();
|
||||
|
||||
expandNumber(part, wordRelation, tokenItem);
|
||||
|
||||
if (wordRelation.getTail() == oldTail) {
|
||||
expandNumberAt(numberString, i, wordRelation,tokenItem);
|
||||
} else {
|
||||
wordRelation.addWord(tokenItem,order);
|
||||
expandNumberAt(numberString, i, wordRelation,tokenItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number string list of the given string starting at
|
||||
* the given index. E.g., expandNumberAt("1100", 1) gives "one hundred"
|
||||
*
|
||||
* @param numberString the string which is the number to expand
|
||||
* @param startIndex the starting position
|
||||
* @param wordRelation words are added to this Relation
|
||||
*/
|
||||
private static void expandNumberAt(String numberString,
|
||||
int startIndex,
|
||||
WordRelation wordRelation,Item tokenItem) {
|
||||
expandNumber(numberString.substring(startIndex,numberString.length()),
|
||||
wordRelation,tokenItem);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Expands given token to list of words pronouncing it as digits
|
||||
*
|
||||
* @param numberString the string which is the number to expand
|
||||
* @param wordRelation words are added to this Relation
|
||||
*/
|
||||
public static void expandDigits(String numberString,
|
||||
WordRelation wordRelation,Item tokenItem) {
|
||||
int numberDigits = numberString.length();
|
||||
for (int i = 0; i < numberDigits; i++) {
|
||||
char digit = numberString.charAt(i);
|
||||
if (isDigit(digit)) {
|
||||
wordRelation.addWord(tokenItem,digit2num[numberString.charAt(i)-'0']);
|
||||
} else {
|
||||
wordRelation.addWord(tokenItem,"umpty");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Expands the digit string of an ordinal number.
|
||||
*
|
||||
* @param rawNumberString the string which is the number to expand
|
||||
* @param wordRelation words are added to this Relation
|
||||
*/
|
||||
public static void expandOrdinal(String rawNumberString,
|
||||
WordRelation wordRelation,Item tokenItem) {
|
||||
// remove all ','s from the raw number string
|
||||
String numberString = Utilities.deleteChar(rawNumberString, ',');
|
||||
|
||||
expandNumber(numberString, wordRelation,tokenItem);
|
||||
|
||||
// get the last in the list of number strings
|
||||
Item lastItem = wordRelation.getTail();
|
||||
|
||||
if (lastItem != null) {
|
||||
|
||||
FeatureSet featureSet = lastItem.getFeatures();
|
||||
String lastNumber = featureSet.getString("name");
|
||||
String ordinal = findMatchInArray(lastNumber, digit2num, ord2num);
|
||||
|
||||
if (ordinal == null) {
|
||||
ordinal = findMatchInArray(lastNumber, digit2teen, ord2teen);
|
||||
}
|
||||
if (ordinal == null) {
|
||||
ordinal = findMatchInArray(lastNumber, digit2enty, ord2enty);
|
||||
}
|
||||
|
||||
if (lastNumber.equals("hundred")) {
|
||||
ordinal = "hundredth";
|
||||
} else if (lastNumber.equals("thousand")) {
|
||||
ordinal = "thousandth";
|
||||
} else if (lastNumber.equals("billion")) {
|
||||
ordinal = "billionth";
|
||||
}
|
||||
|
||||
// if there was an ordinal, set the last element of the list
|
||||
// to that ordinal; otherwise, don't do anything
|
||||
if (ordinal != null) {
|
||||
wordRelation.setLastWord(ordinal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds a match of the given string in the given array,
|
||||
* and returns the element at the same index in the returnInArray
|
||||
*
|
||||
* @param strToMatch the string to match
|
||||
* @param matchInArray the source array
|
||||
* @param returnInArray the return array
|
||||
*
|
||||
* @return an element in returnInArray, or <code>null</code>
|
||||
* if a match is not found
|
||||
*/
|
||||
private static String findMatchInArray(String strToMatch,
|
||||
String[] matchInArray,
|
||||
String[] returnInArray) {
|
||||
for (int i = 0; i < matchInArray.length; i++) {
|
||||
if (strToMatch.equals(matchInArray[i])) {
|
||||
if (i < returnInArray.length) {
|
||||
return returnInArray[i];
|
||||
if (numDigits == 0) {
|
||||
// wordRelation = null;
|
||||
} else if (numDigits == 1) {
|
||||
expandDigits(numberString, wordRelation, tokenItem);
|
||||
} else if (numDigits == 2) {
|
||||
expand2DigitNumber(numberString, wordRelation, tokenItem);
|
||||
} else if (numDigits == 3) {
|
||||
expand3DigitNumber(numberString, wordRelation, tokenItem);
|
||||
} else if (numDigits < 7) {
|
||||
expandBelow7DigitNumber(numberString, wordRelation, tokenItem);
|
||||
} else if (numDigits < 10) {
|
||||
expandBelow10DigitNumber(numberString, wordRelation, tokenItem);
|
||||
} else if (numDigits < 13) {
|
||||
expandBelow13DigitNumber(numberString, wordRelation, tokenItem);
|
||||
} else {
|
||||
return null;
|
||||
expandDigits(numberString, wordRelation, tokenItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Expands the given number string as pairs as in years or IDs
|
||||
*
|
||||
* @param numberString the string which is the number to expand
|
||||
* @param wordRelation words are added to this Relation
|
||||
*/
|
||||
public static void expandID(String numberString, WordRelation wordRelation, Item tokenItem) {
|
||||
|
||||
int numberDigits = numberString.length();
|
||||
|
||||
if ((numberDigits == 4) &&
|
||||
(numberString.charAt(2) == '0') &&
|
||||
(numberString.charAt(3) == '0')) {
|
||||
if (numberString.charAt(1) == '0') { // e.g. 2000, 3000
|
||||
expandNumber(numberString, wordRelation,tokenItem);
|
||||
} else {
|
||||
expandNumber(numberString.substring(0,2), wordRelation,tokenItem);
|
||||
wordRelation.addWord(tokenItem,"hundred");
|
||||
}
|
||||
} else if ((numberDigits == 2) && (numberString.charAt(0) == '0')) {
|
||||
wordRelation.addWord(tokenItem,"oh");
|
||||
expandDigits(numberString.substring(1,2), wordRelation,tokenItem);
|
||||
} else if ((numberDigits == 4 &&
|
||||
numberString.charAt(1) == '0') ||
|
||||
numberDigits < 3) {
|
||||
expandNumber(numberString, wordRelation,tokenItem);
|
||||
} else if (numberDigits % 2 == 1) {
|
||||
String firstDigit = digit2num[numberString.charAt(0)-'0'];
|
||||
wordRelation.addWord(tokenItem,firstDigit);
|
||||
expandID(numberString.substring(1,numberDigits), wordRelation,tokenItem);
|
||||
} else {
|
||||
expandNumber(numberString.substring(0,2), wordRelation,tokenItem);
|
||||
expandID(numberString.substring(2,numberDigits), wordRelation,tokenItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Expands the given number string as a real number.
|
||||
*
|
||||
* @param numberString the string which is the real number to expand
|
||||
* @param wordRelation words are added to this Relation
|
||||
*/
|
||||
public static void expandReal(String numberString, WordRelation wordRelation,Item tokenItem) {
|
||||
|
||||
int stringLength = numberString.length();
|
||||
int position;
|
||||
|
||||
if (numberString.charAt(0) == '-') {
|
||||
// negative real numbers
|
||||
wordRelation.addWord(tokenItem,"minus");
|
||||
expandReal(numberString.substring(1, stringLength), wordRelation,tokenItem);
|
||||
} else if (numberString.charAt(0) == '+') {
|
||||
// prefixed with a '+'
|
||||
wordRelation.addWord(tokenItem,"plus");
|
||||
expandReal(numberString.substring(1, stringLength), wordRelation,tokenItem);
|
||||
} else if ((position = numberString.indexOf('e')) != -1 ||
|
||||
(position = numberString.indexOf('E')) != -1) {
|
||||
// numbers with 'E' or 'e'
|
||||
expandReal(numberString.substring(0, position), wordRelation,tokenItem);
|
||||
wordRelation.addWord(tokenItem,"e");
|
||||
expandReal(numberString.substring(position + 1), wordRelation,tokenItem);
|
||||
} else if ((position = numberString.indexOf('.')) != -1) {
|
||||
// numbers with '.'
|
||||
String beforeDot = numberString.substring(0, position);
|
||||
if (beforeDot.length() > 0) {
|
||||
expandReal(beforeDot, wordRelation,tokenItem);
|
||||
}
|
||||
wordRelation.addWord(tokenItem,"point");
|
||||
String afterDot = numberString.substring(position + 1);
|
||||
if (afterDot.length() > 0) {
|
||||
expandDigits(afterDot, wordRelation,tokenItem);
|
||||
}
|
||||
} else {
|
||||
// everything else
|
||||
expandNumber(numberString, wordRelation,tokenItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Expands the given string of letters as a list of single char symbols.
|
||||
*
|
||||
* @param letters the string of letters to expand
|
||||
* @param wordRelation words are added to this Relation
|
||||
*/
|
||||
public static void expandLetters(String letters,
|
||||
WordRelation wordRelation,Item tokenItem) {
|
||||
letters = letters.toLowerCase();
|
||||
char c;
|
||||
|
||||
for (int i = 0; i < letters.length(); i++) {
|
||||
// if this is a number
|
||||
c = letters.charAt(i);
|
||||
|
||||
if (isDigit(c)) {
|
||||
wordRelation.addWord(tokenItem,digit2num[c-'0']);
|
||||
} else if (letters.equals("a")) {
|
||||
wordRelation.addWord(tokenItem,"_a");
|
||||
} else {
|
||||
wordRelation.addWord(tokenItem,String.valueOf(c));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the integer value of the given string of Roman numerals.
|
||||
*
|
||||
* @param roman the string of Roman numbers
|
||||
*
|
||||
* @return the integer value
|
||||
*/
|
||||
public static int expandRoman(String roman) {
|
||||
int value = 0;
|
||||
|
||||
for (int p = 0; p < roman.length(); p++) {
|
||||
char c = roman.charAt(p);
|
||||
if (c == 'X') {
|
||||
value += 10;
|
||||
} else if (c == 'V') {
|
||||
value += 5;
|
||||
} else if (c == 'I') {
|
||||
if (p+1 < roman.length()) {
|
||||
char p1 = roman.charAt(p+1);
|
||||
if (p1 == 'V') {
|
||||
value += 4;
|
||||
p++;
|
||||
} else if (p1 == 'X') {
|
||||
value += 9;
|
||||
p++;
|
||||
} else {
|
||||
value += 1;
|
||||
}
|
||||
/**
|
||||
* Expands a two-digit string into a list of English words.
|
||||
*
|
||||
* @param numberString
|
||||
* the string which is the number to expand
|
||||
* @param wordRelation
|
||||
* words are added to this Relation
|
||||
*/
|
||||
private static void expand2DigitNumber(String numberString, WordRelation wordRelation, Item tokenItem) {
|
||||
if (numberString.charAt(0) == '0') {
|
||||
// numberString is "0X"
|
||||
if (numberString.charAt(1) == '0') {
|
||||
// numberString is "00", do nothing
|
||||
} else {
|
||||
// numberString is "01", "02" ...
|
||||
String number = digit2num[numberString.charAt(1) - '0'];
|
||||
wordRelation.addWord(tokenItem, number);
|
||||
}
|
||||
} else if (numberString.charAt(1) == '0') {
|
||||
// numberString is "10", "20", ...
|
||||
String number = digit2enty[numberString.charAt(0) - '0'];
|
||||
wordRelation.addWord(tokenItem, number);
|
||||
} else if (numberString.charAt(0) == '1') {
|
||||
// numberString is "11", "12", ..., "19"
|
||||
String number = digit2teen[numberString.charAt(1) - '0'];
|
||||
wordRelation.addWord(tokenItem, number);
|
||||
} else {
|
||||
value += 1;
|
||||
// numberString is "2X", "3X", ...
|
||||
String enty = digit2enty[numberString.charAt(0) - '0'];
|
||||
wordRelation.addWord(tokenItem, enty);
|
||||
expandDigits(numberString.substring(1, numberString.length()), wordRelation, tokenItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expands a three-digit string into a list of English words.
|
||||
*
|
||||
* @param numberString
|
||||
* the string which is the number to expand
|
||||
* @param wordRelation
|
||||
* words are added to this Relation
|
||||
*/
|
||||
private static void expand3DigitNumber(String numberString, WordRelation wordRelation, Item tokenItem) {
|
||||
if (numberString.charAt(0) == '0') {
|
||||
expandNumberAt(numberString, 1, wordRelation, tokenItem);
|
||||
} else {
|
||||
String hundredDigit = digit2num[numberString.charAt(0) - '0'];
|
||||
wordRelation.addWord(tokenItem, hundredDigit);
|
||||
wordRelation.addWord(tokenItem, "hundred");
|
||||
expandNumberAt(numberString, 1, wordRelation, tokenItem);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given character is a digit (0-9 only).
|
||||
*
|
||||
* @param ch the character to test
|
||||
*
|
||||
* @return true or false
|
||||
*/
|
||||
public static boolean isDigit(char ch) {
|
||||
return ('0' <= ch && ch <= '9');
|
||||
}
|
||||
/**
|
||||
* Expands a string that is a 4 to 6 digits number into a list of English words. For example, "333000" into "three hundred and
|
||||
* thirty-three thousand".
|
||||
*
|
||||
* @param numberString
|
||||
* the string which is the number to expand
|
||||
* @param wordRelation
|
||||
* words are added to this Relation
|
||||
*/
|
||||
private static void expandBelow7DigitNumber(String numberString, WordRelation wordRelation, Item tokenItem) {
|
||||
expandLargeNumber(numberString, "thousand", 3, wordRelation, tokenItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expands a string that is a 7 to 9 digits number into a list of English words. For example, "19000000" into nineteen
|
||||
* million.
|
||||
*
|
||||
* @param numberString
|
||||
* the string which is the number to expand
|
||||
* @param wordRelation
|
||||
* words are added to this Relation
|
||||
*/
|
||||
private static void expandBelow10DigitNumber(String numberString, WordRelation wordRelation, Item tokenItem) {
|
||||
expandLargeNumber(numberString, "million", 6, wordRelation, tokenItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expands a string that is a 10 to 12 digits number into a list of English words. For example, "27000000000" into
|
||||
* twenty-seven billion.
|
||||
*
|
||||
* @param numberString
|
||||
* the string which is the number to expand
|
||||
* @param wordRelation
|
||||
* words are added to this Relation
|
||||
*/
|
||||
private static void expandBelow13DigitNumber(String numberString, WordRelation wordRelation, Item tokenItem) {
|
||||
expandLargeNumber(numberString, "billion", 9, wordRelation, tokenItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expands a string that is a number longer than 3 digits into a list of English words. For example, "1000" into one thousand.
|
||||
*
|
||||
* @param numberString
|
||||
* the string which is the number to expand
|
||||
* @param order
|
||||
* either "thousand", "million", or "billion"
|
||||
* @param numberZeroes
|
||||
* the number of zeroes, depending on the order, so its either 3, 6, or 9
|
||||
* @param wordRelation
|
||||
* words are added to this Relation
|
||||
*/
|
||||
private static void expandLargeNumber(String numberString, String order, int numberZeroes, WordRelation wordRelation,
|
||||
Item tokenItem) {
|
||||
int numberDigits = numberString.length();
|
||||
|
||||
// parse out the prefix, e.g., "113" in "113,000"
|
||||
int i = numberDigits - numberZeroes;
|
||||
String part = numberString.substring(0, i);
|
||||
|
||||
// get how many thousands/millions/billions
|
||||
Item oldTail = wordRelation.getTail();
|
||||
|
||||
expandNumber(part, wordRelation, tokenItem);
|
||||
|
||||
if (wordRelation.getTail() == oldTail) {
|
||||
expandNumberAt(numberString, i, wordRelation, tokenItem);
|
||||
} else {
|
||||
wordRelation.addWord(tokenItem, order);
|
||||
expandNumberAt(numberString, i, wordRelation, tokenItem);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number string list of the given string starting at the given index. E.g., expandNumberAt("1100", 1) gives
|
||||
* "one hundred"
|
||||
*
|
||||
* @param numberString
|
||||
* the string which is the number to expand
|
||||
* @param startIndex
|
||||
* the starting position
|
||||
* @param wordRelation
|
||||
* words are added to this Relation
|
||||
*/
|
||||
private static void expandNumberAt(String numberString, int startIndex, WordRelation wordRelation, Item tokenItem) {
|
||||
expandNumber(numberString.substring(startIndex, numberString.length()), wordRelation, tokenItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expands given token to list of words pronouncing it as digits
|
||||
*
|
||||
* @param numberString
|
||||
* the string which is the number to expand
|
||||
* @param wordRelation
|
||||
* words are added to this Relation
|
||||
*/
|
||||
public static void expandDigits(String numberString, WordRelation wordRelation, Item tokenItem) {
|
||||
int numberDigits = numberString.length();
|
||||
for (int i = 0; i < numberDigits; i++) {
|
||||
char digit = numberString.charAt(i);
|
||||
if (isDigit(digit)) {
|
||||
wordRelation.addWord(tokenItem, digit2num[numberString.charAt(i) - '0']);
|
||||
} else {
|
||||
wordRelation.addWord(tokenItem, "umpty");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Expands the digit string of an ordinal number.
|
||||
*
|
||||
* @param rawNumberString
|
||||
* the string which is the number to expand
|
||||
* @param wordRelation
|
||||
* words are added to this Relation
|
||||
*/
|
||||
public static void expandOrdinal(String rawNumberString, WordRelation wordRelation, Item tokenItem) {
|
||||
// remove all ','s from the raw number string
|
||||
String numberString = Utilities.deleteChar(rawNumberString, ',');
|
||||
|
||||
expandNumber(numberString, wordRelation, tokenItem);
|
||||
|
||||
// get the last in the list of number strings
|
||||
Item lastItem = wordRelation.getTail();
|
||||
|
||||
if (lastItem != null) {
|
||||
|
||||
FeatureSet featureSet = lastItem.getFeatures();
|
||||
String lastNumber = featureSet.getString("name");
|
||||
String ordinal = findMatchInArray(lastNumber, digit2num, ord2num);
|
||||
|
||||
if (ordinal == null) {
|
||||
ordinal = findMatchInArray(lastNumber, digit2teen, ord2teen);
|
||||
}
|
||||
if (ordinal == null) {
|
||||
ordinal = findMatchInArray(lastNumber, digit2enty, ord2enty);
|
||||
}
|
||||
|
||||
if (lastNumber.equals("hundred")) {
|
||||
ordinal = "hundredth";
|
||||
} else if (lastNumber.equals("thousand")) {
|
||||
ordinal = "thousandth";
|
||||
} else if (lastNumber.equals("billion")) {
|
||||
ordinal = "billionth";
|
||||
}
|
||||
|
||||
// if there was an ordinal, set the last element of the list
|
||||
// to that ordinal; otherwise, don't do anything
|
||||
if (ordinal != null) {
|
||||
wordRelation.setLastWord(ordinal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a match of the given string in the given array, and returns the element at the same index in the returnInArray
|
||||
*
|
||||
* @param strToMatch
|
||||
* the string to match
|
||||
* @param matchInArray
|
||||
* the source array
|
||||
* @param returnInArray
|
||||
* the return array
|
||||
*
|
||||
* @return an element in returnInArray, or <code>null</code> if a match is not found
|
||||
*/
|
||||
private static String findMatchInArray(String strToMatch, String[] matchInArray, String[] returnInArray) {
|
||||
for (int i = 0; i < matchInArray.length; i++) {
|
||||
if (strToMatch.equals(matchInArray[i])) {
|
||||
if (i < returnInArray.length) {
|
||||
return returnInArray[i];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expands the given number string as pairs as in years or IDs
|
||||
*
|
||||
* @param numberString
|
||||
* the string which is the number to expand
|
||||
* @param wordRelation
|
||||
* words are added to this Relation
|
||||
*/
|
||||
public static void expandID(String numberString, WordRelation wordRelation, Item tokenItem) {
|
||||
|
||||
int numberDigits = numberString.length();
|
||||
|
||||
if ((numberDigits == 4) && (numberString.charAt(2) == '0') && (numberString.charAt(3) == '0')) {
|
||||
if (numberString.charAt(1) == '0') { // e.g. 2000, 3000
|
||||
expandNumber(numberString, wordRelation, tokenItem);
|
||||
} else {
|
||||
expandNumber(numberString.substring(0, 2), wordRelation, tokenItem);
|
||||
wordRelation.addWord(tokenItem, "hundred");
|
||||
}
|
||||
} else if ((numberDigits == 2) && (numberString.charAt(0) == '0')) {
|
||||
wordRelation.addWord(tokenItem, "oh");
|
||||
expandDigits(numberString.substring(1, 2), wordRelation, tokenItem);
|
||||
} else if ((numberDigits == 4 && numberString.charAt(1) == '0') || numberDigits < 3) {
|
||||
expandNumber(numberString, wordRelation, tokenItem);
|
||||
} else if (numberDigits % 2 == 1) {
|
||||
String firstDigit = digit2num[numberString.charAt(0) - '0'];
|
||||
wordRelation.addWord(tokenItem, firstDigit);
|
||||
expandID(numberString.substring(1, numberDigits), wordRelation, tokenItem);
|
||||
} else {
|
||||
expandNumber(numberString.substring(0, 2), wordRelation, tokenItem);
|
||||
expandID(numberString.substring(2, numberDigits), wordRelation, tokenItem);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Expands the given number string as a real number.
|
||||
*
|
||||
* @param numberString
|
||||
* the string which is the real number to expand
|
||||
* @param wordRelation
|
||||
* words are added to this Relation
|
||||
*/
|
||||
public static void expandReal(String numberString, WordRelation wordRelation, Item tokenItem) {
|
||||
|
||||
int stringLength = numberString.length();
|
||||
int position;
|
||||
|
||||
if (numberString.charAt(0) == '-') {
|
||||
// negative real numbers
|
||||
wordRelation.addWord(tokenItem, "minus");
|
||||
expandReal(numberString.substring(1, stringLength), wordRelation, tokenItem);
|
||||
} else if (numberString.charAt(0) == '+') {
|
||||
// prefixed with a '+'
|
||||
wordRelation.addWord(tokenItem, "plus");
|
||||
expandReal(numberString.substring(1, stringLength), wordRelation, tokenItem);
|
||||
} else if ((position = numberString.indexOf('e')) != -1 || (position = numberString.indexOf('E')) != -1) {
|
||||
// numbers with 'E' or 'e'
|
||||
expandReal(numberString.substring(0, position), wordRelation, tokenItem);
|
||||
wordRelation.addWord(tokenItem, "e");
|
||||
expandReal(numberString.substring(position + 1), wordRelation, tokenItem);
|
||||
} else if ((position = numberString.indexOf('.')) != -1) {
|
||||
// numbers with '.'
|
||||
String beforeDot = numberString.substring(0, position);
|
||||
if (beforeDot.length() > 0) {
|
||||
expandReal(beforeDot, wordRelation, tokenItem);
|
||||
}
|
||||
wordRelation.addWord(tokenItem, "point");
|
||||
String afterDot = numberString.substring(position + 1);
|
||||
if (afterDot.length() > 0) {
|
||||
expandDigits(afterDot, wordRelation, tokenItem);
|
||||
}
|
||||
} else {
|
||||
// everything else
|
||||
expandNumber(numberString, wordRelation, tokenItem);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Expands the given string of letters as a list of single char symbols.
|
||||
*
|
||||
* @param letters
|
||||
* the string of letters to expand
|
||||
* @param wordRelation
|
||||
* words are added to this Relation
|
||||
*/
|
||||
public static void expandLetters(String letters, WordRelation wordRelation, Item tokenItem) {
|
||||
letters = letters.toLowerCase();
|
||||
char c;
|
||||
|
||||
for (int i = 0; i < letters.length(); i++) {
|
||||
// if this is a number
|
||||
c = letters.charAt(i);
|
||||
|
||||
if (isDigit(c)) {
|
||||
wordRelation.addWord(tokenItem, digit2num[c - '0']);
|
||||
} else if (letters.equals("a")) {
|
||||
wordRelation.addWord(tokenItem, "_a");
|
||||
} else {
|
||||
wordRelation.addWord(tokenItem, String.valueOf(c));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the integer value of the given string of Roman numerals.
|
||||
*
|
||||
* @param roman
|
||||
* the string of Roman numbers
|
||||
*
|
||||
* @return the integer value
|
||||
*/
|
||||
public static int expandRoman(String roman) {
|
||||
int value = 0;
|
||||
|
||||
for (int p = 0; p < roman.length(); p++) {
|
||||
char c = roman.charAt(p);
|
||||
if (c == 'X') {
|
||||
value += 10;
|
||||
} else if (c == 'V') {
|
||||
value += 5;
|
||||
} else if (c == 'I') {
|
||||
if (p + 1 < roman.length()) {
|
||||
char p1 = roman.charAt(p + 1);
|
||||
if (p1 == 'V') {
|
||||
value += 4;
|
||||
p++;
|
||||
} else if (p1 == 'X') {
|
||||
value += 9;
|
||||
p++;
|
||||
} else {
|
||||
value += 1;
|
||||
}
|
||||
} else {
|
||||
value += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given character is a digit (0-9 only).
|
||||
*
|
||||
* @param ch
|
||||
* the character to test
|
||||
*
|
||||
* @return true or false
|
||||
*/
|
||||
public static boolean isDigit(char ch) {
|
||||
return ('0' <= ch && ch <= '9');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,16 +25,11 @@ import marytts.datatypes.MaryDataType;
|
|||
import marytts.modules.ProsodyGeneric;
|
||||
import marytts.server.MaryProperties;
|
||||
|
||||
public class Prosody extends ProsodyGeneric
|
||||
{
|
||||
public Prosody()
|
||||
{
|
||||
super(MaryDataType.PHONEMES,
|
||||
MaryDataType.INTONATION,
|
||||
Locale.ENGLISH,
|
||||
MaryProperties.localePrefix(Locale.ENGLISH)+".prosody.tobipredparams",
|
||||
MaryProperties.localePrefix(Locale.ENGLISH)+".prosody.accentPriorities",
|
||||
MaryProperties.localePrefix(Locale.ENGLISH)+".prosody.syllableaccents",
|
||||
MaryProperties.localePrefix(Locale.ENGLISH)+".prosody.paragraphdeclination");
|
||||
}
|
||||
public class Prosody extends ProsodyGeneric {
|
||||
public Prosody() {
|
||||
super(MaryDataType.PHONEMES, MaryDataType.INTONATION, Locale.ENGLISH, MaryProperties.localePrefix(Locale.ENGLISH)
|
||||
+ ".prosody.tobipredparams", MaryProperties.localePrefix(Locale.ENGLISH) + ".prosody.accentPriorities",
|
||||
MaryProperties.localePrefix(Locale.ENGLISH) + ".prosody.syllableaccents", MaryProperties
|
||||
.localePrefix(Locale.ENGLISH) + ".prosody.paragraphdeclination");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,40 +31,35 @@ import com.sun.speech.freetts.Utterance;
|
|||
import com.sun.speech.freetts.UtteranceProcessor;
|
||||
import com.sun.speech.freetts.lexicon.Lexicon;
|
||||
|
||||
|
||||
/**
|
||||
* Annotates an utterance with <code>Relation.SYLLABLE</code>,
|
||||
* <code>Relation.SYLLABLE_STRUCTURE</code>, and
|
||||
* <code>Relation.SEGMENT</code>.
|
||||
* To determine stress, the <code>isStressed</code> method relies upon
|
||||
* a phone ending in the number "1". Subclasses should override
|
||||
* <code>isStressed</code> and <code>deStress</code> if stresses are
|
||||
* determined in other ways.
|
||||
*
|
||||
* Annotates an utterance with <code>Relation.SYLLABLE</code>, <code>Relation.SYLLABLE_STRUCTURE</code>, and
|
||||
* <code>Relation.SEGMENT</code>. To determine stress, the <code>isStressed</code> method relies upon a phone ending in the number
|
||||
* "1". Subclasses should override <code>isStressed</code> and <code>deStress</code> if stresses are determined in other ways.
|
||||
*
|
||||
* @see Relation#SEGMENT
|
||||
* @see Relation#SYLLABLE
|
||||
* @see Relation#SYLLABLE_STRUCTURE
|
||||
*/
|
||||
public class Segmenter implements UtteranceProcessor {
|
||||
private final static String STRESS = "1";
|
||||
private final static String NO_STRESS = "0";
|
||||
private Map addenda;
|
||||
private final static String STRESS = "1";
|
||||
private final static String NO_STRESS = "0";
|
||||
private Map addenda;
|
||||
|
||||
/**
|
||||
* Annotates an utterance with <code>Relation.SYLLABLE</code>,
|
||||
* <code>Relation.SYLLABLE_STRUCTURE</code>, and
|
||||
* <code>Relation.SEGMENT</code>.
|
||||
*
|
||||
* @param utterance the utterance to process/tokenize
|
||||
*
|
||||
* @see Relation#SEGMENT
|
||||
* @see Relation#SYLLABLE
|
||||
* @see Relation#SYLLABLE_STRUCTURE
|
||||
*
|
||||
* @throws ProcessException if an IOException is thrown during the
|
||||
* processing of the utterance
|
||||
*/
|
||||
public void processUtterance(Utterance utterance) throws ProcessException {
|
||||
/**
|
||||
* Annotates an utterance with <code>Relation.SYLLABLE</code>, <code>Relation.SYLLABLE_STRUCTURE</code>, and
|
||||
* <code>Relation.SEGMENT</code>.
|
||||
*
|
||||
* @param utterance
|
||||
* the utterance to process/tokenize
|
||||
*
|
||||
* @see Relation#SEGMENT
|
||||
* @see Relation#SYLLABLE
|
||||
* @see Relation#SYLLABLE_STRUCTURE
|
||||
*
|
||||
* @throws ProcessException
|
||||
* if an IOException is thrown during the processing of the utterance
|
||||
*/
|
||||
public void processUtterance(Utterance utterance) throws ProcessException {
|
||||
|
||||
// preconditions
|
||||
if (utterance.getRelation(Relation.WORD) == null) {
|
||||
|
@ -183,80 +178,70 @@ public class Segmenter implements UtteranceProcessor {
|
|||
assert utterance.getRelation(Relation.SEGMENT) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the given phonene is stressed.
|
||||
* To determine stress, this method relies upon
|
||||
* a phone ending in the number "1". Subclasses should override this
|
||||
* method if stresses are determined in other ways.
|
||||
*
|
||||
* @param phone the phone to check
|
||||
*
|
||||
* @return true if the phone is stressed, otherwise false
|
||||
*/
|
||||
protected boolean isStressed(String phone) {
|
||||
return phone.endsWith("1");
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts stressed phone to regular phone. This method
|
||||
* merely removes the last character of the phone. Subclasses
|
||||
* should override this if another method is to be used.
|
||||
*
|
||||
* @param phone the phone to convert
|
||||
*
|
||||
* @return de-stressed phone
|
||||
*/
|
||||
protected String deStress(String phone) {
|
||||
String retPhone = phone;
|
||||
if (isStressed(phone)) {
|
||||
retPhone = phone.substring(0, phone.length() - 1);
|
||||
/**
|
||||
* Determines if the given phonene is stressed. To determine stress, this method relies upon a phone ending in the number "1".
|
||||
* Subclasses should override this method if stresses are determined in other ways.
|
||||
*
|
||||
* @param phone
|
||||
* the phone to check
|
||||
*
|
||||
* @return true if the phone is stressed, otherwise false
|
||||
*/
|
||||
protected boolean isStressed(String phone) {
|
||||
return phone.endsWith("1");
|
||||
}
|
||||
return retPhone;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void saveAddenda() throws IOException{
|
||||
String path = MaryProperties.maryBase()+"/log/addenda.log";
|
||||
if (addenda != null && path != null){
|
||||
try{
|
||||
String line;
|
||||
StringBuilder addendaBuf = new StringBuilder();
|
||||
addendaBuf.append("# Logfile contains words that are not in the lexicon"
|
||||
+"\n# and their transcriptions predicted by the LTS-rules"
|
||||
+"\n# (for English)\n");
|
||||
//add new entries
|
||||
Set words = addenda.keySet();
|
||||
for (Iterator it = words.iterator();it.hasNext();){
|
||||
String nextWord = (String) it.next();
|
||||
addendaBuf.append(nextWord+" "
|
||||
+addenda.get(nextWord)+"\n");
|
||||
}
|
||||
|
||||
//open addenda file
|
||||
PrintWriter addendaOut = new PrintWriter(
|
||||
new FileOutputStream(new File(path)));
|
||||
//print addendaBuf and close
|
||||
addendaOut.print(addendaBuf.toString());
|
||||
addendaOut.flush();
|
||||
addendaOut.close();
|
||||
} catch (Exception e){
|
||||
throw new IOException("Could not save addenda because : "
|
||||
+e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the simple name of this class.
|
||||
*
|
||||
* @return the simple name of this class
|
||||
*/
|
||||
public String toString() {
|
||||
return "Segmenter";
|
||||
}
|
||||
/**
|
||||
* Converts stressed phone to regular phone. This method merely removes the last character of the phone. Subclasses should
|
||||
* override this if another method is to be used.
|
||||
*
|
||||
* @param phone
|
||||
* the phone to convert
|
||||
*
|
||||
* @return de-stressed phone
|
||||
*/
|
||||
protected String deStress(String phone) {
|
||||
String retPhone = phone;
|
||||
if (isStressed(phone)) {
|
||||
retPhone = phone.substring(0, phone.length() - 1);
|
||||
}
|
||||
return retPhone;
|
||||
}
|
||||
|
||||
public void saveAddenda() throws IOException {
|
||||
String path = MaryProperties.maryBase() + "/log/addenda.log";
|
||||
if (addenda != null && path != null) {
|
||||
try {
|
||||
String line;
|
||||
StringBuilder addendaBuf = new StringBuilder();
|
||||
addendaBuf.append("# Logfile contains words that are not in the lexicon"
|
||||
+ "\n# and their transcriptions predicted by the LTS-rules" + "\n# (for English)\n");
|
||||
// add new entries
|
||||
Set words = addenda.keySet();
|
||||
for (Iterator it = words.iterator(); it.hasNext();) {
|
||||
String nextWord = (String) it.next();
|
||||
addendaBuf.append(nextWord + " " + addenda.get(nextWord) + "\n");
|
||||
}
|
||||
|
||||
// open addenda file
|
||||
PrintWriter addendaOut = new PrintWriter(new FileOutputStream(new File(path)));
|
||||
// print addendaBuf and close
|
||||
addendaOut.print(addendaBuf.toString());
|
||||
addendaOut.flush();
|
||||
addendaOut.close();
|
||||
} catch (Exception e) {
|
||||
throw new IOException("Could not save addenda because : " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the simple name of this class.
|
||||
*
|
||||
* @return the simple name of this class
|
||||
*/
|
||||
public String toString() {
|
||||
return "Segmenter";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,25 +25,15 @@ import marytts.datatypes.MaryDataType;
|
|||
import marytts.language.en_US.datatypes.USEnglishDataTypes;
|
||||
import marytts.modules.Utt2XMLBase;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert FreeTTS utterances into MaryXML format
|
||||
* (Durations, English).
|
||||
*
|
||||
* Convert FreeTTS utterances into MaryXML format (Durations, English).
|
||||
*
|
||||
* @author Marc Schröder
|
||||
*/
|
||||
|
||||
public class Utt2XMLDurationsEn extends Utt2XMLBase
|
||||
{
|
||||
public Utt2XMLDurationsEn()
|
||||
{
|
||||
super("Utt2XML DurationsEn",
|
||||
USEnglishDataTypes.FREETTS_MBROLISED_DURATIONS,
|
||||
MaryDataType.DURATIONS,
|
||||
Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public class Utt2XMLDurationsEn extends Utt2XMLBase {
|
||||
public Utt2XMLDurationsEn() {
|
||||
super("Utt2XML DurationsEn", USEnglishDataTypes.FREETTS_MBROLISED_DURATIONS, MaryDataType.DURATIONS, Locale.ENGLISH);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -25,25 +25,15 @@ import marytts.datatypes.MaryDataType;
|
|||
import marytts.language.en_US.datatypes.USEnglishDataTypes;
|
||||
import marytts.modules.Utt2XMLBase;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert FreeTTS utterances into MaryXML format
|
||||
* (Intonation, English).
|
||||
*
|
||||
* Convert FreeTTS utterances into MaryXML format (Intonation, English).
|
||||
*
|
||||
* @author Marc Schröder
|
||||
*/
|
||||
|
||||
public class Utt2XMLIntonationEn extends Utt2XMLBase
|
||||
{
|
||||
public Utt2XMLIntonationEn()
|
||||
{
|
||||
super("Utt2XML IntonationEn",
|
||||
USEnglishDataTypes.FREETTS_INTONATION,
|
||||
MaryDataType.INTONATION,
|
||||
Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public class Utt2XMLIntonationEn extends Utt2XMLBase {
|
||||
public Utt2XMLIntonationEn() {
|
||||
super("Utt2XML IntonationEn", USEnglishDataTypes.FREETTS_INTONATION, MaryDataType.INTONATION, Locale.ENGLISH);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -24,25 +24,15 @@ import java.util.Locale;
|
|||
import marytts.language.en_US.datatypes.USEnglishDataTypes;
|
||||
import marytts.modules.Utt2XMLBase;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert FreeTTS utterances into MaryXML format
|
||||
* (Pauses, English).
|
||||
*
|
||||
* Convert FreeTTS utterances into MaryXML format (Pauses, English).
|
||||
*
|
||||
* @author Marc Schröder
|
||||
*/
|
||||
|
||||
public class Utt2XMLPausesEn extends Utt2XMLBase
|
||||
{
|
||||
public Utt2XMLPausesEn()
|
||||
{
|
||||
super("Utt2XML PausesEn",
|
||||
USEnglishDataTypes.FREETTS_PAUSES,
|
||||
USEnglishDataTypes.PAUSES_US,
|
||||
Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public class Utt2XMLPausesEn extends Utt2XMLBase {
|
||||
public Utt2XMLPausesEn() {
|
||||
super("Utt2XML PausesEn", USEnglishDataTypes.FREETTS_PAUSES, USEnglishDataTypes.PAUSES_US, Locale.ENGLISH);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -24,25 +24,15 @@ import java.util.Locale;
|
|||
import marytts.language.en_US.datatypes.USEnglishDataTypes;
|
||||
import marytts.modules.Utt2XMLBase;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert FreeTTS utterances into MaryXML format
|
||||
* (Phrases, English).
|
||||
*
|
||||
* Convert FreeTTS utterances into MaryXML format (Phrases, English).
|
||||
*
|
||||
* @author Marc Schröder
|
||||
*/
|
||||
|
||||
public class Utt2XMLPhrasesEn extends Utt2XMLBase
|
||||
{
|
||||
public Utt2XMLPhrasesEn()
|
||||
{
|
||||
super("Utt2XML PhrasesEn",
|
||||
USEnglishDataTypes.FREETTS_PHRASES,
|
||||
USEnglishDataTypes.PHRASES_US,
|
||||
Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public class Utt2XMLPhrasesEn extends Utt2XMLBase {
|
||||
public Utt2XMLPhrasesEn() {
|
||||
super("Utt2XML PhrasesEn", USEnglishDataTypes.FREETTS_PHRASES, USEnglishDataTypes.PHRASES_US, Locale.ENGLISH);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -25,24 +25,15 @@ import marytts.datatypes.MaryDataType;
|
|||
import marytts.language.en_US.datatypes.USEnglishDataTypes;
|
||||
import marytts.modules.Utt2XMLBase;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert FreeTTS utterances into MaryXML format
|
||||
* (parts of speech, English).
|
||||
*
|
||||
* Convert FreeTTS utterances into MaryXML format (parts of speech, English).
|
||||
*
|
||||
* @author Marc Schröder
|
||||
*/
|
||||
|
||||
public class Utt2XMLPosEn extends Utt2XMLBase
|
||||
{
|
||||
public Utt2XMLPosEn()
|
||||
{
|
||||
super("Utt2XML PosEn",
|
||||
USEnglishDataTypes.FREETTS_POS,
|
||||
MaryDataType.PARTSOFSPEECH,
|
||||
Locale.ENGLISH);
|
||||
}
|
||||
public class Utt2XMLPosEn extends Utt2XMLBase {
|
||||
public Utt2XMLPosEn() {
|
||||
super("Utt2XML PosEn", USEnglishDataTypes.FREETTS_POS, MaryDataType.PARTSOFSPEECH, Locale.ENGLISH);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -25,25 +25,15 @@ import marytts.datatypes.MaryDataType;
|
|||
import marytts.language.en_US.datatypes.USEnglishDataTypes;
|
||||
import marytts.modules.Utt2XMLBase;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert FreeTTS utterances into MaryXML format
|
||||
* (Postprocessed, English).
|
||||
*
|
||||
* Convert FreeTTS utterances into MaryXML format (Postprocessed, English).
|
||||
*
|
||||
* @author Marc Schröder
|
||||
*/
|
||||
|
||||
public class Utt2XMLPostprocessedEn extends Utt2XMLBase
|
||||
{
|
||||
public Utt2XMLPostprocessedEn()
|
||||
{
|
||||
super("Utt2XML PostprocessedEn",
|
||||
USEnglishDataTypes.FREETTS_POSTPROCESSED,
|
||||
MaryDataType.ALLOPHONES,
|
||||
Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public class Utt2XMLPostprocessedEn extends Utt2XMLBase {
|
||||
public Utt2XMLPostprocessedEn() {
|
||||
super("Utt2XML PostprocessedEn", USEnglishDataTypes.FREETTS_POSTPROCESSED, MaryDataType.ALLOPHONES, Locale.ENGLISH);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -25,24 +25,15 @@ import marytts.datatypes.MaryDataType;
|
|||
import marytts.language.en_US.datatypes.USEnglishDataTypes;
|
||||
import marytts.modules.Utt2XMLBase;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert FreeTTS utterances into MaryXML format
|
||||
* (Segments, English).
|
||||
*
|
||||
* Convert FreeTTS utterances into MaryXML format (Segments, English).
|
||||
*
|
||||
* @author Marc Schröder
|
||||
*/
|
||||
|
||||
public class Utt2XMLSegmentsEn extends Utt2XMLBase
|
||||
{
|
||||
public Utt2XMLSegmentsEn()
|
||||
{
|
||||
super("Utt2XML SegmentsEn",
|
||||
USEnglishDataTypes.FREETTS_SEGMENTS,
|
||||
MaryDataType.PHONEMES,
|
||||
Locale.ENGLISH);
|
||||
}
|
||||
public class Utt2XMLSegmentsEn extends Utt2XMLBase {
|
||||
public Utt2XMLSegmentsEn() {
|
||||
super("Utt2XML SegmentsEn", USEnglishDataTypes.FREETTS_SEGMENTS, MaryDataType.PHONEMES, Locale.ENGLISH);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -25,25 +25,15 @@ import marytts.datatypes.MaryDataType;
|
|||
import marytts.language.en_US.datatypes.USEnglishDataTypes;
|
||||
import marytts.modules.Utt2XMLBase;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert FreeTTS utterances into MaryXML format
|
||||
* (Tokens, English).
|
||||
*
|
||||
* Convert FreeTTS utterances into MaryXML format (Tokens, English).
|
||||
*
|
||||
* @author Marc Schröder
|
||||
*/
|
||||
|
||||
public class Utt2XMLTokensEn extends Utt2XMLBase
|
||||
{
|
||||
public Utt2XMLTokensEn()
|
||||
{
|
||||
super("Utt2XML TokensEn",
|
||||
USEnglishDataTypes.FREETTS_TOKENS,
|
||||
MaryDataType.TOKENS,
|
||||
Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public class Utt2XMLTokensEn extends Utt2XMLBase {
|
||||
public Utt2XMLTokensEn() {
|
||||
super("Utt2XML TokensEn", USEnglishDataTypes.FREETTS_TOKENS, MaryDataType.TOKENS, Locale.ENGLISH);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -25,24 +25,15 @@ import marytts.datatypes.MaryDataType;
|
|||
import marytts.language.en_US.datatypes.USEnglishDataTypes;
|
||||
import marytts.modules.Utt2XMLBase;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert FreeTTS utterances into MaryXML format
|
||||
* (Words, English).
|
||||
*
|
||||
* Convert FreeTTS utterances into MaryXML format (Words, English).
|
||||
*
|
||||
* @author Marc Schröder
|
||||
*/
|
||||
|
||||
public class Utt2XMLWordsEn extends Utt2XMLBase
|
||||
{
|
||||
public Utt2XMLWordsEn()
|
||||
{
|
||||
super("Utt2XML WordsEn",
|
||||
USEnglishDataTypes.FREETTS_WORDS,
|
||||
MaryDataType.WORDS,
|
||||
Locale.ENGLISH);
|
||||
}
|
||||
public class Utt2XMLWordsEn extends Utt2XMLBase {
|
||||
public Utt2XMLWordsEn() {
|
||||
super("Utt2XML WordsEn", USEnglishDataTypes.FREETTS_WORDS, MaryDataType.WORDS, Locale.ENGLISH);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -20,76 +20,72 @@ import com.sun.speech.freetts.Utterance;
|
|||
*/
|
||||
public class WordRelation {
|
||||
|
||||
private Relation relation;
|
||||
private TokenToWords tokenToWords;
|
||||
private Relation relation;
|
||||
private TokenToWords tokenToWords;
|
||||
|
||||
|
||||
private WordRelation(Relation parentRelation, TokenToWords tokenToWords) {
|
||||
this.relation = parentRelation;
|
||||
this.tokenToWords = tokenToWords;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a WordRelation object with the given utterance and
|
||||
* TokenToWords.
|
||||
*
|
||||
* @param utterance the Utterance from which to create a Relation
|
||||
* @param tokenToWords the TokenToWords object to use
|
||||
*
|
||||
* @return a WordRelation object
|
||||
*/
|
||||
public static WordRelation createWordRelation(Utterance utterance,
|
||||
TokenToWords tokenToWords) {
|
||||
Relation relation = utterance.createRelation(Relation.WORD);
|
||||
return new WordRelation(relation, tokenToWords);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds a break as a feature to the last item in the list.
|
||||
*/
|
||||
public void addBreak() {
|
||||
Item wordItem = relation.getTail();
|
||||
if (wordItem != null) {
|
||||
FeatureSet featureSet = wordItem.getFeatures();
|
||||
featureSet.setString("break", "1");
|
||||
private WordRelation(Relation parentRelation, TokenToWords tokenToWords) {
|
||||
this.relation = parentRelation;
|
||||
this.tokenToWords = tokenToWords;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a WordRelation object with the given utterance and TokenToWords.
|
||||
*
|
||||
* @param utterance
|
||||
* the Utterance from which to create a Relation
|
||||
* @param tokenToWords
|
||||
* the TokenToWords object to use
|
||||
*
|
||||
* @return a WordRelation object
|
||||
*/
|
||||
public static WordRelation createWordRelation(Utterance utterance, TokenToWords tokenToWords) {
|
||||
Relation relation = utterance.createRelation(Relation.WORD);
|
||||
return new WordRelation(relation, tokenToWords);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a word as an Item to this WordRelation object.
|
||||
*
|
||||
* @param word the word to add
|
||||
*/
|
||||
public void addWord(Item tokenItem, String word) {
|
||||
assert (tokenItem != null);
|
||||
Item wordItem = tokenItem.createDaughter();
|
||||
FeatureSet featureSet = wordItem.getFeatures();
|
||||
featureSet.setString("name", word);
|
||||
relation.appendItem(wordItem);
|
||||
}
|
||||
/**
|
||||
* Adds a break as a feature to the last item in the list.
|
||||
*/
|
||||
public void addBreak() {
|
||||
Item wordItem = relation.getTail();
|
||||
if (wordItem != null) {
|
||||
FeatureSet featureSet = wordItem.getFeatures();
|
||||
featureSet.setString("break", "1");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a word as an Item to this WordRelation object.
|
||||
*
|
||||
* @param word
|
||||
* the word to add
|
||||
*/
|
||||
public void addWord(Item tokenItem, String word) {
|
||||
assert(tokenItem != null);
|
||||
Item wordItem = tokenItem.createDaughter();
|
||||
FeatureSet featureSet = wordItem.getFeatures();
|
||||
featureSet.setString("name", word);
|
||||
relation.appendItem(wordItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the last Item in this WordRelation to the given word.
|
||||
*
|
||||
* @param word the word to set
|
||||
*/
|
||||
public void setLastWord(String word) {
|
||||
Item lastItem = relation.getTail();
|
||||
FeatureSet featureSet = lastItem.getFeatures();
|
||||
featureSet.setString("name", word);
|
||||
}
|
||||
/**
|
||||
* Sets the last Item in this WordRelation to the given word.
|
||||
*
|
||||
* @param word
|
||||
* the word to set
|
||||
*/
|
||||
public void setLastWord(String word) {
|
||||
Item lastItem = relation.getTail();
|
||||
FeatureSet featureSet = lastItem.getFeatures();
|
||||
featureSet.setString("name", word);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the last item in this WordRelation.
|
||||
*
|
||||
* @return the last item
|
||||
*/
|
||||
public Item getTail() {
|
||||
return relation.getTail();
|
||||
}
|
||||
/**
|
||||
* Returns the last item in this WordRelation.
|
||||
*
|
||||
* @return the last item
|
||||
*/
|
||||
public Item getTail() {
|
||||
return relation.getTail();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,35 +29,24 @@ import org.w3c.dom.Element;
|
|||
|
||||
import com.sun.speech.freetts.Utterance;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert a MaryXML DOM tree into FreeTTS utterances
|
||||
* (durations, English).
|
||||
*
|
||||
* Convert a MaryXML DOM tree into FreeTTS utterances (durations, English).
|
||||
*
|
||||
* @author Marc Schröder
|
||||
*/
|
||||
|
||||
public class XML2UttDurationsEn extends XML2UttBase
|
||||
{
|
||||
public XML2UttDurationsEn() {
|
||||
super("XML2Utt DurationsEn",
|
||||
MaryDataType.DURATIONS,
|
||||
USEnglishDataTypes.FREETTS_DURATIONS,
|
||||
Locale.ENGLISH);
|
||||
}
|
||||
public class XML2UttDurationsEn extends XML2UttBase {
|
||||
public XML2UttDurationsEn() {
|
||||
super("XML2Utt DurationsEn", MaryDataType.DURATIONS, USEnglishDataTypes.FREETTS_DURATIONS, Locale.ENGLISH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Depending on the data type, find the right information in the sentence
|
||||
* and insert it into the utterance.
|
||||
*/
|
||||
protected void fillUtterance(Utterance utterance, Element sentence)
|
||||
{
|
||||
fillUtterance(utterance, sentence,
|
||||
true, // create word relation
|
||||
true, // create sylstruct relation
|
||||
false); // don't create target relation
|
||||
}
|
||||
/**
|
||||
* Depending on the data type, find the right information in the sentence and insert it into the utterance.
|
||||
*/
|
||||
protected void fillUtterance(Utterance utterance, Element sentence) {
|
||||
fillUtterance(utterance, sentence, true, // create word relation
|
||||
true, // create sylstruct relation
|
||||
false); // don't create target relation
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,35 +29,24 @@ import org.w3c.dom.Element;
|
|||
|
||||
import com.sun.speech.freetts.Utterance;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert a MaryXML DOM tree into FreeTTS utterances
|
||||
* (intonation, English).
|
||||
*
|
||||
* Convert a MaryXML DOM tree into FreeTTS utterances (intonation, English).
|
||||
*
|
||||
* @author Marc Schröder
|
||||
*/
|
||||
|
||||
public class XML2UttIntonationEn extends XML2UttBase
|
||||
{
|
||||
public XML2UttIntonationEn() {
|
||||
super("XML2Utt IntonationEn",
|
||||
MaryDataType.INTONATION,
|
||||
USEnglishDataTypes.FREETTS_INTONATION,
|
||||
Locale.ENGLISH);
|
||||
}
|
||||
public class XML2UttIntonationEn extends XML2UttBase {
|
||||
public XML2UttIntonationEn() {
|
||||
super("XML2Utt IntonationEn", MaryDataType.INTONATION, USEnglishDataTypes.FREETTS_INTONATION, Locale.ENGLISH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Depending on the data type, find the right information in the sentence
|
||||
* and insert it into the utterance.
|
||||
*/
|
||||
protected void fillUtterance(Utterance utterance, Element sentence)
|
||||
{
|
||||
fillUtterance(utterance, sentence,
|
||||
true, // create word relation
|
||||
true, // create sylstruct relation
|
||||
false); // don't create target relation
|
||||
}
|
||||
/**
|
||||
* Depending on the data type, find the right information in the sentence and insert it into the utterance.
|
||||
*/
|
||||
protected void fillUtterance(Utterance utterance, Element sentence) {
|
||||
fillUtterance(utterance, sentence, true, // create word relation
|
||||
true, // create sylstruct relation
|
||||
false); // don't create target relation
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -28,35 +28,24 @@ import org.w3c.dom.Element;
|
|||
|
||||
import com.sun.speech.freetts.Utterance;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert a MaryXML DOM tree into FreeTTS utterances
|
||||
* (pauses, English).
|
||||
*
|
||||
* Convert a MaryXML DOM tree into FreeTTS utterances (pauses, English).
|
||||
*
|
||||
* @author Marc Schröder
|
||||
*/
|
||||
|
||||
public class XML2UttPausesEn extends XML2UttBase
|
||||
{
|
||||
public XML2UttPausesEn() {
|
||||
super("XML2Utt PausesEn",
|
||||
USEnglishDataTypes.PAUSES_US,
|
||||
USEnglishDataTypes.FREETTS_PAUSES,
|
||||
Locale.ENGLISH);
|
||||
}
|
||||
public class XML2UttPausesEn extends XML2UttBase {
|
||||
public XML2UttPausesEn() {
|
||||
super("XML2Utt PausesEn", USEnglishDataTypes.PAUSES_US, USEnglishDataTypes.FREETTS_PAUSES, Locale.ENGLISH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Depending on the data type, find the right information in the sentence
|
||||
* and insert it into the utterance.
|
||||
*/
|
||||
protected void fillUtterance(Utterance utterance, Element sentence)
|
||||
{
|
||||
fillUtterance(utterance, sentence,
|
||||
true, // create word relation
|
||||
true, // create sylstruct relation
|
||||
false); // don't create target relation
|
||||
}
|
||||
/**
|
||||
* Depending on the data type, find the right information in the sentence and insert it into the utterance.
|
||||
*/
|
||||
protected void fillUtterance(Utterance utterance, Element sentence) {
|
||||
fillUtterance(utterance, sentence, true, // create word relation
|
||||
true, // create sylstruct relation
|
||||
false); // don't create target relation
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -28,36 +28,25 @@ import org.w3c.dom.Element;
|
|||
|
||||
import com.sun.speech.freetts.Utterance;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert a MaryXML DOM tree into FreeTTS utterances
|
||||
* (phrases, English).
|
||||
*
|
||||
* Convert a MaryXML DOM tree into FreeTTS utterances (phrases, English).
|
||||
*
|
||||
* @author Marc Schröder
|
||||
*/
|
||||
|
||||
public class XML2UttPhrasesEn extends XML2UttBase
|
||||
{
|
||||
public XML2UttPhrasesEn() {
|
||||
super("XML2Utt PhrasesEn",
|
||||
USEnglishDataTypes.PHRASES_US,
|
||||
USEnglishDataTypes.FREETTS_PHRASES,
|
||||
Locale.ENGLISH);
|
||||
}
|
||||
public class XML2UttPhrasesEn extends XML2UttBase {
|
||||
public XML2UttPhrasesEn() {
|
||||
super("XML2Utt PhrasesEn", USEnglishDataTypes.PHRASES_US, USEnglishDataTypes.FREETTS_PHRASES, Locale.ENGLISH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Depending on the data type, find the right information in the sentence
|
||||
* and insert it into the utterance.
|
||||
*/
|
||||
protected void fillUtterance(Utterance utterance, Element sentence)
|
||||
{
|
||||
fillUtterance(utterance, sentence,
|
||||
true, // create word relation
|
||||
false, // do not create sylstruct relation
|
||||
false); // don't create target relation
|
||||
/**
|
||||
* Depending on the data type, find the right information in the sentence and insert it into the utterance.
|
||||
*/
|
||||
protected void fillUtterance(Utterance utterance, Element sentence) {
|
||||
fillUtterance(utterance, sentence, true, // create word relation
|
||||
false, // do not create sylstruct relation
|
||||
false); // don't create target relation
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,36 +29,25 @@ import org.w3c.dom.Element;
|
|||
|
||||
import com.sun.speech.freetts.Utterance;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert a MaryXML DOM tree into FreeTTS utterances
|
||||
* (parts of speech, English).
|
||||
*
|
||||
* Convert a MaryXML DOM tree into FreeTTS utterances (parts of speech, English).
|
||||
*
|
||||
* @author Marc Schröder
|
||||
*/
|
||||
|
||||
public class XML2UttPosEn extends XML2UttBase
|
||||
{
|
||||
public XML2UttPosEn() {
|
||||
super("XML2Utt PosEn",
|
||||
MaryDataType.PARTSOFSPEECH,
|
||||
USEnglishDataTypes.FREETTS_POS,
|
||||
Locale.ENGLISH);
|
||||
}
|
||||
public class XML2UttPosEn extends XML2UttBase {
|
||||
public XML2UttPosEn() {
|
||||
super("XML2Utt PosEn", MaryDataType.PARTSOFSPEECH, USEnglishDataTypes.FREETTS_POS, Locale.ENGLISH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Depending on the data type, find the right information in the sentence
|
||||
* and insert it into the utterance.
|
||||
*/
|
||||
protected void fillUtterance(Utterance utterance, Element sentence)
|
||||
{
|
||||
fillUtterance(utterance, sentence,
|
||||
true, // create word relation
|
||||
false, // do not create sylstruct relation
|
||||
false); // don't create target relation
|
||||
/**
|
||||
* Depending on the data type, find the right information in the sentence and insert it into the utterance.
|
||||
*/
|
||||
protected void fillUtterance(Utterance utterance, Element sentence) {
|
||||
fillUtterance(utterance, sentence, true, // create word relation
|
||||
false, // do not create sylstruct relation
|
||||
false); // don't create target relation
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,35 +29,24 @@ import org.w3c.dom.Element;
|
|||
|
||||
import com.sun.speech.freetts.Utterance;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert a MaryXML DOM tree into FreeTTS utterances
|
||||
* (postprocessed, English).
|
||||
*
|
||||
* Convert a MaryXML DOM tree into FreeTTS utterances (postprocessed, English).
|
||||
*
|
||||
* @author Marc Schröder
|
||||
*/
|
||||
|
||||
public class XML2UttPostprocessedEn extends XML2UttBase
|
||||
{
|
||||
public XML2UttPostprocessedEn() {
|
||||
super("XML2Utt PostprocessedEn",
|
||||
MaryDataType.ALLOPHONES,
|
||||
USEnglishDataTypes.FREETTS_POSTPROCESSED,
|
||||
Locale.ENGLISH);
|
||||
}
|
||||
public class XML2UttPostprocessedEn extends XML2UttBase {
|
||||
public XML2UttPostprocessedEn() {
|
||||
super("XML2Utt PostprocessedEn", MaryDataType.ALLOPHONES, USEnglishDataTypes.FREETTS_POSTPROCESSED, Locale.ENGLISH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Depending on the data type, find the right information in the sentence
|
||||
* and insert it into the utterance.
|
||||
*/
|
||||
protected void fillUtterance(Utterance utterance, Element sentence)
|
||||
{
|
||||
fillUtterance(utterance, sentence,
|
||||
true, // create word relation
|
||||
true, // create sylstruct relation
|
||||
false); // don't create target relation
|
||||
}
|
||||
/**
|
||||
* Depending on the data type, find the right information in the sentence and insert it into the utterance.
|
||||
*/
|
||||
protected void fillUtterance(Utterance utterance, Element sentence) {
|
||||
fillUtterance(utterance, sentence, true, // create word relation
|
||||
true, // create sylstruct relation
|
||||
false); // don't create target relation
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,35 +29,24 @@ import org.w3c.dom.Element;
|
|||
|
||||
import com.sun.speech.freetts.Utterance;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert a MaryXML DOM tree into FreeTTS utterances
|
||||
* (segments, English).
|
||||
*
|
||||
* Convert a MaryXML DOM tree into FreeTTS utterances (segments, English).
|
||||
*
|
||||
* @author Marc Schröder
|
||||
*/
|
||||
|
||||
public class XML2UttSegmentsEn extends XML2UttBase
|
||||
{
|
||||
public XML2UttSegmentsEn() {
|
||||
super("XML2Utt SegmentsEn",
|
||||
MaryDataType.PHONEMES,
|
||||
USEnglishDataTypes.FREETTS_SEGMENTS,
|
||||
Locale.ENGLISH);
|
||||
}
|
||||
public class XML2UttSegmentsEn extends XML2UttBase {
|
||||
public XML2UttSegmentsEn() {
|
||||
super("XML2Utt SegmentsEn", MaryDataType.PHONEMES, USEnglishDataTypes.FREETTS_SEGMENTS, Locale.ENGLISH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Depending on the data type, find the right information in the sentence
|
||||
* and insert it into the utterance.
|
||||
*/
|
||||
protected void fillUtterance(Utterance utterance, Element sentence)
|
||||
{
|
||||
fillUtterance(utterance, sentence,
|
||||
true, // create word relation
|
||||
true, // create sylstruct relation
|
||||
false); // don't create target relation
|
||||
}
|
||||
/**
|
||||
* Depending on the data type, find the right information in the sentence and insert it into the utterance.
|
||||
*/
|
||||
protected void fillUtterance(Utterance utterance, Element sentence) {
|
||||
fillUtterance(utterance, sentence, true, // create word relation
|
||||
true, // create sylstruct relation
|
||||
false); // don't create target relation
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,36 +29,25 @@ import org.w3c.dom.Element;
|
|||
|
||||
import com.sun.speech.freetts.Utterance;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert a MaryXML DOM tree into FreeTTS utterances
|
||||
* (tokens, English).
|
||||
*
|
||||
* Convert a MaryXML DOM tree into FreeTTS utterances (tokens, English).
|
||||
*
|
||||
* @author Marc Schröder
|
||||
*/
|
||||
|
||||
public class XML2UttTokensEn extends XML2UttBase
|
||||
{
|
||||
public XML2UttTokensEn() {
|
||||
super("XML2Utt TokensEn",
|
||||
MaryDataType.TOKENS,
|
||||
USEnglishDataTypes.FREETTS_TOKENS,
|
||||
Locale.ENGLISH);
|
||||
}
|
||||
public class XML2UttTokensEn extends XML2UttBase {
|
||||
public XML2UttTokensEn() {
|
||||
super("XML2Utt TokensEn", MaryDataType.TOKENS, USEnglishDataTypes.FREETTS_TOKENS, Locale.ENGLISH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Depending on the data type, find the right information in the sentence
|
||||
* and insert it into the utterance.
|
||||
*/
|
||||
protected void fillUtterance(Utterance utterance, Element sentence)
|
||||
{
|
||||
fillUtterance(utterance, sentence,
|
||||
false, // do not create word relation
|
||||
false, // do not create sylstruct relation
|
||||
false); // don't create target relation
|
||||
/**
|
||||
* Depending on the data type, find the right information in the sentence and insert it into the utterance.
|
||||
*/
|
||||
protected void fillUtterance(Utterance utterance, Element sentence) {
|
||||
fillUtterance(utterance, sentence, false, // do not create word relation
|
||||
false, // do not create sylstruct relation
|
||||
false); // don't create target relation
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,36 +29,25 @@ import org.w3c.dom.Element;
|
|||
|
||||
import com.sun.speech.freetts.Utterance;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert a MaryXML DOM tree into FreeTTS utterances
|
||||
* (words, English).
|
||||
*
|
||||
* Convert a MaryXML DOM tree into FreeTTS utterances (words, English).
|
||||
*
|
||||
* @author Marc Schröder
|
||||
*/
|
||||
|
||||
public class XML2UttWordsEn extends XML2UttBase
|
||||
{
|
||||
public XML2UttWordsEn() {
|
||||
super("XML2Utt WordsEn",
|
||||
MaryDataType.WORDS,
|
||||
USEnglishDataTypes.FREETTS_WORDS,
|
||||
Locale.ENGLISH);
|
||||
}
|
||||
public class XML2UttWordsEn extends XML2UttBase {
|
||||
public XML2UttWordsEn() {
|
||||
super("XML2Utt WordsEn", MaryDataType.WORDS, USEnglishDataTypes.FREETTS_WORDS, Locale.ENGLISH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Depending on the data type, find the right information in the sentence
|
||||
* and insert it into the utterance.
|
||||
*/
|
||||
protected void fillUtterance(Utterance utterance, Element sentence)
|
||||
{
|
||||
fillUtterance(utterance, sentence,
|
||||
true, // create word relation
|
||||
false, // do not create sylstruct relation
|
||||
false); // don't create target relation
|
||||
/**
|
||||
* Depending on the data type, find the right information in the sentence and insert it into the utterance.
|
||||
*/
|
||||
protected void fillUtterance(Utterance utterance, Element sentence) {
|
||||
fillUtterance(utterance, sentence, true, // create word relation
|
||||
false, // do not create sylstruct relation
|
||||
false); // don't create target relation
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -22,56 +22,67 @@ package marytts.language.en.prosody;
|
|||
/**
|
||||
* Information on how to recognise and how to realise different sentence types.
|
||||
*/
|
||||
public class SentenceType
|
||||
{
|
||||
public static final SentenceType declarative =
|
||||
new SentenceType( "declarative", "L-L%", "H-L%", "H-", "!H*", "L+H*");
|
||||
public static final SentenceType interrogative =
|
||||
new SentenceType("interrogative", "H-H%", "H-L%", "H-", "L*", "H*");
|
||||
public static final SentenceType exclamation =
|
||||
new SentenceType("exclamation", "L-L%", "H-L%", "H-", "H*", "H*");
|
||||
public static final SentenceType interrogYN =
|
||||
new SentenceType("interrogYN", "H-H%", "H-L%", "H-", "L*", "H*");
|
||||
public static final SentenceType interrogWH =
|
||||
new SentenceType("interrogWH", "L-L%", "H-L%", "H-", "H*", "H*");
|
||||
public class SentenceType {
|
||||
public static final SentenceType declarative = new SentenceType("declarative", "L-L%", "H-L%", "H-", "!H*", "L+H*");
|
||||
public static final SentenceType interrogative = new SentenceType("interrogative", "H-H%", "H-L%", "H-", "L*", "H*");
|
||||
public static final SentenceType exclamation = new SentenceType("exclamation", "L-L%", "H-L%", "H-", "H*", "H*");
|
||||
public static final SentenceType interrogYN = new SentenceType("interrogYN", "H-H%", "H-L%", "H-", "L*", "H*");
|
||||
public static final SentenceType interrogWH = new SentenceType("interrogWH", "L-L%", "H-L%", "H-", "H*", "H*");
|
||||
|
||||
public static SentenceType punctuationType(String punct)
|
||||
{
|
||||
if (punct.equals(".")) return declarative;
|
||||
else if (punct.equals("?")) return interrogative;
|
||||
else if (punct.equals("!")) return exclamation;
|
||||
else return null;
|
||||
}
|
||||
public static SentenceType punctuationType(String punct) {
|
||||
if (punct.equals("."))
|
||||
return declarative;
|
||||
else if (punct.equals("?"))
|
||||
return interrogative;
|
||||
else if (punct.equals("!"))
|
||||
return exclamation;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
private String name;
|
||||
private String sentenceFinalBoundary;
|
||||
private String nonFinalMajorBoundary;
|
||||
private String minorBoundary;
|
||||
private String nuclearAccent;
|
||||
private String nonNuclearAccent;
|
||||
private String name;
|
||||
private String sentenceFinalBoundary;
|
||||
private String nonFinalMajorBoundary;
|
||||
private String minorBoundary;
|
||||
private String nuclearAccent;
|
||||
private String nonNuclearAccent;
|
||||
|
||||
private SentenceType(String name,
|
||||
String sentenceFinalBoundary,
|
||||
String nonFinalMajorBoundary,
|
||||
String minorBoundary,
|
||||
String nuclearAccent,
|
||||
String nonNuclearAccent)
|
||||
{
|
||||
this.name = name;
|
||||
this.sentenceFinalBoundary = sentenceFinalBoundary;
|
||||
this.nonFinalMajorBoundary = nonFinalMajorBoundary;
|
||||
this.minorBoundary = minorBoundary;
|
||||
this.nuclearAccent = nuclearAccent;
|
||||
this.nonNuclearAccent = nonNuclearAccent;
|
||||
}
|
||||
private SentenceType(String name, String sentenceFinalBoundary, String nonFinalMajorBoundary, String minorBoundary,
|
||||
String nuclearAccent, String nonNuclearAccent) {
|
||||
this.name = name;
|
||||
this.sentenceFinalBoundary = sentenceFinalBoundary;
|
||||
this.nonFinalMajorBoundary = nonFinalMajorBoundary;
|
||||
this.minorBoundary = minorBoundary;
|
||||
this.nuclearAccent = nuclearAccent;
|
||||
this.nonNuclearAccent = nonNuclearAccent;
|
||||
}
|
||||
|
||||
public String name() { return name; }
|
||||
public String toString() { return name(); }
|
||||
public String sentenceFinalBoundary() { return sentenceFinalBoundary; }
|
||||
public String nonFinalMajorBoundary() { return nonFinalMajorBoundary; }
|
||||
public String minorBoundary() { return minorBoundary; }
|
||||
public String nuclearAccent() { return nuclearAccent; }
|
||||
public String nonNuclearAccent() { return nonNuclearAccent; }
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return name();
|
||||
}
|
||||
|
||||
public String sentenceFinalBoundary() {
|
||||
return sentenceFinalBoundary;
|
||||
}
|
||||
|
||||
public String nonFinalMajorBoundary() {
|
||||
return nonFinalMajorBoundary;
|
||||
}
|
||||
|
||||
public String minorBoundary() {
|
||||
return minorBoundary;
|
||||
}
|
||||
|
||||
public String nuclearAccent() {
|
||||
return nuclearAccent;
|
||||
}
|
||||
|
||||
public String nonNuclearAccent() {
|
||||
return nonNuclearAccent;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -23,25 +23,29 @@ import marytts.datatypes.MaryDataType;
|
|||
import marytts.datatypes.MaryXML;
|
||||
|
||||
/**
|
||||
* This class will register the data types that are specific for the
|
||||
* US English synthesis modules.
|
||||
* This class will register the data types that are specific for the US English synthesis modules.
|
||||
*
|
||||
* @author marc
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class USEnglishDataTypes
|
||||
{
|
||||
public static final MaryDataType FREETTS_CONTOUR = new MaryDataType("FREETTS_CONTOUR", false, false, MaryDataType.UTTERANCES);
|
||||
public static final MaryDataType FREETTS_DURATIONS = new MaryDataType("FREETTS_DURATIONS", false, false, MaryDataType.UTTERANCES);
|
||||
public static final MaryDataType FREETTS_INTONATION = new MaryDataType("FREETTS_INTONATION", false, false, MaryDataType.UTTERANCES);
|
||||
public static final MaryDataType FREETTS_MBROLISED_DURATIONS = new MaryDataType("FREETTS_MBROLISED_DURATIONS", false, false, MaryDataType.UTTERANCES);
|
||||
public static final MaryDataType FREETTS_PAUSES = new MaryDataType("FREETTS_PAUSES", false, false, MaryDataType.UTTERANCES);
|
||||
public static final MaryDataType FREETTS_PHRASES = new MaryDataType("FREETTS_PHRASES", false, false, MaryDataType.UTTERANCES);
|
||||
public static final MaryDataType FREETTS_POS = new MaryDataType("FREETTS_POS", false, false, MaryDataType.UTTERANCES);
|
||||
public static final MaryDataType FREETTS_POSTPROCESSED = new MaryDataType("FREETTS_POSTPROCESSED", false, false, MaryDataType.UTTERANCES);
|
||||
public static final MaryDataType FREETTS_SEGMENTS = new MaryDataType("FREETTS_SEGMENTS", false, false, MaryDataType.UTTERANCES);
|
||||
public static final MaryDataType FREETTS_TOKENS = new MaryDataType("FREETTS_TOKENS", false, false, MaryDataType.UTTERANCES);
|
||||
public static final MaryDataType FREETTS_WORDS = new MaryDataType("FREETTS_WORDS", false, false, MaryDataType.UTTERANCES);
|
||||
public static final MaryDataType PAUSES_US = new MaryDataType("PAUSES_US", true, true, MaryDataType.MARYXML, MaryXML.MARYXML);
|
||||
public static final MaryDataType PHRASES_US = new MaryDataType("PHRASES_US", true, true, MaryDataType.MARYXML, MaryXML.MARYXML);
|
||||
public class USEnglishDataTypes {
|
||||
public static final MaryDataType FREETTS_CONTOUR = new MaryDataType("FREETTS_CONTOUR", false, false, MaryDataType.UTTERANCES);
|
||||
public static final MaryDataType FREETTS_DURATIONS = new MaryDataType("FREETTS_DURATIONS", false, false,
|
||||
MaryDataType.UTTERANCES);
|
||||
public static final MaryDataType FREETTS_INTONATION = new MaryDataType("FREETTS_INTONATION", false, false,
|
||||
MaryDataType.UTTERANCES);
|
||||
public static final MaryDataType FREETTS_MBROLISED_DURATIONS = new MaryDataType("FREETTS_MBROLISED_DURATIONS", false, false,
|
||||
MaryDataType.UTTERANCES);
|
||||
public static final MaryDataType FREETTS_PAUSES = new MaryDataType("FREETTS_PAUSES", false, false, MaryDataType.UTTERANCES);
|
||||
public static final MaryDataType FREETTS_PHRASES = new MaryDataType("FREETTS_PHRASES", false, false, MaryDataType.UTTERANCES);
|
||||
public static final MaryDataType FREETTS_POS = new MaryDataType("FREETTS_POS", false, false, MaryDataType.UTTERANCES);
|
||||
public static final MaryDataType FREETTS_POSTPROCESSED = new MaryDataType("FREETTS_POSTPROCESSED", false, false,
|
||||
MaryDataType.UTTERANCES);
|
||||
public static final MaryDataType FREETTS_SEGMENTS = new MaryDataType("FREETTS_SEGMENTS", false, false,
|
||||
MaryDataType.UTTERANCES);
|
||||
public static final MaryDataType FREETTS_TOKENS = new MaryDataType("FREETTS_TOKENS", false, false, MaryDataType.UTTERANCES);
|
||||
public static final MaryDataType FREETTS_WORDS = new MaryDataType("FREETTS_WORDS", false, false, MaryDataType.UTTERANCES);
|
||||
public static final MaryDataType PAUSES_US = new MaryDataType("PAUSES_US", true, true, MaryDataType.MARYXML, MaryXML.MARYXML);
|
||||
public static final MaryDataType PHRASES_US = new MaryDataType("PHRASES_US", true, true, MaryDataType.MARYXML,
|
||||
MaryXML.MARYXML);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче