本文介绍了我如何在C#识别中将Sql表转换为Grammer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何在C#识别中将sqlserver表转换为语法?

例如:

how i do convert a sqlserver table to grammar in C# recognition ?
for example:

var db = new DataClasses1DataContext();
        var word = from c in db.Englishes select c;
                   comboBox1.DataSource = word;
         comboBox1.DisplayMember = "English_Word";
           comboBox1.ValueMember = "English_Word";

           string[]  conv=new string[100000];

           for (int a = 0; a < comboBox1.Items.Count; a++)  conv[a] = comboBox1.Items[a].ToString();
           Choices comands = new Choices();
           comands.Add(conv);
           GrammarBuilder gbuilder = new GrammarBuilder();
           gbuilder.Append(comands);
           Grammar grammar = new Grammar(gbuilder);

           recEngine.LoadGrammarAsync(grammar);
           recEngine.SetInputToDefaultAudioDevice();
           recEngine.RecognizeAsync(RecognizeMode.Multiple); //Error here





错误



recEngine.RecognizeAsync(RecognizeMode.Multiple);



({在识别之前必须加载至少一个语法。})是错误





请帮助我谢谢你



is error in

recEngine.RecognizeAsync(RecognizeMode.Multiple);

( {"At least one grammar must be loaded before doing a recognition."} ) is error


please help me thank you

推荐答案



  1. 使用 LoadGrammar 而不是 LoadGrammarAsync
  2. 如果将其加载为异步,则只在加载完成后启动识别器。添加 LoadGrammarCompleted 事件处理程序,启动识别器:


  1. Load the grammar synchronously, using LoadGrammar instead of LoadGrammarAsync.
  2. If you load it async, only start the recognizer once the loading is complete. Add a LoadGrammarCompleted event handler which starts the recognizer:
recEngine.LoadGrammarCompleted += delegate(EventHandler<LoadGrammarCompletedEventArgs> e)
{
    recEngine.SetInputToDefaultAudioDevice();
    recEngine.RecognizeAsync(RecognizeMode.Multiple);
};
recEngine.LoadGrammarAsync(grammar);


这篇关于我如何在C#识别中将Sql表转换为Grammer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 13:19