In this article I would like to discuss how to convert text to speech
using WPF Application.
Open Visual Studio 2008 ,
From file menu select New Project ,
From the templates select WPFApplication .
By default it creates Window1.xaml
, App.xaml , References and Properties folders.
Right click on the references
folder and select “Add Reference” .
and from .net tab select
System.Speech and click on ok.
This will add system.speech
namespace to the project.
Open window1.xaml , from toolbar
drag and drop a textbox and button controls.
Double click on the button ..it will open button event handler in code
behind file(window1.xaml.cs)
Speak function is in the class SpeechSynthesizer , so to use that class add the following in your cs file.
"using System.Speech.Synthesis;"
In the function create obj for that class ,
invoke speak function as follows.
private void button1_Click(object
sender, RoutedEventArgs e)
{
SpeechSynthesizer
obj = new SpeechSynthesizer();
obj.Speak(Speak.Text);
}
The output window looks like
this. Type some text in the textbox and click on Speak button .
No comments:
Post a Comment