Here I’m about to explain Text to Speech feature of C#. This simple example will demonstrate how to use Text to Speech feature of C#.
Example
Form Design
Code
Namespace for voice
using SpeechLib;
namespace TextTospeech
{
publicpartialclassForm1 : Form
{
public Form1()
{
InitializeComponent();
}
privatevoid btnSpeak_Click(object sender, EventArgs e)
{
//creating instance of voice
SpVoice v = newSpVoice();
//Setting Rate of voice
v.Rate = 2;
//calling speak() method of SpVoice class.
v.Speak(rtxtSpeech.Text, SpeechVoiceSpeakFlags.SVSFPurgeBeforeSpeak);
}
}
}
Leave Comment