Simple windows form application that speaks whatever user enters into given textbox.
-
Basic idea behind this is similar to my previous repository: KeySound
-
I included a
textbox
,groupbox
withtwo radio buttons
and abutton
. -
User enters data/message into textbox provided, which then will be passed to a string variable as:
string text = textBox1.Text;
- Now, We will create object of
SpeechSynthesizer
as:
SpeechSynthesizer speech = new SpeechSynthesizer();
- Now, When user clicks on
Speak
button, we will callselectGender()
function to select the gender of output voice based on option selected by the user. - This
selectGender()
is as follows:
public void selectGender()
{
if (radioButton1.Checked == true)
speech.SelectVoiceByHints(VoiceGender.Male, VoiceAge.Adult);
else
speech.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult);
}
- Now, We will set
speech volume
as:
speech.Volume = 100;
- At the end, We will call
Speak
method using object ofSpeechSynthesizer
withtext
as argument:
speech.Speak(text);