I would like to change the gender and age of the voice of System.Speech
in c#. For example, a girl of 10 years but can not find any simple example to help me adjust the parameters.

- 5,613
- 12
- 49
- 68

- 673
- 2
- 10
- 24
5 Answers
First, check which voices you have installed by enumerating the GetInstalledVoices
method of the SpeechSynthesizer
class, and then use SelectVoiceByHints
to select one of them:
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);
}

- 49,838
- 16
- 120
- 201
-
If speaker is a woman yet, means that I dont have male voice in my system, so I need to download it? – Pablo Gonzalez Jun 04 '12 at 13:09
-
@Pablo: that's correct, although, to tell you the truth, I have no clue where to download them from. [This MSDN page](http://www.microsoft.com/en-us/download/details.aspx?id=27224) looks like it has some additional voices, but I never used any of them. – vgru Jun 04 '12 at 13:17
-
Ok, change voice properties is just a question I had time ago, because I wanna know more about speech namespace. I will go to find a little girl voice if really exist hahah thanks again – Pablo Gonzalez Jun 04 '12 at 13:21
http://msdn.microsoft.com/en-us/library/system.speech.synthesis.voiceage.aspx http://msdn.microsoft.com/en-us/library/system.speech.synthesis.voicegender.aspx
Did you take a look at this ?

- 386
- 1
- 16
-
2Why [StackOverFlow](http://http://stackoverflow.com) doesn't have **LIKE** button ? :) – Ahmed Ghoneim Jun 04 '12 at 12:42
-
1
-
-
Member names are NotSet, Child, Teen, etc..., why did you try "VoiceAge 10" ? – Pierre Pellegrino Jun 04 '12 at 12:52
-
because I am a novice...properties, members, class, events, still confusing me a lot – Pablo Gonzalez Jun 04 '12 at 12:55
-
You should check Groo's answer so, look at how he selected the voice : `synthesizer.SelectVoiceByHints(VoiceGender.Male, VoiceAge.Senior);` – Pierre Pellegrino Jun 04 '12 at 12:56
-
What ? _Sorry my english's not well and I don't know what you mean_ – Pierre Pellegrino Jun 04 '12 at 13:00
-
1@PabloGonzalez: you probably only have a single voice installed ("Microsoft Anna", a female adult). – vgru Jun 04 '12 at 13:04
-
You need to check if the voice you need is installed. Look at Groo's Answer, he gave you all the code to do what you need to do. :) – Pierre Pellegrino Jun 04 '12 at 13:04
first you need to intialise the reference speech using the add reference.
then create an event handler for the speak started then you can edit the paramemters inside that handler.
in the handler is where you can change the voice and age using the
synthesizer.SelectVoiceByHints(VoiceGender.Male , VoiceAge.Adult);

- 19,829
- 17
- 83
- 99

- 81
- 7
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Speech.Synthesis; // first import this package
namespace textToSpeech
{
public partial class home : Form
{
public string s = "pran"; // storing string (pran) to s
private void home_Load(object sender, EventArgs e)
{
speech(s); // calling the function with a string argument
}
private void speech(string args) // defining the function which will accept a string parameter
{
SpeechSynthesizer synthesizer = new SpeechSynthesizer();
synthesizer.SelectVoiceByHints(VoiceGender.Male , VoiceAge.Adult); // to change VoiceGender and VoiceAge check out those links below
synthesizer.Volume = 100; // (0 - 100)
synthesizer.Rate = 0; // (-10 - 10)
// Synchronous
synthesizer.Speak("Now I'm speaking, no other function'll work");
// Asynchronous
synthesizer.SpeakAsync("Welcome" + args); // here args = pran
}
}
}
- It'll be better choice to use "SpeakAsync" because when "Speak" function is executing/running none of other function will work until it finishes it's work (personally recommended)

- 1,817
- 23
- 23
These age and gender is actually of no use. If you have many voices installed in your windows, then you may call specific voices by these parameters. Otherwise, its simply fake!

- 300
- 1
- 4
- 11