Control Voice Attributes

Control Voice Attributes

A computer may have multiple synthesizer voices installed that represent various combinations of language, age, and gender. You can select the voice to use with methods on the SpeechSynthesizer object. In addition, you can embed commands in prompts using methods on the PromptBuilder object that change the voice that the synthesizer uses while it is processing prompts.

Note Note

A voice is an installed speech synthesis engine, which is also referred to as a text-to-speech engine or a TTS engine.

When you create a new SpeechSynthesizer object, it uses the default system voice. To select one of the other installed voices, use the SelectVoice(String) or SelectVoiceByHints() methods. Using the SelectVoiceByHints() methods, you can specify characteristics of the voice you want to select, such as language-culture, gender, and age.

Use the GetInstalledVoices() method to find out which voices are available for the synthesizer to use. The VoiceInfo class provides detailed information about an installed voice.

With the StartVoice() overloaded methods on the PromptBuilder class, you can change the voice used in speech synthesis, change the culture of the voice, or change the gender or age of the voice.

To change the voice in use by the synthesizer, call the StartVoice(String) method, providing the name of the voice in the call. For English (U.S.), the name of the default synthesis voice is "Microsoft Anna." When the voice is no longer needed, call the EndVoice() method. After EndVoice() returns, the voice is reset to the voice in use before the call to StartVoice(String).

An application that has registered a handler for the VoiceChange event can determine the details of the voice change by inspecting the handler’s VoiceChangeEventArgs argument. For more information, see Use Speech Synthesis Events.

To change the culture of the synthesizer voice, call the StartVoice(CultureInfo) method, passing an initialized CultureInfo instance that represents the desired culture. To generate speech using the language specified in the CultureInfo argument, a speech synthesis engine that supports that language-country code must be installed.

There are three methods that can be used to change the synthesizer’s gender, age, or both.

To change the voice’s gender, call the StartVoice(VoiceGender) method, passing a value from the VoiceGender enumeration in the call.

To change the voice’s gender and age, call the StartVoice(VoiceGender, VoiceAge) method, passing values from the VoiceGender and VoiceAge enumerations in the first and second parameters. To change only the age, pass the current gender value and the new age value.

To change the voice’s gender and age and to specify a preferred voice when more than one voice matches the gender and age parameters, call the StartVoice(VoiceGender, VoiceAge, Int32) method. Pass in the gender and age and an integer that specifies the preferred voice among those that match the gender and age parameters. This parameter represents the variant attribute that is defined in the Speech Synthesis Markup Language 1.0 specification for the voice element.

Show:
© 2016 Microsoft