public L2FVoice(string name, VoiceGender gender, VoiceAge age, string culture, L2FSpeechEngine engine) : base(engine) { Name = name; Gender = gender; Age = age; Culture = culture; }
public static void setupVoices() { ModConfig config = Helper.ReadConfig <ModConfig>(); currentCulture = CultureInfo.CreateSpecificCulture(config.lang); culturelang = config.lang.Split('-')[0]; voices = new Dictionary <string, SpeechProfile>(); foreach (SpeechConfig npc in config.voices) { VoiceGender gender = (npc.gender == 0) ? VoiceGender.Male : VoiceGender.Female; VoiceAge age = VoiceAge.NotSet; if (npc.age == 3) { age = VoiceAge.Senior; } else if (npc.age == 0) { age = VoiceAge.Adult; } else if (npc.age == 1) { age = VoiceAge.Teen; } else if (npc.age == 2) { age = VoiceAge.Child; } voices.Add(npc.name, new SpeechProfile(npc.voicename, gender, age, 0, currentCulture)); } }
public void SelectVoiceByHints(VoiceGender gender, VoiceAge age, int voiceAlternate, CultureInfo culture) { Helpers.ThrowIfNull(culture, nameof(culture)); if (voiceAlternate < 0) { throw new ArgumentOutOfRangeException(nameof(voiceAlternate), SR.Get(SRID.PromptBuilderInvalidVariant)); } if (!VoiceInfo.ValidateGender(gender)) { throw new ArgumentException(SR.Get(SRID.EnumInvalid, "VoiceGender"), nameof(gender)); } if (!VoiceInfo.ValidateAge(age)) { throw new ArgumentException(SR.Get(SRID.EnumInvalid, "VoiceAge"), nameof(age)); } TTSVoice ttsVoice = VoiceSynthesizer.GetEngine(null, culture, gender, age, voiceAlternate, true); if (ttsVoice == null) { // No match - throw throw new InvalidOperationException(SR.Get(SRID.SynthesizerSetVoiceNoMatch)); } VoiceSynthesizer.Voice = ttsVoice; }
public SpeechProfile(string name, VoiceGender gender, VoiceAge age, int alternate, CultureInfo culture) { this.name = name; this.gender = gender; this.age = age; this.alternate = alternate; this.culture = culture; }
public WindowsVoice(int rate, VoiceGender gender, VoiceAge age, CultureInfo language) { Language = language; Synthesizer = new SpeechSynthesizer(); Synthesizer.SetOutputToDefaultAudioDevice(); Synthesizer.Rate = 1; Synthesizer.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult, 0, language); }
internal static bool ValidateAge(VoiceAge age) { if (age != VoiceAge.Adult && age != VoiceAge.Child && age != 0 && age != VoiceAge.Senior) { return(age == VoiceAge.Teen); } return(true); }
/// <summary> /// Selects a voice with specific characteristics. /// </summary> public void SelectVoiceByHints(VoiceGender gender, VoiceAge age, int voiceAlternate, CultureInfo culture) { _gender = gender; _age = age; _voiceAlternate = voiceAlternate; _culture = culture; SelectVoice(); }
public static void SetUp(VoiceGender gender, VoiceAge age) { //Customise the voice //speechSyn.SelectVoice("Vocalizer Expressive Samantha Harpo 22kHz"); speechSyn.SelectVoiceByHints(gender, age, 0); speechSyn.SpeakStarted += SpeechSyn_SpeakStarted; speechSyn.SpeakCompleted += SpeechSyn_SpeakCompleted; }
/// <summary> /// Play a sound using the voice assistant /// </summary> /// <param name="phrase">What it will say</param> /// <param name="gender">What gender</param> /// <param name="age">What age</param> /// <param name="whichCulture">Which culture to use Ex: en-US,pt-BR and etc</param> public static void PlayPhrase(string phrase, VoiceGender gender = VoiceGender.Female, VoiceAge age = VoiceAge.Adult, string whichCulture = "en-US") { using (var playphrase = new SpeechSynthesizer()) { playphrase.SelectVoiceByHints(gender, age, -2, new CultureInfo(whichCulture)); playphrase.SetOutputToDefaultAudioDevice(); playphrase.Speak(phrase); } }
public TextToSpeech(string text, VoiceGender voiceGender, VoiceAge voiceAge, int voicePosition, string culture, int volume, int rate) { Text = text; VoiceGender = voiceGender; VoiceAge = voiceAge; VoicePosition = voicePosition; CultureInfo = culture; Volume = volume; Rate = rate; }
internal VoiceInfo(VoiceGender gender, VoiceAge age, int voiceAlternate) { if (voiceAlternate < 0) { throw new ArgumentOutOfRangeException("voiceAlternate", SR.Get(SRID.PromptBuilderInvalidVariant)); } _gender = gender; _age = age; _variant = voiceAlternate + 1; }
internal void SetVoice(string name, CultureInfo culture, VoiceGender gender, VoiceAge age, int variant) { TTSVoice ttsVoice = _voiceSynthesis.GetEngine(name, culture, gender, age, variant, false); if (!ttsVoice.Equals(_ttsVoice)) { _ttsVoice = ttsVoice; _fNotInTextSeg = true; } }
public TextToSpeech(string text, VoiceGender voiceGender, VoiceAge voiceAge, int voicePosition, string culture, int volume, int rate ) { Text = text; VoiceGender = voiceGender; VoiceAge = voiceAge; VoicePosition = voicePosition; CultureInfo = culture; Volume = volume; Rate = rate; }
internal static bool TryConvertAge(string sAge, out VoiceAge age) { bool result = false; age = VoiceAge.NotSet; switch (sAge) { case "child": age = VoiceAge.Child; break; case "teenager": case "teen": age = VoiceAge.Teen; break; case "adult": age = VoiceAge.Adult; break; case "elder": case "senior": age = VoiceAge.Senior; break; } int result2; if (age != 0) { result = true; } else if (int.TryParse(sAge, out result2)) { if (result2 <= 12) { age = VoiceAge.Child; } else if (result2 <= 22) { age = VoiceAge.Teen; } else if (result2 <= 47) { age = VoiceAge.Adult; } else { age = VoiceAge.Senior; } result = true; } return(result); }
public TextToSpeech() { _synthesizer = new SpeechSynthesizer(); _synthesizer.Volume = Convert.ToInt32(ConfigurationManager.AppSettings["SpeechSynthesizer_Volume"]); _synthesizer.Rate = Convert.ToInt32(ConfigurationManager.AppSettings["SpeechSynthesizer_Rate"]); string strVoiceGender = ConfigurationManager.AppSettings["SpeechSynthesizer_VoiceGender"]; string strVoiceAge = ConfigurationManager.AppSettings["SpeechSynthesizer_VoiceAge"]; VoiceGender voiceGender = VoiceGender.Neutral; VoiceAge voiceAge = VoiceAge.Senior; // Set voice gender if (strVoiceGender.Equals("Male", StringComparison.InvariantCultureIgnoreCase)) { voiceGender = VoiceGender.Male; } else if (strVoiceGender.Equals("Female", StringComparison.InvariantCultureIgnoreCase)) { voiceGender = VoiceGender.Female; } else if (strVoiceGender.Equals("Neutral", StringComparison.InvariantCultureIgnoreCase)) { voiceGender = VoiceGender.Neutral; } else if (strVoiceGender.Equals("Default", StringComparison.InvariantCultureIgnoreCase)) { voiceGender = VoiceGender.NotSet; } // Set voice age if (strVoiceAge.Equals("Adult", StringComparison.InvariantCultureIgnoreCase)) { voiceAge = VoiceAge.Adult; } else if (strVoiceAge.Equals("Child", StringComparison.InvariantCultureIgnoreCase)) { voiceAge = VoiceAge.Child; } else if (strVoiceAge.Equals("Default", StringComparison.InvariantCultureIgnoreCase)) { voiceAge = VoiceAge.NotSet; } else if (strVoiceAge.Equals("Senior", StringComparison.InvariantCultureIgnoreCase)) { voiceAge = VoiceAge.Senior; } else if (strVoiceAge.Equals("Teen", StringComparison.InvariantCultureIgnoreCase)) { voiceAge = VoiceAge.Teen; } _synthesizer.SelectVoiceByHints(voiceGender, voiceAge); }
private void AgeText_SelectedIndexChanged(object sender, EventArgs e) { switch (AgeText.Text) { case "Child": age = VoiceAge.Child; break; case "Teen": age = VoiceAge.Teen; break; case "Adult": age = VoiceAge.Adult; break; case "Senior": age = VoiceAge.Senior; break; } s.SelectVoiceByHints(gender, age); }
public object ProcessVoice(string name, CultureInfo culture, VoiceGender gender, VoiceAge age, int variant, bool fNewCulture, List <SsmlXmlAttribute> extraNamespace) { _speakInfo.SetVoice(name, culture, gender, age, variant); return(_speakInfo.Voice); }
public object ProcessTextBlock(bool isParagraph, object voice, ref FragmentState fragmentState, CultureInfo culture, bool newCulture, VoiceGender gender, VoiceAge age) { if (culture != null && newCulture) { _speakInfo.SetVoice(null, culture, gender, age, 1); } if (isParagraph) { _paragraphStarted = true; } else { _sentenceStarted = true; } return(_speakInfo.Voice); }
/// <summary> /// Sets the current voice to one based on the <paramref name="gender"/>, <paramref name="age"/>, <paramref name="voiceAlternate"/> and <paramref name="culture"/>. /// </summary> /// <param name="gender">The gender of the voice to change to.</param> /// <param name="age">The age of the voice.</param> /// <param name="voiceAlternate">The voice alternate.</param> /// <param name="culture">The specific culture to select a voice for.</param> public override void SelectVoiceByHints(VoiceGender gender, VoiceAge age, int voiceAlternate, CultureInfo culture) { this.speechSynthesizer.SelectVoiceByHints(gender, age, voiceAlternate, culture); }
internal VoiceInfo(VoiceGender gender, VoiceAge age) { _gender = gender; _age = age; }
/// <summary> /// Sets the age of the SpeechSynthesizer object with a /// VoiceAge enumeration. /// </summary> public SpeakR Age(VoiceAge age) { _age = age; SelectVoice(); return(this); }
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); }
public void StartVoice(VoiceGender gender, VoiceAge age, int voiceAlternate) { StartVoice(new VoiceInfo(gender, age, voiceAlternate)); }
internal static bool ValidateAge(VoiceAge age) { return(age == VoiceAge.Adult || age == VoiceAge.Child || age == VoiceAge.NotSet || age == VoiceAge.Senior || age == VoiceAge.Teen); }
public void SelectVoiceByHints(VoiceGender gender, VoiceAge age, int voiceAlternate) { SelectVoiceByHints(gender, age, voiceAlternate, CultureInfo.CurrentUICulture); }
public void SelectVoiceByHints(VoiceGender gender, VoiceAge age) { SelectVoiceByHints(gender, age, 1, CultureInfo.CurrentUICulture); }
/// <summary> /// Sets the current voice to one based on the <paramref name="gender"/>, <paramref name="age"/>, <paramref name="voiceAlternate"/> and <paramref name="culture"/>. /// </summary> /// <param name="gender">The gender of the voice to change to.</param> /// <param name="age">The age of the voice.</param> /// <param name="voiceAlternate">The voice alternate.</param> /// <param name="culture">The specific culture to select a voice for.</param> public virtual void SelectVoiceByHints(VoiceGender gender, VoiceAge age, int voiceAlternate, CultureInfo culture) { throw new NotImplementedException(); }
/// <summary> /// Sets the current voice to one based on the <paramref name="gender"/> and <paramref name="age"/>. /// </summary> /// <param name="gender">The gender of the voice to change to.</param> /// <param name="age">The age of the voice.</param> public virtual void SelectVoiceByHints(VoiceGender gender, VoiceAge age) { throw new NotImplementedException(); }
/// <summary> /// Sets the current voice to one based on the <paramref name="gender"/> and <paramref name="age"/>. /// </summary> /// <param name="gender">The gender of the voice to change to.</param> /// <param name="age">The age of the voice.</param> public override void SelectVoiceByHints(VoiceGender gender, VoiceAge age) { this.speechSynthesizer.SelectVoiceByHints(gender, age); }
public void StartVoice(VoiceGender gender, VoiceAge age) { StartVoice(new VoiceInfo(gender, age)); }
/// <summary>Selects a voice with a specific gender, age, and locale.</summary> /// <param name="gender">The gender.</param> /// <param name="age">The age.</param> /// <param name="cultureInfo">The culture information.</param> /// <exception cref="ArgumentNullException">cultureInfo.</exception> public void SelectVoiceByHints(VoiceGender gender, VoiceAge age, CultureInfo cultureInfo) => this.cultureInfo = cultureInfo ?? throw new ArgumentNullException(nameof(cultureInfo));
public void voidEditVoice(VoiceGender gender, VoiceAge age) { synth.SelectVoiceByHints(gender, age); }
public object ProcessTextBlock(bool isParagraph, object voice, ref FragmentState fragmentState, CultureInfo culture, bool newCulture, VoiceGender gender, VoiceAge age) { _writer.WriteStartElement(isParagraph ? "p" : "s"); if (culture != null) { _writer.WriteAttributeString("xml", "lang", null, culture.Name); } return(null); }
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); }
public void Speak(string filename, VoiceGender genderHint = VoiceGender.Female, VoiceAge ageHint = VoiceAge.Child) { synthesizer.SelectVoiceByHints(genderHint, ageHint); synthesizer.Volume = 80; synthesizer.Rate = 0; lines = File.ReadAllLines(filename); var startTime = DateTime.Now; lines.ToList().ForEach(line => { if (line.StartsWith("#")) { return; } try { var parsed = Parse(line); var parsedWithVariables = InsertVariable(parsed); WaitForTime(startTime, parsedWithVariables.TimeType, parsedWithVariables.AtTime); var functionRun = RunFunction(synthesizer, parsedWithVariables, DateTime.Now); if (functionRun) { return; } TimedDialogs.SpeakString(synthesizer, parsedWithVariables); } catch (Exception ex) { Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.fff")} Skipping: {line}"); Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.fff")} {ex.Message}"); Console.WriteLine(ex.StackTrace); } }); Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.fff")} Speaking: Bye"); synthesizer.Speak("Bye"); }