SpeechSynthesizer.AllVoices Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a collection of all installed speech synthesis engines (voices).
public:
static property IVectorView<VoiceInformation ^> ^ AllVoices { IVectorView<VoiceInformation ^> ^ get(); };
static IVectorView<VoiceInformation> AllVoices();
public static IReadOnlyList<VoiceInformation> AllVoices { get; }
var iVectorView = SpeechSynthesizer.allVoices;
Public Shared ReadOnly Property AllVoices As IReadOnlyList(Of VoiceInformation)
A collection of VoiceInformation objects.
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);
}
Only Microsoft-signed voices installed on the system can be used to generate speech with a SpeechSynthesizer. Each voice generates synthesized speech in a single language, as spoken in a specific country/region.
By default, a new SpeechSynthesizer object uses the current system voice (call DefaultVoice to find out what the default voice is).
To specify any of the other speech synthesis (text-to-speech) voices installed on the user's system, use the Voice method (to find out which voices are installed on the system, call AllVoices).
If you don't specify a language, the voice that most closely corresponds to the language selected in the Language control panel is loaded.
Product | Versions |
---|---|
WinRT | Build 10240, Build 10586, Build 14383, Build 15063, Build 16299, Build 17134, Build 17763, Build 18362, Build 19041, Build 20348, Build 22000, Build 22621, Build 26100 |