Convert Text to Speech

In this blog, we'll learn to convert the text to voice. Follow the steps below:

Step 1: Create a Windows Application, and can named it as ConvertTextToVoice.

Step 2: To convert text to speech which is called voice synthesis, you must include "System.Speech" reference in your project. So click on “References”, then “Add References”. Click on Framework tab, and then add "System.Speech".

System Speech

Step 3: Add 1 textbox and a button to Form1.cs.

 Windows Form

Step 4: Double click on Speak button.

  1. private void Speak_Click(object sender, EventArgs e)  
  2. {  
  3.     SpeechSynthesizer speechSynthesizer = new SpeechSynthesizer();  
  4.     speechSynthesizer.Volume = 100;  // 0...100  
  5.     speechSynthesizer.Rate = 0;     // -10...10  
  6.   
  7.     // Synchronous - Speaks the specified text string.  
  8.     // speechSynthesizer.Speak(textBox1.Text);  
  9.   
  10.     // Asynchronous -   Speaks the specified text string asynchronously.  
  11.      speechSynthesizer.SpeakAsync(textBox1.Text);  

Add the following namespace:

  1. using System.Speech.Synthesis; 
Please find the attached code project for more details.
Ebook Download
View all
Learn
View all