السلام عليكم و رحمة الله و بركاته..
اثناء بحثي لتعلم تقنية speech Recognition ..و جدت على شبكة الانترنت هذا الكود....فما مدى صحته...و لماذا لم يعمل معي؟
public partial class Form1 : Form
{
SpeechRecognizer rec = new SpeechRecognizer();
public Form1()
{
InitializeComponent();
rec.SpeechRecognized += rec_SpeechRecognized;
}
private void rec_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
RecognitionResult r = e.Result;
label1.Text = r.Text;
}
private void Form1_Load(object sender, EventArgs e)
{
var c = new Choices();
//for (int i = 0; i < 100; i++)
//{
// c.Add(i.ToString());
//}
c.Add("one");
c.Add("two");
var gb = new GrammarBuilder(c);
var g = new Grammar(gb);
rec.LoadGrammar(g);
rec.Enabled = true;
}
}