I am trying to add voice to my calculator project. I was able to add the voice. But i am facing some problem. When i press 13, it first says "One" then says "Thirteen". And one more thing i am unable to add voice to equal(=) sign.
private void NumberButtons(object sender, EventArgs e)
{
Button b = sender as Button;
if ((b == null) || (b.Text == "0" && buffer.Length == 0))
return;
buffer += b.Text;
txtOutput.Text = buffer;
if (txtOutput.Text != "")
{
SpVoice voice = new SpVoice();
voice.Volume = 100;
voice.Speak(txtOutput.Text, SpeechVoiceSpeakFlags.SVSFlagsAsync);
}
}
here's the method.
private void Equal(object sender, EventArgs e)
{
if (buffer.Length != 0)
operand[1] = Double.Parse(buffer);
switch (op)
{
case '+': result = operand[0] + operand[1]; break;
case '-': result = operand[0] - operand[1]; break;
case '*': result = operand[0] * operand[1]; break;
case '/': result = operand[0] / operand[1]; break;
}
txtOutput.Text = result.ToString();
if (txtOutput.Text != "")
{
SpVoice voice = new SpVoice();
voice.Volume = 100;
// voice.Speak("The Result Is"+ SpeechVoiceSpeakFlags.SVSFlagsAsync);
voice.Speak(txtOutput.Text, SpeechVoiceSpeakFlags.SVSFlagsAsync);
}
step = 1;
buffer = "";
}
here's the equal method.