so this is how it goes :
- Go to the references of your project and add System.Speech.Recognition
- Create a new instance of the SpeechRecognitionEngine
SpeechRecognitionEngine sre = new SpeechRecognitionEngine(new CultureInfo("en-US")); - Set a file to read from and a dictionary to use:
sre.SetInputToWaveFile("c:\\test.wav");
sre.LoadGrammar(new DictationGrammar()); - Now read
RecognitionResult rr = sre.Recognize(); - If something fails inside the Recognize() then it returns null , otherwise rr.Text will get you the text you are looking for ;
now the problem is and it stays unsolved , that out of the box , the engine does not usually hit the correct text . Good luck and mail me if you have ideas
SpeechRecognitionEngine sre = new SpeechRecognitionEngine(new CultureInfo("en-US"));
sre.SetInputToWaveFile("c:\\test.wav");
sre.LoadGrammar(new DictationGrammar());
RecognitionResult rr = sre.Recognize();
if (rr != null)
{
Console.WriteLine(rr.Text);
}
else
{
Console.WriteLine("Recognition failed");
}
Console.ReadKey();
No comments:
Post a Comment