Skip to content

Latest commit

 

History

History
51 lines (34 loc) · 1.49 KB

voicegender.md

File metadata and controls

51 lines (34 loc) · 1.49 KB
-api-id -api-type
T:Windows.Media.SpeechSynthesis.VoiceGender
winrt enum

VoiceGender

-description

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

-enum-fields

-field Male:0

Male

-field Female:1

Female

-remarks

-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);
}

-see-also

Windows.Media.SpeechSynthesis, Speech interactions, Speech recognition and speech synthesis sample