Frank La Vigne

Fear and Loathing in .NET

Subscription Options

Blog
Add to Google

Subscribe in Bloglines
Subscribe in NewsGator Online
Add Frank La Vigne to Newsburst from CNET News.com

Subscribe in Rojo
Podcast
Subscribe in podnova
Add Frank La Vigne to ODEO

My Links

News






Post Categories

Archives

Image Galleries

Blog Stats

Blog Roll

Favorite Sites

Gadget Blogs

Tablet PC Links

Making Your WPF Applications Speak

It's amazingly easy to add speech synthesis to WPF applications.

WPF's speech synthesis capabilities are often lost in the rich feature set of the platform.

Last year, I wrote a blog post about Speech Synthesis in WPF.

I thought it would be cool to write an Extension Method that encapsulates speech synthesis functionality, so that speaking would be as simple as

   1: string sayThis;
   2: sayThis.Speak();

 

The code to make this possible is this simple.

   1: public static void Speak (this string text)
   2: {
   3:     SpeechSynthesizer synthesizer = new SpeechSynthesizer();
   4:  
   5:     synthesizer.SpeakAsync(text);
   6: }

 

Be sure to add a reference to System.Speech and add the appropriate using statement.

   1: using System.Speech.Synthesis;

 

Now if only Speech Synthesis existed in Silverlight. ;)

 

posted on Thursday, May 08, 2008 12:16 PM