Recently I was working on an application where I need to develop Text to Speech in a Windows Application. This application is for physically blind people where when they run the application, it need to read the text file, and convert it into voice, and should be able to listen to the voice if speakers / headphones are connected.
Thanks to WPF, it has been so simple one line of code using Speech Synthesis in WPF.All the coding is achieved by importing System.Speech.Synthesis;
If you are using VS2005, you need to install WPF(Visual Studio Extensions for .NET Framework 3.0) as sperate template
When ever we install VS2008 all these libraries comes along with installation of .NetFramework 3.5.The conculsion here is the framework versions that support the speech synthesis is 3.0 and above (ie 3.0,3.5 and 4.0)
First thing is to import the name space using System.Speech.Synthesis;
This name space is comes long with the dll System.Speech
If you don’t add that reference you get error as the type or namespace name System.Speech does not exist in the namespace system.
To include the dll go to add references and include System.Speech
public partial class SpeechObj : Window
{
SpeechSynthesizer speechObject = new SpeechSynthesizer();
public SpeechObj()
{
InitializeComponent();
}
private void btnDisplayAudio_Click(object sender, RoutedEventArgs e)
{
speechObject.SpeakAsync(TxtAreaResult.Text);
}
}
No comments:
Post a Comment