public void GetVoices() { var installedVoices = _synth.GetInstalledVoices(); // Variable for debug. var installedVoicesCount = installedVoices.Count; //installedVoicesCount = 0; if (installedVoicesCount == 0) { throw new Exception(@"No se encontraron voces instaladas"); } if (Voices == null) { Voices = new List <string>(); } // Output information about all of the installed voices. Debug.WriteLine(@"Installed voices -"); foreach (var voice in installedVoices) { var info = voice.VoiceInfo; var infoDescription = info.Description; string auxvoice; if (infoDescription.StartsWith("Microsoft")) { auxvoice = infoDescription; } else { //auxvoice = info.Name; continue; } if (!Voices.Contains(auxvoice)) { Voices.Add(auxvoice); } var audioFormats = ""; foreach (var fmt in info.SupportedAudioFormats) { audioFormats += $"{fmt.EncodingFormat.ToString()}\n"; } Debug.WriteLine(@" Name: " + info.Name); Debug.WriteLine(@" Culture: " + info.Culture); Debug.WriteLine(@" Age: " + info.Age); Debug.WriteLine(@" Gender: " + info.Gender); Debug.WriteLine(@" Description: " + infoDescription); Debug.WriteLine(@" ID: " + info.Id); Debug.WriteLine(@" Enabled: " + voice.Enabled); Debug.WriteLine(info.SupportedAudioFormats.Count != 0 ? $@" Audio formats: {audioFormats}" : @" No supported audio formats found"); Debug.WriteLine($@" Additional Info - {info.AdditionalInfo.Keys.Aggregate("", (current, key) => current + $" {key}: {info.AdditionalInfo[key]}\n")}"); } }
public void Play(string words) { if (string.IsNullOrEmpty(words)) { return; } if (Speaking) { Queue.Add(words); } else { Speaking = true; Queue.RemoveAll(words.Equals); speaker.SelectVoice(Voices.Contains(SelectedVoice) ? SelectedVoice : Voices.FirstOrDefault()); speaker.SpeakAsync(words); } }
public void GetVoices() { var installedVoices = _synth.GetInstalledVoices(); if (installedVoices.Count == 0) { throw new Exception(@"No se encontraron voces instaladas"); } if (Voices == null) { Voices = new List <string>(); } // Output information about all of the installed voices. Debug.WriteLine(@"Installed voices -"); foreach (var voice in installedVoices) { var info = voice.VoiceInfo; var infoDescription = info.Description; string auxVoice; if (infoDescription.StartsWith("Microsoft")) { auxVoice = infoDescription; } else { // For now it's only possible to use the Microsoft Voices. //auxVoice = info.Name; continue; } if (!Voices.Contains(auxVoice)) { Voices.Add(auxVoice); } //GetVoiceInfo(info, infoDescription, voice); } /* * void GetVoiceInfo(VoiceInfo info, string infoDescription, InstalledVoice voice) * { * var audioFormats = info.SupportedAudioFormats.Aggregate("", (current, fmt) => current + $"{fmt.EncodingFormat}\n"); * * Debug.WriteLine(@" Name: " + info.Name); * Debug.WriteLine(@" Culture: " + info.Culture); * Debug.WriteLine(@" Age: " + info.Age); * Debug.WriteLine(@" Gender: " + info.Gender); * Debug.WriteLine(@" Description: " + infoDescription); * Debug.WriteLine(@" ID: " + info.Id); * Debug.WriteLine(@" Enabled: " + voice.Enabled); * Debug.WriteLine(info.SupportedAudioFormats.Count != 0 * ? $@" Audio formats: {audioFormats}" * : @" No supported audio formats found"); * * Debug.WriteLine( * $@" Additional Info - {info.AdditionalInfo.Keys.Aggregate("", (current, key) => current + $" {key}: {info.AdditionalInfo[key]}\n")}"); * } */ }