Thursday, July 16, 2009

Vista Speech Regognition API

This will teach your program to read text from the voice it "hears" using .NET 3

so this is how it goes :
  1. Go to the references of your project and add System.Speech.Recognition
  2. Create a new instance of the SpeechRecognitionEngine
    SpeechRecognitionEngine sre = new SpeechRecognitionEngine(new CultureInfo("en-US"));
  3. Set a file to read from and a dictionary to use:
    sre.SetInputToWaveFile("c:\\test.wav");
    sre.LoadGrammar(new DictationGrammar());
  4. Now read
    RecognitionResult rr = sre.Recognize();
  5. 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