Accuracy of MS System.Speech.Recognizer and the SpeechRecognitionEngine

后端 未结 1 345
北恋
北恋 2021-01-05 13:43

I am currently testing the SpeechRecognitionEngine by loading from an xml file a pretty simple rule. In fact it is a simple between (\"decrypt the email\", \"remove encryp

相关标签:
1条回答
  • 2021-01-05 14:32

    If the only thing the System.Speech recognizer is listening for is "encrypt the email", then the recognizer will generate lots of false positives. (Particularly in a noisy environment.) If you add a DictationGrammar (particularly a pronunciation grammar) in parallel, the DictationGrammar will pick up the noise, and you can check the (e.g.) name of the grammar in the event handler to discard the bogus recognitions.

    A (subset) example:

        static void Main(string[] args)
        {
            Choices gb = new Choices();
            gb.Add("encrypt the document");
            gb.Add("decrypt the document");
            Grammar commands = new Grammar(gb);
            commands.Name = "commands";
            DictationGrammar dg = new DictationGrammar("grammar:dictation#pronunciation");
            dg.Name = "Random";
            using (SpeechRecognitionEngine recoEngine = new SpeechRecognitionEngine(new CultureInfo("en-US")))
            {
            recoEngine.SetInputToDefaultAudioDevice();
            recoEngine.LoadGrammar(commands);
            recoEngine.LoadGrammar(dg);
            recoEngine.RecognizeCompleted += recoEngine_RecognizeCompleted;
            recoEngine.RecognizeAsync();
    
            System.Console.ReadKey(true);
            recoEngine.RecognizeAsyncStop();
            }
        }
    
        static void recoEngine_RecognizeCompleted(object sender, RecognizeCompletedEventArgs e)
        {
            if (e.Result.Grammar.Name != "Random")
            {
                System.Console.WriteLine(e.Result.Text);
            }
        }
    
    0 讨论(0)
提交回复
热议问题