This sample code will get the installed voices using C# SpeechSynthesizer and will load in to a combo box.
using (SpeechSynthesizer synth = new SpeechSynthesizer())
{
foreach (InstalledVoice voice in synth.GetInstalledVoices())
{
VoiceInfo info = voice.VoiceInfo;
cmbVoices.Items.Add(info.Description + ", " + info.Gender + ", " + info.Age);
installedVoices.Add(info);
}
if (cmbVoices.Items.Count > 0)
{
cmbVoices.SelectedIndex = 0;
}
}
using (SpeechSynthesizer synth = new SpeechSynthesizer())
{
foreach (InstalledVoice voice in synth.GetInstalledVoices())
{
VoiceInfo info = voice.VoiceInfo;
cmbVoices.Items.Add(info.Description + ", " + info.Gender + ", " + info.Age);
installedVoices.Add(info);
}
if (cmbVoices.Items.Count > 0)
{
cmbVoices.SelectedIndex = 0;
}
}
No comments:
Post a Comment