Code Simplified – Viral Sarvaiya

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

Text to speech in asp.net 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="http://www.w3.org/1999/xhtml">
<head runat="server">
 <title>Text to speach</title>
</head>
<body>
 <form id="form1" runat="server">
 <div>
 <asp:TextBox ID="txtspeach" runat="server"></asp:TextBox>
 <br />
 <asp:Button ID="btn1" runat="server" Text="Speach" onclick="btn1_Click" />
 </div>
 </form>
</body>
</html>

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);
 objspeach.WaitUntilDone(Timeout.Infinite);
 }
}

Step 5 : Run the code…

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

thanks…..

for more details : click here

Advertisements

15 Responses to “Text to speech in asp.net 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

    Hi,

    I did exactly the procedure u gave above….

    but the application is not executing …..it 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

    Hiiiiii,
    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

    http://codeprojectdownload.com/asp-net-2/convert-text-into-speech-in-asp-net/#.T0ScXIfXDZE

    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 asp.net 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

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

 
%d bloggers like this: