通过音频检测单词

时间:2013-07-02 03:18:14

标签: c# audio

我想知道是否有可能捕获语音输入并告诉用户是否说了一些像yes / no / next等简单的东西,而不使用语音到文本方法。我试过谷歌搜索,但结果不利。分析波形是一种方法,如何做到这一点?希望有人可以帮助我。

1 个答案:

答案 0 :(得分:2)

它内置于Windows,您可以从C#

访问它

参见文档

http://msdn.microsoft.com/en-us/library/hh361683(v=office.14).aspx

并且示例非常简单: -

// Create a new SpeechRecognitionEngine instance.
      SpeechRecognizer recognizer = new SpeechRecognizer();

      // Create a simple grammar that recognizes "red", "green", or "blue".
      Choices colors = new Choices();
      colors.Add(new string[] { "red", "green", "blue" });

      // Create a GrammarBuilder object and append the Choices object.
      GrammarBuilder gb = new GrammarBuilder();
      gb.Append(colors);

      // Create the Grammar instance and load it into the speech recognition engine.
      Grammar g = new Grammar(gb);
      recognizer.LoadGrammar(g);

      // Register a handler for the SpeechRecognized event.
      recognizer.SpeechRecognized +=
        new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized);
    }

    // Create a simple handler for the SpeechRecognized event.
    void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
    {
      MessageBox.Show("Speech recognized: " + e.Result.Text);
    }