string GetXmlText(string text, InstalledVoiceEx vi, int volume, int pitch, int rate, bool isComment) { string xml; string name = vi.Name; var sw = new StringWriter(); var w = new XmlTextWriter(sw); w.Formatting = Formatting.Indented; w.WriteStartElement("voice"); if (string.IsNullOrEmpty(language) || vi.CultureLCID.ToString("X3") != language) { w.WriteAttributeString("required", "name=" + name); } else { w.WriteAttributeString("required", "name=" + name + ";language=" + language); //+ vi.CultureLCID.ToString("X3")); } w.WriteStartElement("volume"); w.WriteAttributeString("level", volume.ToString()); w.WriteStartElement("rate"); w.WriteAttributeString("absspeed", rate.ToString()); w.WriteStartElement("pitch"); w.WriteAttributeString("absmiddle", (isComment ? _PitchComment : pitch).ToString()); // Replace acronyms with full values. text = SettingsManager.Current.ReplaceAcronyms(text); w.WriteRaw(text); w.WriteEndElement(); w.WriteEndElement(); w.WriteEndElement(); w.WriteEndElement(); xml = sw.ToString(); w.Close(); return(xml); }
public bool IsSameVoice(InstalledVoiceEx voice) { var isSame = Source == voice.Source && CultureName == voice.CultureName && Name == voice.Name && Gender == voice.Gender; // If source is amazon then compare engine too. if (Source == VoiceSource.Amazon) { var query = System.Web.HttpUtility.ParseQueryString(SourceKeys ?? ""); var voiceQuery = System.Web.HttpUtility.ParseQueryString(voice.SourceKeys ?? ""); Engine engine = query[_KeyEngine]; Engine voiceEngine = voiceQuery[_KeyEngine]; isSame &= engine == voiceEngine; } return(isSame); }