Here you are gonna learn how to convert Text to Speech in C# i.e you are going to create a software that Talks!
So lets start;
1. Open Visual Studio -> New Project -> Windows Form Application with name
2. Now add button, richtextbox and labels to the empty form and design it as shown in
the below screenshot.
3. Now change the name and text of the added controls from the Properties dialog box;
Control Control Name Text
Button btnRead Read
4. Now double click on the Read button and copy the below code;
SpeechSynthesizer synth = new SpeechSynthesizer();synth.SetOutputToDefaultAudioDevice();
5. Now you will have to add a reference to System.Speech.Synthesis to
use SpeechSynthesizer in your project. To do so, Right click on your Project from
Solution Explorer and select Add Reference ( See the Screenshot)
Now check the System.Speech as shown in the below screenshot
6. Now Right click on SpeechSynthesizer() and Resolve -> Using System.Speech.Synthesis;
(See the Screenshot)
7. The complete code is shown below;
public partial class Form1 : Form
private void btnReadText_Click(object sender, EventArgs e)
SpeechSynthesizer synth = new SpeechSynthesizer();
8. Rebuild and Run the project, type some text in the richtextbox and click on Read to
read the text ENJOY :-)
In case of any doubts / errors, please drop in a comment.