Introduction
This Article explains how to convert text to speech using c#.
Before starting to write code for converting a text into speech you have to add a reference (DownLoad if not available) for Interop.SpeechLib.

Step 1. Add the NameSpace as Using SpeechLib.
Step 2. Create an object of SpVoice class.
SpVoice voice = new SpVoice();Step 3. Call the Speak() method by using Spvoice class object as follows and pass the parameters in the Speak().
voice.Speak(String text,SpeechVoiceSpeakFlags Flags);Example
SpVoice voice = new SpVoice();
voice.Volume = 100;
voice.Speak(textBox1.Text, SpeechVoiceSpeakFlags.SVSFlagsAsync);Place the above code in the Button Click event.
Add one TextBox, write some text in TextBox and click on the button to convert the TextBox text into speech as follows.

using System;
using System.Windows.Forms;
using SpeechLib; // Add this using directive for SpeechLib namespace
namespace VoiceTest {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void btnSpeak_Click(object sender, EventArgs e) { // Corrected EventArgs
if (!string.IsNullOrEmpty(textBox1.Text)) {
SpVoice voice = new SpVoice();
voice.Volume = 100;
voice.Speak(textBox1.Text, SpeechVoiceSpeakFlags.SVSFlagsAsync);
}
else {
MessageBox.Show("Please enter text for speech", "Text to Speech", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}Thanks for Reading my article!
Syed Shakeer Hussain


万春 吴Posted Nov 5, 2014, 3:04 PM EST
amazing
mohamed sayedPosted Nov 5, 2014, 5:33 AM EST
good work, thank you
prithvi rajPosted Oct 8, 2014, 4:56 AM EDT
but when use same code in my windows service application it give error System.Runtime.InteropServices.COMException (0x8004503A): Exception from HRESULT: 0x8004503A at SpeechLib.ISpeechVoice.Speak how to use speech library in wndows service?
ankit makadiaPosted Aug 23, 2014, 7:17 AM EDT
thanx...very good work
duaa qaisiPosted Sep 18, 2011, 4:39 AM EDT
thanx alot . plz can anybody tell me how i can do the opposite speech to text ?
Rahat pattalbabPosted Mar 27, 2011, 11:12 AM EDT
great steps thnxxxxxxxxxxx
Frank SlowPosted Feb 27, 2011, 4:03 AM EST
Thank You so much for the link
Slavcho ChungurskiPosted Feb 27, 2011, 1:05 AM EST
Mr Syed, I have found an article in Microsoft SpeechSDK documentation under a Topic "TTS Engine Vendor Porting Guide". This is the topic I was looking for. Do you have some c# experience with this. Do You have some tips & tricks?
Slavcho ChungurskiPosted Feb 24, 2011, 12:00 PM EST
Mr. Syed, is there any answer for me? Thanks...
Slavcho ChungurskieditedPosted Feb 22, 2011, 11:58 AM ESTEdited Feb 22, 2011, 11:59 AM EST
Mr. Shakeer, I have developed a new TTS engine (for Macedonian language) in C#. It's main method SpeakMacedonian(string InputText) gets Unicode text as input, and returns a WAV file (or a stream). I'm trying to make it SAPI compatible and use it as default Windows voice, but I can not find some fine article for this issue. Do you have any idea how to resolve this? Thanks in advance...
Frank SlowPosted Jan 29, 2011, 9:40 AM EST
Could you tell me where can i download the Interop.SpeechLib file?
sagar BhosalePosted Jan 27, 2011, 7:58 AM EST
Very nice tutorials .Thanks sir.
Irfan KumtePosted Jan 19, 2011, 9:10 PM EST
great!!!