Text To Speech Converter In C#

Motivation comes to me when I am doing my project on Text to speech converter and it takes a lot of time to know about its syntax and libraries. So I decide to write on it so you can do conversion of text to speech with little effort by follow this pattern.
 
So don't worry if you doesn't know about:
  1. libraries to add.
  2. system reference to include in project.
  3. syntax of speech recognition and speech synthesis.
Starting from the very initial point
 
You must include this reference by right clicking on project name select reference
 
Microsoft.system.speech;
 
Libraries to use in c#
  1. using System.Speech.Synthesis;   
  2. using System.Speech.Recognition;  
Syntax of Speech To Text
  1. Public void SpeakText()  
  2. {  
  3.     PromptBuilder Pbuilder = new PromptBuilder();  
  4.     SpeechSynthesizer synth = new SpeechSynthesizer();  
  5.     Pbuilder.ClearContent();  
  6.     Pbuilder.AppendText(“Text You want to speek”);  
  7.     synth.Speak(Pbuilder);  
  8. }  
Code for Desktop app
 
The form contains one textbox named textBox and a button named button1.
 
Any thing you write in text box will be spoken by your computer when button1 is pressed.
  1. using System.Data;  
  2. using System.Drawing;  
  3. using System.Linq;  
  4. using System.Text;  
  5. using System.Threading.Tasks;  
  6. using System.Windows.Forms;  
  7. using System.Speech.Synthesis;  
  8. using System.Speech.Recognition;  
  9. using System.Threading;  
  10.   
  11. namespace Project_Name  
  12. {  
  13.     public partial class Form1 : Form {  
  14.     public Form1() {  
  15.         InitializeComponent();  
  16.     }  
  17.     SpeechSynthesizer synth = new SpeechSynthesizer();  
  18.     PromptBuilder Pbuilder = new PromptBuilder();  
  19.   
  20.     private void Form1_Load(object sender, EventArgs e) { }  
  21.     private void button1_Click(object sender, EventArgs e) {  
  22.         Pbuilder.ClearContent();  
  23.         Pbuilder.AppendText(textBox1.Text);  
  24.          synth.Speak(Pbuilder);  
  25.     }  
  26.     }  
  27. }  
Now that's all you need.
So, are you ready to give a try to build your own speaking app?
Comments and suggestions are valuable.
Ebook Download
View all
Learn
View all