Thursday, 22 May 2014

Text to Speech in C#

Hello Programmers,

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
    Richtextbox   rtbTexttoRead

4. Now double click on the Read button and copy the below code;

            SpeechSynthesizer synth = new SpeechSynthesizer();

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;


using System;
using System.Speech.Synthesis;
using System.Windows.Forms;

namespace TexttoSpeech
    public partial class Form1 : Form
        public Form1()

        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.

See Also

No comments:

Post a Comment


About Me

I am Tijo Tom, a Computer Engineer from India.Right from my schooling, I had a passion for Programming, PC Tricks, Virus Creation and Hacking.

I started this blog on Jan 1, 2014 to share my views and ideas with the world.

You can know more about me on