Make Your Application Sounded using Speech namespace in WPF

You might be known the WinFX (WPF, WCF, WF, InfoCard) have been RTM recently just like what Microsoft said in the term of WPF (to build great software with great UX). Said user experience is not just about eye catching (just like what AERO did), User Experience need a many approach to make human computer interaction much better. In WPF Microsoft have provided us managed API to handle rich multimedia (whoa managed api?).

Back in the last year, to enable good experience for the user I'm use Microsoft Agents SDK, You might be sometimes use it when typing in 2000-2003 Office, or XP search assistant. A character like Rocky, Clip, Marlin, and Robot give us more way to communicate to our user more friendly using animated character. However to use that, we need to download the sdk and add a reference using COM interop J. (btw I use the Microsoft Agent for a software that build to kindergarten student, or elementary student since this Microsoft Agents is funny for them, in a real LOB application I'm afraid client will blame us to see Rocky or Marlin in their software he8x)

For LOB application or similar software rather than use Microsoft Agent SDK we can use speech namespace in WPF (hurray). Below is a sample code to enable your XAML application speech

// for speech synt don't forget to add System.speech using add reference

using System.Speech.Synthesis;

// in example i want to read a richtexbox called rtbEmail (wpf control richtextbox not the net 2.0 control) so i can do this

SpeechSynthesizer _speechSynthesizer = new SpeechSynthesizer();

TextRange textRange = new TextRange(rtbEmail.Document.ContentStart,rtbEmail.Document.ContentEnd);

_speechSynthesizer.SpeakAsync(textRange.Text);

// yeah that's all you have to do to make yopu application speech

 

Regards Guys

 

Ridi Ferdiana

http://ridilabs.net

Share this post: | | | |

Comments

No Comments