SIGN UP MEMBER LOGIN:    
ARTICLE

Text-to-Speech Conversion in C#

Posted by Suhil Srinivas Articles | Speech in C# May 11, 2004
This article provides some elementary information about how to perform text to speech conversion using the speech SDK 5.1.
Reader Level:

Description

This article provides some elementary information about how to perform text to speech conversion using the speech SDK 5.1. Speech SDK 5.1 is the latest release in the speech product line from Microsoft. Speech SDK 5.1 can be used in various programming languages.

Introduction

Speech is one of the most natural way to interact. When it comes to computers it is no different. If an application can be controlled solely by way of voice commands then the opportunity that lies is unlimited. Even though the idea of using speech as an input mechanism for an application is not new there are not a lot of applications that use speech as in input. In other words speech is still an big opportunity that is yet to be explored.

Microsoft speech SDK is one of the many tools that enable a developer to add speech capability in to a applications. Speech SDK can be used in either C#, C++, VB  or any COM compliant language.

Broadly, speech can be divided in to two paradigms. Text to speech conversion and speech recognition. In this article I shall be focusing on the Text to speech  conversion.

Converting text to speech using speech SDK consists of a few simple steps. The following code shows the important pieces in performing text to speech. The below code is an implementation of the button click event.

private void button1_Click(object sender, System.EventArgs e)
{
SpVoice objSpeech =
new SpVoice();
objSpeech.Speak(textBox1.Text,SpeechVoiceSpeakFlags.SVSFlagsAsync);
objSpeech.WaitUntilDone(Timeout.Infinite);
}

SpVoice is the class that is used for text to speech conversion. The speak method takes in a string that needs to be spoken along with a set of flags. The flag that I have used, which is SVSFlagsAsync tells the TTS engine that the conversion of the text to speech needs to be done in a Asynchronous mode. The control quickly returns after this call.

Microsoft speech SDK comes with a few default text-to-speech engines. A developer can select a text to speech engine using the Text-To-Speech property pane in the speech item in the control panel. Below is a screen shot of the speech property pane.



As shown in the above screen shot, there are various voice profiles to choose from. The voices are either masculine or feminine. The preview voice button will allow you to preview the voice.

The SpVoice class has a property called AudioOutputStream which could be used to store the voice file if required.

Summary

This article gives an introduction to text to speech conversion using the Speech SDK 5.1.

Login to add your contents and source code to this article
Article Extensions
Contents added by muddsair sharif on Jul 20, 2010
great source code
share this article :
post comment
 

hey can you get the code for text to speech in c#

Posted by purvil rupera Mar 07, 2011

There's a better way to do it in .NET 3: http://www.studentguru.gr/blogs/jupiter/archive/2009/09/17/text-to-speech-using-c.aspx

Posted by Matthew Lieder Jan 19, 2011

hi srinivas
is ter any possibility to change the voice through code

Posted by shankar Oct 30, 2010

Hi dear Suhil,

I am a senior IT student in Iraq, and for my final project i have chosen to build an application to convert speech to text. can you please guide me how to start oe any other help.

thanks in advance,
Karzan

Posted by Karzan Abdullah Oct 04, 2010

abe ulke pathe project to de de..

Posted by sourabh aggarwal Sep 02, 2010
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Nevron Gauge for SharePoint
Become a Sponsor