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".
Step 3: Add 1 textbox and a button to Form1.cs.
Step 4: Double click on Speak button.
- private void Speak_Click(object sender, EventArgs e)
- {
- SpeechSynthesizer speechSynthesizer = new SpeechSynthesizer();
- speechSynthesizer.Volume = 100;
- speechSynthesizer.Rate = 0;
-
-
-
-
-
- speechSynthesizer.SpeakAsync(textBox1.Text);
- }
Add the following namespace:
- using System.Speech.Synthesis;
Please find the attached code project for more details.