c# - Adding voice to my text -
i trying add voice calculator project. able add voice. facing problem. when press 13, first says "one" says "thirteen". , 1 more thing unable add voice equal(=) sign.
private void numberbuttons(object sender, eventargs e) { button b = sender 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 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 equal method.
you have convert numbers words, otherwise it'll 13 1 three. here's post shows how that.
also, equal need add manually text want spoken.
basically need build text this, operationtext "plus" or "minus", etc.:
var texttobespoken = input1toword + operationtext + input2toword + "equals" + resulttoword
Comments
Post a Comment