本文整理汇总了Java中marytts.util.MaryUtils类的典型用法代码示例。如果您正苦于以下问题:Java MaryUtils类的具体用法?Java MaryUtils怎么用?Java MaryUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MaryUtils类属于marytts.util包,在下文中一共展示了MaryUtils类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import marytts.util.MaryUtils; //导入依赖的package包/类
public MaryData process(MaryData d) throws Exception {
String plainText = MaryUtils.normaliseUnicodePunctuation(d.getPlainText());
MaryData result = new MaryData(outputType(), d.getLocale(), true);
Document doc = result.getDocument();
Element root = doc.getDocumentElement();
Locale l = determineLocale(plainText, d.getLocale());
root.setAttribute("xml:lang", MaryUtils.locale2xmllang(l));
if (splitIntoParagraphs) { // Empty lines separate paragraphs
String[] inputTexts = plainText.split("\\n(\\s*\\n)+");
for (int i = 0; i < inputTexts.length; i++) {
String paragraph = inputTexts[i].trim();
if (paragraph.length() == 0)
continue;
appendParagraph(paragraph, root, d.getLocale());
}
} else { // The whole text as one single paragraph
appendParagraph(plainText, root, d.getLocale());
}
result.setDocument(doc);
return result;
}
示例2: appendParagraph
import marytts.util.MaryUtils; //导入依赖的package包/类
/**
* Append one paragraph of text to the rawmaryxml document. If the text language (as determined by #getLanguage(text)) differs
* from the enclosing document's language, the paragraph element is enclosed with a <code><voice xml:lang="..."></code>
* element.
*
* @param text
* the paragraph text.
* @param root
* the root node of the rawmaryxml document, where to insert the paragraph.
* @param defaultLocale
* the default locale, in case the language of the text cannot be determined.
*/
private void appendParagraph(String text, Element root, Locale defaultLocale) throws Exception {
Element insertHere = root;
String rootLanguage = root.getAttribute("xml:lang");
String textLanguage = MaryUtils.locale2xmllang(determineLocale(text, defaultLocale));
if (!textLanguage.equals(rootLanguage)) {
Element voiceElement = MaryXML.appendChildElement(root, MaryXML.VOICE);
voiceElement.setAttribute("xml:lang", textLanguage);
insertHere = voiceElement;
}
// HB 151109 If the text is in Arabic script, change it to buckwalter
System.out.println("Input text on next line:");
System.out.println(text);
if ( containsArabic(text) ) {
if ( !isVocalised(text) ) {
text = vocaliseText(text);
}
text = arabicToBuckwalter(text);
}
System.out.println("Buckwalter text on next line:");
System.out.println(text);
insertHere = MaryXML.appendChildElement(insertHere, MaryXML.PARAGRAPH);
// Now insert the entire plain text as a single text node
insertHere.appendChild(root.getOwnerDocument().createTextNode(text));
// And, for debugging, read it:
Text textNode = (Text) insertHere.getFirstChild();
String textNodeString = textNode.getData();
logger.debug("textNodeString=`" + textNodeString + "'");
}
示例3: getSSMLStartTag
import marytts.util.MaryUtils; //导入依赖的package包/类
public synchronized String getSSMLStartTag()
{
return "<speak xmlns=\"http://www.w3.org/2001/10/synthesis\" xml:lang=\""
+ MaryUtils.locale2xmllang(voice.getLocale()) + "\">";
}
示例4: getMaryXMLStartTag
import marytts.util.MaryUtils; //导入依赖的package包/类
public synchronized String getMaryXMLStartTag()
{
return "<maryxml version=\"0.5\" xmlns=\"http://mary.dfki.de/2002/MaryXML\" xml:lang=\""
+ MaryUtils.locale2xmllang(voice.getLocale()) + "\">";
}
示例5: getSSMLStartTag
import marytts.util.MaryUtils; //导入依赖的package包/类
public synchronized String getSSMLStartTag()
{
return "<speak xmlns=\"http://www.w3.org/2001/10/synthesis\" xml:lang=\"" + MaryUtils.locale2xmllang(marytts.getLocale()) + "\">";
}
示例6: getMaryXMLStartTag
import marytts.util.MaryUtils; //导入依赖的package包/类
public synchronized String getMaryXMLStartTag()
{
return "<maryxml version=\"0.5\" xmlns=\"http://mary.dfki.de/2002/MaryXML\" xml:lang=\""
+ MaryUtils.locale2xmllang(marytts.getLocale()) + "\">";
}
示例7: phonemise
import marytts.util.MaryUtils; //导入依赖的package包/类
@Override
public String phonemise(String text, String pos, StringBuilder g2pMethod)
{
//Arabic question:
//Where to remove initial A if previous word ends with vowel?
//Here only one word at a time..
//It is now done in Postlex.java
text = arabicToBuckwalter(text);
// First, try a simple userdict and lexicon lookup:
//System.err.println("Text: "+text);
String result = userdictLookup(text, pos);
if (result != null) {
g2pMethod.append("userdict");
return result;
}
//HB 151118 Don't do lexicon lookup until the lexicon is fixed!
//result = lexiconLookup(text, pos);
if (result != null) {
g2pMethod.append("lexicon");
return result;
}
// Lookup attempts failed. Try normalising exotic letters
// (diacritics on vowels, etc.), look up again:
String normalised = MaryUtils.normaliseUnicodeLetters(text, getLocale());
if (!normalised.equals(text)) {
result = userdictLookup(normalised, pos);
if (result != null) {
g2pMethod.append("userdict");
return result;
}
//HB 151118 Don't do lexicon lookup until the lexicon is fixed!
//result = lexiconLookup(normalised, pos);
if (result != null) {
g2pMethod.append("lexicon");
return result;
}
}
// Cannot find it in the lexicon -- apply letter-to-sound rules
// to the normalised form
//HB It is probably better to not use lts rules, but a simpler conversion of buckwalter to phonetics.
//String phones = lts.predictPronunciation(text);
//Trying instead a simple buckwalter to phonetic mapping (should be the same as in Arabic-Phonetiser)
/*
//This check should be done before vocalisation - when the word appears here it's been vocalised and doesn't match the fixed words (ex lndn appears as lanodan)
result = isFixedWord(text);
if (result != null) {
g2pMethod.append("lexicon");
return result;
}
*/
String phones = buckwalterToPhonetic(text);
System.out.println("Text: "+text+", phones: "+phones);
result = lts.syllabify(phones);
System.out.println("Syllabified: "+result);
if (result != null) {
g2pMethod.append("rules");
return result;
}
return null;
}