Text to speech (TTS) is the conversion of written text into spoken voice.You can create TTS programs in C#. The quality of the spoken voice depends on your speech engine.

In this article you’ll learn how to create your own TTS program.

Text to speech in C#

Example with espeak

The program ‘espeak’ is a simple speech synthesizer which converst written text into spoken voice. The espeak program does sound a bit robotic, but its simple enough to build a basic program.

1
2
3
4
5
6
7
8
9
10
System.Diagnostics.Process pProcess = new System.Diagnostics.Process();
pProcess.StartInfo.FileName = @"C:\....speak.exe";
pProcess.StartInfo.Arguments = "'hello world'"; //argument
pProcess.StartInfo.UseShellExecute = false;
pProcess.StartInfo.RedirectStandardOutput = true;
pProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
pProcess.StartInfo.CreateNoWindow = true; //not diplay a windows
pProcess.Start();
string output = pProcess.StandardOutput.ReadToEnd(); //The output result
pProcess.WaitForExit();

This will output spoken voice / an mp3 file.