Configuring Voices
The SpeechSynthesizer class also offers methods to perform the following operations:
- Retrieve the installed voices with GetInstalledVoices.
- Specify the voice to use by its name with SelectVoice.
- Specify the voice to use by hints with SelectVoicyByHints.
The GetInstalledVoices method returns a read-only collection of InstalledVoice instances. You can access the VoiceInfo.Name property for each element and use it as a parameter to the SelectVoice method. It is possible to fill a list box or a combo box with these values and let the user select the desired voice in your speak-aware application. The following two lines retrieve the installed voices according to the current UI culture and then select the first voice. In a default Windows 7 English (United States) installation, the value for the VoiceInfo.Name property is going to be "Microsoft Anna".
var installedVoices = synthesizer.GetInstalledVoices(System.Globalization.CultureInfo.CurrentUICulture); synthesizer.SelectVoice(installedVoices[0].VoiceInfo.Name);
Besides, the SpeechSynthesizer class fires events to allow you to write code at specific times. For example, you can program event handlers for SpeakStarted, SpeakProgress, and SpeakCompleted. There are many other advanced options that let you control the way the TTS engine works.


