Logo
Color-Of-Code
  Home   All tags   Terms and Conditions

Text to Speech

December 25, 2018

C# Text to Speech

Assembly (reference)

System.Speech

Using directive

using System.Speech.Synthesis;

Code: say "hello world"

SpeechSynthesizer speaker = new SpeechSynthesizer();
speaker.Rate = 1;
speaker.Volume = 100;
speaker.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult);
speaker.SpeakAsync("Hello World");

Code: list available voices

SpeechSynthesizer speaker = new SpeechSynthesizer();
speaker.GetInstalledVoices()