Text to speech allows you to enter text, then use System.Speech.dll to speech your text. This library contains classes for initializing and configuring a speech synthesis engine for generating speech.

You can design a simple UI as below to play demo

text to speech in c#

Paste the following code to handle button click event

private void btnSpeech_Click(object sender, EventArgs e)
{
    SpeechSynthesizer speechSynthesizer = new SpeechSynthesizer();
    speechSynthesizer.Speak(txtText.Text);
    speechSynthesizer.Dispose();
}

You shoud add a reference to System.Speech.dll, then add the following reference on top

using System.Speech.Synthesis;