Share via


VoiceGender Enum

Definition

Specifies the gender preferences available for speech synthesis (if supported by the specified speech synthesis engine).

public enum class VoiceGender
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
enum class VoiceGender
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
public enum VoiceGender
var value = Windows.Media.SpeechSynthesis.VoiceGender.male
Public Enum VoiceGender
Inheritance
VoiceGender
Attributes

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Fields

Name Value Description
Male 0

Male

Female 1

Female

Examples

Here, we show how to select a gender for the voice (VoiceInformation.Gender) by using either the first female voice (VoiceGender) found, or just the default system voice (SpeechSynthesizer.DefaultVoice), if no female voice is found.

using (SpeechSynthesizer synthesizer = new SpeechSynthesizer())
{
    VoiceInformation voiceInfo =
        (
            from voice in SpeechSynthesizer.AllVoices
            where voice.Gender == VoiceGender.Female
            select voice
        ).FirstOrDefault() ?? SpeechSynthesizer.DefaultVoice;

    synthesizer.Voice = voiceInfo;

    // Windows.Media.SpeechSynthesis.SpeechSynthesisStream
    stream = await synthesizer.SynthesizeTextToStreamAsync(text);
}

Applies to

See also