How to Convert Text into Speech


Create a new Windows application, design the form as follows:

Speech.gif

When entering text into the textbox and the speak button is clicked then this program will read out the text in the textbox.

Solution:

After designing the form, the button click event must be raised. Use the following code for it.

Speak:

string text = textBox1.Text;
SpeechController.Instance.Speech(text);

Create a new class with the name SpeechController and add the following namespaces:

using System.Speech.Synthesis;
using System.Speech.AudioFormat;

And use the following code for it:

public static SpeechController Instance
{
    get {return msInstace; }
}

private static SpeechController msInstace=new SpeechController();
private SpeechSynthesizer mySys = new SpeechSynthesizer();

public void Speech(string text)
{
    mySys.SpeakAsync(text);
}

 

Up Next
    Ebook Download
    View all
    Learn
    View all