C#3.0基于 Speech.Recognition的grammerbuilder 语音识别定义模糊语法范例

using System;
using System.Windows;
using System.Speech.Recognition;

namespace Speech_Recognition
{
public partial class Window1 : System.Windows.Window
{
public Window1()
{
InitializeComponent();

SpeechRecognizer recognizer = new SpeechRecognizer();
GrammarBuilder builder = new GrammarBuilder();
builder.Append(new Choices("二", "三", "四", "五", "六", "七",
"八", "九", "十", "十一", "十二", "十三", "十四"));
builder.Append("的", 0, 1);
builder.Append(new Choices("哈", "师大", "斯蒂芬", "斯蒂"));
recognizer.LoadGrammar(new Grammar(builder));

recognizer.SpeechRecognized +=
new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);
}

void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
MessageBox.Show("你说: " + e.Result.Text);
}
}
}

你可能感兴趣的:(C++,c,windows,C#)