Disable built-in speech recognition commands?

2019-02-21 13:52发布

I'm trying to build software that interprets various textual commands, all in a custom way. I use System.Speech.Recognition and it works surprisingly well, but I can't figure how to get around the fact that whenever I say "Delete", "Close", "Correct", etc, I will end up with the default Windows (7) implementation. Is there any way to get around that with System.Speech.Recognition? If not, which C# .NET library would you recommend the most?

1条回答
疯言疯语
2楼-- · 2019-02-21 14:16

Use SpeechRecognitionEngine instead of SpeechRecognizer.
Try this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Speech.Recognition;
namespace speech
{
class Program
{
    static void Main(string[] args)
    {
        SpeechRecognitionEngine mynizer = new SpeechRecognitionEngine();

        GrammarBuilder builder = new GrammarBuilder();
        builder.AppendDictation();
        Grammar mygram = new Grammar(builder);
        mynizer.SetInputToDefaultAudioDevice();
        mynizer.LoadGrammar(mygram);
        while (true)
        {
            Console.WriteLine(mynizer.Recognize().Text);
        }
    }

}
}
查看更多
登录 后发表回答