How To: Teach Your Apps To Speak With System.Speech.SpeechSynthesizer Part 2

.NET ,Fun Stuff ,Tutorial
September 23, 2008

In part 1 of this series i showed you how to specify the voice, gender, rate and volume of the our SpeechSynthesizer object. This time i’m going to show you how to use predefined Voices in your machine and utilize it as hints to your SpeechSynthesizer object.

The first thing that I did to our sample project is change the UI since we would not need the Gender and Age combo box in our form. The result is a UI like this:

Next, we need to figure out a way to extract the names of the installed voices in our machine. To this we need to use the SpeechSynthesizer.GetInstalledVoices() method. This method, when invoked returns a readonly collection of TTS(text-to-speech) voices also known as InstalledVoice objects that are readily available in your machine. The InstalledVoice object contains a property called VoiceInfo which represents the voice information about that TTS voice. To begin our project we need to get all the VoiceInfo objects on each and every InstalledVoice. Below is a code snippet showing how we can accomplish this task:

Next, we need to bind the resulting list to our voiceComboBox.

And finally we need to create the logic inside our button click event to initiate our SpeechSynthesizer

And we are done 😉 Running the application would show as all the installed TTS voice in our machine. One thing to note is that this list is machine dependent and different machines might contain different voices.

Clicking the “Speak!” button should echo our selected voice.

Next time I’ll show you how to export the resulting speech to a wave file. HTH

Leave a Reply

Your email address will not be published. Required fields are marked *