Hi All,
I have a bit of a problem I suspect most will know how to resolve, sadly I do not.
I have just started playing with voice recognition, it works reasonably well, however I cant seem to clear the event buffer between voice detections.
Here is my code...
using System.etc etc;
The problem is that SpeechRecognizedEventArgs e seems to keep the last detection, and I cant seem to clear it.
For example, if I say "hello"
Hello is detected and put in textbox1.
However if i now say banana after a pause, textbox1 displays hello banana, even though I clear the string buffer and the textbox.
Avent e keeps appending text and not clearing out past text.
So detecting commands is impossible unless i do it in the first detection after running.
In the above example, if the first thing I say is stephen, my message box pops up, however after closing the message box, but not the program, if I say stephen again, the detection becomes "stephen stephen"
So any suggestions how to remove the old text from SpeechRecognizedEventArgs e between detections?
Thanks in advance
Ray
I have a bit of a problem I suspect most will know how to resolve, sadly I do not.
I have just started playing with voice recognition, it works reasonably well, however I cant seem to clear the event buffer between voice detections.
Here is my code...
using System.etc etc;
namespace Hal { public partial class Form1 : Form { public Form1() { InitializeComponent(); } SpeechRecognizer sRecognise = new SpeechRecognizer(); string readtext = ""; private void Form1_Load(object sender, EventArgs e) { sRecognise.SpeechRecognized -= sRecognise_SpeechRecognized; } void sRecognise_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { readtext = e.Result.Text.ToLower(); textBox1.Clear(); textBox1.Text = readtext; readtext = ""; } private void textBox1_TextChanged(object sender, EventArgs e) { if (textBox1.Text == "Stephen") MessageBox.Show("Yes Ray"); } } }
The problem is that SpeechRecognizedEventArgs e seems to keep the last detection, and I cant seem to clear it.
For example, if I say "hello"
Hello is detected and put in textbox1.
However if i now say banana after a pause, textbox1 displays hello banana, even though I clear the string buffer and the textbox.
Avent e keeps appending text and not clearing out past text.
So detecting commands is impossible unless i do it in the first detection after running.
In the above example, if the first thing I say is stephen, my message box pops up, however after closing the message box, but not the program, if I say stephen again, the detection becomes "stephen stephen"
So any suggestions how to remove the old text from SpeechRecognizedEventArgs e between detections?
Thanks in advance
Ray
Last edited by a moderator: