I have need to write an application which uses a speech recognition engine, the purpose off app is to control PC(keyboard and mouse), when user say "open mycomputer" to open my computer, or say any thing to perform that action, i have tried a lots of time but stuck in between,
my code is
{
SpeechRecognizer recognizer = new SpeechRecognizer();
recognizer.Enabled = true;
Choices folderPath= new Choices();
folderPath.Add(new string[] { "My Computer", "My Documents", "my docs", "Sumeet", "gehi"});
GrammarBuilder gb = new GrammarBuilder(folderPath);
Grammar gramer = new Grammar(gb);
recognizer.LoadGrammar(gramer);
gramerSpeechRecognized+=new EventHandler<SpeechRecognizedEventArgs (gramer_SpeechRecognized);
}
void gramer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
if (e.Result.Text == "computer" || e.Result.Text=="my computer")
{
string myComputerPath = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
System.Diagnostics.Process.Start("explorer", myComputerPath);
//OR
//System.Diagnostics.Process.Start("explorer", "::{20d04fe0-3aea-1069-a2d8-08002b30309d}");
}
else
{
// give output what user have said
textBox1.Text = e.Result.Text;
}
}
need helP!!! what to do or any mistakes in my code???
yes I have done this now work prefect
string resultText = e.Result.Text.ToLower();
if (resultText == "computer")
{
string myComputerPath =
Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
System.Diagnostics.Process.Start("explorer", myComputerPath);
//System.Diagnostics.Process.Start("explorer", "::{20d04fe0-3aea-1069-a2d8-08002b30309d}");
}
but if you still find answer better than this so plz comment here thanx guys