Code Simplified – Viral Sarvaiya

Code Simplified – Viral Sarvaiya, Web Developer Friends, dot net Developer, Sql Server Developer

Text to speech in with C#

Posted by Viral Sarvaiya on June 16, 2010

here i demonstrate the text to Speech conversion…

step 1 : create new web site.

step 2 :  in the default.aspx page, copy the following code…

<html xmlns="">
<head runat="server">
 <title>Text to speach</title>
 <form id="form1" runat="server">
 <asp:TextBox ID="txtspeach" runat="server"></asp:TextBox>
 <br />
 <asp:Button ID="btn1" runat="server" Text="Speach" onclick="btn1_Click" />

Step 3: Right click on the solution explore of the visual studio and add reference

in the add reference dialog box select the COM tag and add “Microsoft Speech Object library” and click to ok.

Step 4 : In the Default.aspx.cs file, copy the following code……

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SpeechLib;
using System.Threading;

public partial class _Default : System.Web.UI.Page
 protected void btn1_Click(object sender, EventArgs e)
 SpVoice objspeach = new SpVoice();
 objspeach.Speak(txtspeach.Text.Trim(), SpeechVoiceSpeakFlags.SVSFDefault);

Step 5 : Run the code…

enter the text which u want to speech and then click to button, and listen the text…..


for more details : click here


16 Responses to “Text to speech in with C#”

  1. viralsarvaiya said

    Dear Shibin,

    I test my application after you comment, its works fine,
    can you please tell me, where you found difficultly?

  2. Gaurav said

    Thanx a lot, Sir. You really helped a lot.

  3. mani said


    I did exactly the procedure u gave above….

    but the application is not executing … is prompting errors(i did project in VS2010)

    giving errors related to web stack trace…

  4. pankaj tiwari said

    Hi Sir,
    Thax for your post. but how we change the voice, means how can we listen our text in indian accent

  5. huda said

    hi sir,

    when I did step3: Right click on the solution explore of the visual studio and add reference

    in the add reference dialog box select the COM tag and add “Microsoft Speech Object library” and click to ok.

    a pop up window comes says: converting the type library to a.NET has failed. no process associated to with this object

    how to solve this problem?

  6. Hamsa Ankamreddy said

    Have u deployed this application? Is it working good after deployment

  7. palak said

    hello sir,
    i find this blog from google
    i also find intresting code from

    it may be Usefull for another user so i share this link here

  8. Kanna said

    Hi When I deploy in the server, cannot hear from the client PC. But can hear the voice from the server pc

  9. sir.. i tried a lot but I cant. can you help me to add buttons such as play, pause/resume, stop, download in text to speech using and c#

  10. sateesh said

    but how to get text to speech female voice?

  11. jagadish said

    thank you very much

  12. stanlyjose said

    This works..! thanks a lot

  13. Sheraton Hotel Pattaya Beach

    Text to speech in with C# « Code Simplified – Viral Sarvaiya

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: