当前位置: 首页>>代码示例>>Java>>正文


Java MaryUtils类代码示例

本文整理汇总了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;
   }
 
开发者ID:HaraldBerthelsen,项目名称:marytts-lang-ar,代码行数:22,代码来源:TextToMaryXML.java

示例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>&lt;voice xml:lang="..."&gt;</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 + "'");
   }
 
开发者ID:HaraldBerthelsen,项目名称:marytts-lang-ar,代码行数:47,代码来源:TextToMaryXML.java

示例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()) + "\">";
}
 
开发者ID:ArticulatedSocialAgentsPlatform,项目名称:HmiCore,代码行数:6,代码来源:MaryTTSGenerator.java

示例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()) + "\">";
}
 
开发者ID:ArticulatedSocialAgentsPlatform,项目名称:HmiCore,代码行数:6,代码来源:MaryTTSGenerator.java

示例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()) + "\">";
}
 
开发者ID:ArticulatedSocialAgentsPlatform,项目名称:HmiCore,代码行数:5,代码来源:MaryTTSGenerator.java

示例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()) + "\">";
}
 
开发者ID:ArticulatedSocialAgentsPlatform,项目名称:HmiCore,代码行数:6,代码来源:MaryTTSGenerator.java

示例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;
   }
 
开发者ID:HaraldBerthelsen,项目名称:marytts-lang-ar,代码行数:82,代码来源:JPhonemiser.java


注:本文中的marytts.util.MaryUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。