【问题标题】:Stop responding to windows commands停止响应 windows 命令
【发布时间】:2013-05-18 06:09:52
【问题描述】:

请看下面的代码

  private void button2_Click(object sender, EventArgs e)
        {
            SpeechRecognizer sr = new SpeechRecognizer();

            Choices colors = new Choices();
            colors.Add(new string[] { "red arrow", "green", "blue" });

            GrammarBuilder gb = new GrammarBuilder();
            gb.Append(colors);

            Grammar g = new Grammar(gb);

            sr.LoadGrammar(g);

           // SpeechSynthesizer s = new SpeechSynthesizer();
           // s.SpeakAsync("start speaking");

            sr.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sr_SpeechRecognized);
        }

        void sr_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            MessageBox.Show(e.Result.Text);
        }

这是使用 MS 语音引擎的普通语音识别代码。你可以在这里看到我已经加载了一些语法。但是,也有一个问题。也就是说,这不仅响应给定的语法,还响应 MS 内置的语音命令!就像语音命令最小化窗口、打开开始菜单等!

我真的不需要那个。我的应用程序应该只响应我的语法而不是 MS 内置命令。有没有办法我可以做到这一点?

【问题讨论】:

    标签: c# .net windows visual-studio-2010 speech-recognition


    【解决方案1】:

    SpeechRecognizer 对象建立在现有的 Windows 语音系统之上。来自MSDN:

    应用程序使用共享识别器访问 Windows Speech 认出。使用 SpeechRecognizer 对象添加到 Windows 语音用户体验。

    考虑改用SpeechRecognitionEngine 对象,因为它在进程内而不是系统范围内运行。

    【讨论】:

    • 这很有趣。我会试试这个,让你知道。 :)
    猜你喜欢
    • 1970-01-01
    • 2021-09-04
    • 1970-01-01
    • 2016-06-09
    • 1970-01-01
    • 2014-08-20
    • 2020-05-07
    • 1970-01-01
    • 2014-12-02
    相关资源
    最近更新 更多