-api-id | -api-type |
---|---|
T:Windows.Media.SpeechSynthesis.VoiceGender |
winrt enum |
Specifies the gender preferences available for speech synthesis (if supported by the specified speech synthesis engine).
Male
Female
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);
}
Windows.Media.SpeechSynthesis, Speech interactions, Speech recognition and speech synthesis sample