below is the code am usng in a text to voice application. i need help so that the application uses the windows 10 default
talkback voice.
using System.Speech;
using System.Speech.Synthesis;
private void Speak()
{
speechSynthesizerObj = new SpeechSynthesizer();
speechSynthesizerObj.Volume = 100;
speechSynthesizerObj.SpeakAsync(richTextBox1.Text);
}
any help will be greatly appreciated


Jefferson S. MottaRank #207 · 11.7K reputationPosted Jan 10, 2023, 4:06 PM EST
Hi!
Get SelectedVoiscesInstalled first:
using System; using System.Speech.Synthesis; using System.Speech.AudioFormat; namespace SampleSynthesis { class Program { static void Main(string[] args) { // Initialize a new instance of the SpeechSynthesizer. using (SpeechSynthesizer synth = new SpeechSynthesizer()) { // Output information about all of the installed voices. Console.WriteLine("Installed voices -"); foreach (InstalledVoice voice in synth.GetInstalledVoices()) { VoiceInfo info = voice.VoiceInfo; string AudioFormats = ""; foreach (SpeechAudioFormatInfo fmt in info.SupportedAudioFormats) { AudioFormats += String.Format("{0}\n", fmt.EncodingFormat.ToString()); } Console.WriteLine(" Name: " + info.Name); Console.WriteLine(" Culture: " + info.Culture); Console.WriteLine(" Age: " + info.Age); Console.WriteLine(" Gender: " + info.Gender); Console.WriteLine(" Description: " + info.Description); Console.WriteLine(" ID: " + info.Id); Console.WriteLine(" Enabled: " + voice.Enabled); if (info.SupportedAudioFormats.Count != 0) { Console.WriteLine( " Audio formats: " + AudioFormats); } else { Console.WriteLine(" No supported audio formats found"); } string AdditionalInfo = ""; foreach (string key in info.AdditionalInfo.Keys) { AdditionalInfo += String.Format(" {0}: {1}\n", key, info.AdditionalInfo[key]); } Console.WriteLine(" Additional Info - " + AdditionalInfo); Console.WriteLine(); } } Console.WriteLine("Press any key to exit..."); Console.ReadKey(); } } }from: SpeechSynthesizer.GetInstalledVoices Method (System.Speech.Synthesis) | Microsoft Learn
Amit MohantyRank #112 · 20K reputationPosted Jan 10, 2023, 11:36 PM EST
Hi,
SpeechSynthesizer speechSynthesizer = new SpeechSynthesizer(); // Use the default voice. speechSynthesizer.SelectVoiceByHints(VoiceGender.Female); //You can also use other VoiceGender like Male, //Neutral or set the voice using specific name speechSynthesizer.SelectVoice("Microsoft David Desktop"); // Set the volume speechSynthesizer.Volume = 100; // Speak a string. speechSynthesizer.SpeakAsync("Hello World");