Element root = (Element) doc.appendChild(doc.createElementNS(installerNamespaceURI, "marytts-install")); Element desc = (Element) root.appendChild(doc.createElementNS(installerNamespaceURI, getComponentTypeString())); desc.setAttribute("locale", MaryUtils.locale2xmllang(locale)); desc.setAttribute("name", name); desc.setAttribute("version", version);
Element root = (Element) doc.appendChild(doc.createElementNS(installerNamespaceURI, "marytts-install")); Element desc = (Element) root.appendChild(doc.createElementNS(installerNamespaceURI, getComponentTypeString())); desc.setAttribute("locale", MaryUtils.locale2xmllang(locale)); desc.setAttribute("name", name); desc.setAttribute("version", version);
/** * 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) { 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; } 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 + "'"); }
/** * 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) { 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; } 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 + "'"); }
protected MaryData createMaryDataFromText(String text, Locale locale) { Document doc = MaryXML.newDocument(); doc.getDocumentElement().setAttribute("xml:lang", MaryUtils.locale2xmllang(locale)); doc.getDocumentElement().appendChild(doc.createTextNode(text)); MaryData md = new MaryData(MaryDataType.RAWMARYXML, locale); md.setDocument(doc); return md; }
protected MaryData createMaryDataFromText(String text, Locale locale) { Document doc = MaryXML.newDocument(); doc.getDocumentElement().setAttribute("xml:lang", MaryUtils.locale2xmllang(locale)); doc.getDocumentElement().appendChild(doc.createTextNode(text)); MaryData md = new MaryData(MaryDataType.RAWMARYXML, locale); md.setDocument(doc); return md; }
transformer.transform(domSource, domResult); maryxmlDocument.getDocumentElement().setAttribute("xml:lang", MaryUtils.locale2xmllang(d.getLocale()));
transformer.transform(domSource, domResult); maryxmlDocument.getDocumentElement().setAttribute("xml:lang", MaryUtils.locale2xmllang(d.getLocale()));
Document doc = result.getDocument(); Element root = doc.getDocumentElement(); root.setAttribute("xml:lang", MaryUtils.locale2xmllang(d.getLocale())); Element insertHere = root; Voice defaultVoice = d.getDefaultVoice();
Document doc = result.getDocument(); Element root = doc.getDocumentElement(); root.setAttribute("xml:lang", MaryUtils.locale2xmllang(d.getLocale())); Element insertHere = root; Voice defaultVoice = d.getDefaultVoice();
Voice v = Voice.getVoice(name); if (v != null && v.getLocale() != null) language = MaryUtils.locale2xmllang(v.getLocale());
Voice v = Voice.getVoice(name); if (v != null && v.getLocale() != null) language = MaryUtils.locale2xmllang(v.getLocale());
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; }
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; }
public String getXMLCompatibleLocaleString() { return MaryUtils.locale2xmllang(locale); }
private void createEmotionDocument() { emotionDocument = docBuilder.getDOMImplementation().createDocument(null, "emotion", null); org.w3c.dom.Element e = emotionDocument.getDocumentElement(); e.setAttributeNS("http://www.w3.org/XML/1998/namespace", "lang", MaryUtils.locale2xmllang(locale)); e.setAttribute("activation", String.valueOf(activation)); e.setAttribute("evaluation", String.valueOf(evaluation)); e.setAttribute("power", String.valueOf(power)); e.appendChild(emotionDocument.createTextNode(text)); }
protected Map<String, String> getVariableSubstitutionMap(Map<String, String> extra) { Map<String, String> m = new HashMap<String, String>(); m.put("MARYVERSION", voiceVersion); m.put("VOICENAME", voiceName); m.put("LOCALE", MaryUtils.locale2xmllang(locale)); m.put("LANG", locale.getLanguage()); m.put("DISPLAYLANG", locale.getDisplayLanguage()); m.put("GENDER", gender); m.put("DOMAIN", domain); m.put("SAMPLINGRATE", String.valueOf(samplingRate)); m.put("PACKAGE", getPackageName()); m.put("VOICECLASS", isUnitSelectionVoice ? "marytts.unitselection.UnitSelectionVoice" : "marytts.htsengine.HMMVoice"); if (extra != null) { m.putAll(extra); } return m; }
/** * 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) { 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; } 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 + "'"); }
transformer.transform(domSource, domResult); maryxmlDocument.getDocumentElement().setAttribute("xml:lang", MaryUtils.locale2xmllang(d.getLocale()));
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; }