Convert Text to Speech in C#

This tutorial provides an introduction of developing speech applications for the Windows Desktop applications using System.Speech reference. So the following example converts a text written in a TextBox to a speech.
First, add the reference System.Speech to the project:

 

Don't forget to add these directives:

using System.Speech.Synthesis;   
using System.Speech.Recognition;

This is the code converting text to speech:

private void SpeakButton_Click(object sender, EventArgs e)
{
    SpeechSynthesizer speechSynth = new SpeechSynthesizer();
    PromptBuilder builder = new PromptBuilder();

    builder.ClearContent();
    builder.AppendText(textBox1.Text);
    speechSynth.Speak(builder);
}

for more explanation check this video:


Convert Text to Speech in C# Convert Text to Speech in C# Reviewed by Bloggeur DZ on 01:47 Rating: 5

1 commentaire:

Fourni par Blogger.