I want to make a text to speech program for my interactive training set. I used the System.Speech
library, but the voice is always female. I would like some sentences to be read with a male voice, and some to be read by a female voice. (These two voices are the only ones I need.)
I'm using Windows 8 Pro and Visual Studio 2010. I can see only one voice pack, the Microsoft Zira Desktop.
My code is as follows. How can I configure the use of a male voice?
SpeechSynthesizer synth = new SpeechSynthesizer();
synth.Rate = 1;
synth.Volume = 100;
synth.SelectVoiceByHints(VoiceGender.Male,VoiceAge.Adult);
synth.SpeakAsync(label18.Text);
Select Text-to-Speech voice settings. Under "Speech Engines," next to "Acapela TTS Engine," select Settings. Select the voice(s) you want to purchase. Return to Text-to-Speech voice settings and under "Preferred Voices," choose the voice you want to use.
Go to Text-to-Speech > Custom Voice > select a project, and select Set up voice talent. Select Add voice talent. Next, to define voice characteristics, select Target scenario. Then describe your Voice characteristics.
You first need to know which voices are installed, you can do this by GetInstalledVoices method of SpeechSynthesizer class: http://msdn.microsoft.com/en-us/library/system.speech.synthesis.speechsynthesizer.getinstalledvoices.aspx
Once you're sure that you've got a male voice installed, then you can simply switch by SelectVoiceByHints See: http://msdn.microsoft.com/en-us/library/ms586877
using (SpeechSynthesizer synthesizer = new SpeechSynthesizer())
{
// show installed voices
foreach (var v in synthesizer.GetInstalledVoices().Select(v => v.VoiceInfo))
{
Console.WriteLine("Name:{0}, Gender:{1}, Age:{2}",
v.Description, v.Gender, v.Age);
}
// select male senior (if it exists)
synthesizer.SelectVoiceByHints(VoiceGender.Male, VoiceAge.Senior);
// select audio device
synthesizer.SetOutputToDefaultAudioDevice();
// build and speak a prompt
PromptBuilder builder = new PromptBuilder();
builder.AppendText("Found this on Stack Overflow.");
synthesizer.Speak(builder);
}
See this for further explanation: how I can change the voice synthesizer gender and age in C#?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With