SIGN UP MEMBER LOGIN:    
ARTICLE

Text to speech using C#

Posted by Syed Shakeer Articles | C# Language January 19, 2011
This Article explains how to convert text to speech using C#.
Reader Level:


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.

Speed1.gif

  1. Add the NameSpace as Using SpeechLib.
  2. Create an object of SpVoice class

    SpVoice voice = new SpVoice();
     
  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);

Let's Look the code:

            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:

Speed2.gif

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using SpeechLib;

namespace VoiceTest
{

public partial class Form1 : Form
{

public Form1()
{

InitializeComponent();

}

private void btnSpeak_Click(object sender,EventArgse)
{

if (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
 

Login to add your contents and source code to this article
share this article :
post comment
 

thanx alot . plz can anybody tell me how i can do the opposite speech to text ?

Posted by duaa qaisi Sep 18, 2011

great steps thnxxxxxxxxxxx

Posted by Rahat pattalbab Mar 27, 2011

Hi Slavcho, You can check the article for what your are looking.I hope it will helps you http://www.c-sharpcorner.com/UploadFile/syedshakeer/5813/

Posted by Syed Shakeer Feb 28, 2011

Thank You so much for the link

Posted by Frank Slow Feb 27, 2011

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?

Posted by Slavcho Chungurski Feb 27, 2011
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Become a Sponsor