public object ProcessVoice(string name, CultureInfo culture, VoiceGender gender, VoiceAge age, int variant, bool fNewCulture, List <SsmlXmlAttribute> extraNamespace)
 {
     _writer.WriteStartElement("voice");
     if (!string.IsNullOrEmpty(name))
     {
         _writer.WriteAttributeString("name", name);
     }
     if (fNewCulture && culture != null)
     {
         _writer.WriteAttributeString("xml", "lang", null, culture.Name);
     }
     if (gender != 0)
     {
         _writer.WriteAttributeString("gender", gender.ToString().ToLowerInvariant());
     }
     if (age != 0)
     {
         XmlTextWriter writer = _writer;
         int           num    = (int)age;
         writer.WriteAttributeString("age", num.ToString(CultureInfo.InvariantCulture));
     }
     if (variant > 0)
     {
         _writer.WriteAttributeString("variant", variant.ToString(CultureInfo.InvariantCulture));
     }
     if (extraNamespace != null)
     {
         foreach (SsmlXmlAttribute item in extraNamespace)
         {
             _writer.WriteAttributeString("xmlns", item._name, item._ns, item._value);
         }
     }
     return(null);
 }
Beispiel #2
0
        public object ProcessVoice(string name, CultureInfo culture, VoiceGender gender, VoiceAge age, int variant, bool fNewCulture, List <SsmlXmlAttribute> extraNamespace)
        {
            _writer.WriteStartElement("voice");
            if (!string.IsNullOrEmpty(name))
            {
                _writer.WriteAttributeString("name", name);
            }
            if (fNewCulture && culture != null)
            {
                _writer.WriteAttributeString("xml", "lang", null, culture.Name);
            }
            if (gender != VoiceGender.NotSet)
            {
                _writer.WriteAttributeString("gender", gender.ToString().ToLowerInvariant());
            }
            if (age != VoiceAge.NotSet)
            {
                _writer.WriteAttributeString("age", ((int)age).ToString(CultureInfo.InvariantCulture));
            }
            if (variant > 0)
            {
                _writer.WriteAttributeString("variant", (variant).ToString(CultureInfo.InvariantCulture));
            }

            // write all the additional namespace
            if (extraNamespace != null)
            {
                foreach (SsmlXmlAttribute ns in extraNamespace)
                {
                    _writer.WriteAttributeString("xmlns", ns._name, ns._ns, ns._value);
                }
            }
            return(null);
        }
Beispiel #3
0
 public static IAsyncAction Say(string text, string language, VoiceGender gender)
 {
     var text2speech = new SpeechSynthesizer();
     var ssml = string.Format("<speak version=\"1.0\" xmlns=\"http://www.w3.org/2001/10/synthesis\" xml:lang=\"{0}\"><voice gender=\"{1}\">{2}</voice></speak>", language, gender.ToString().ToLower(), text);
     return text2speech.SpeakSsmlAsync(ssml);
 }