微软语音平台:认识单词重复(Microsoft Speech Platform: recognize

2019-10-21 14:17发布

我用微软语音平台来将输出它在屏幕上识别语音。 但是,我有问题:比如,我有语法(由GrammarBuilder和选择结构 - “红色”,“绿色”,“黑”)

当我说 - “红,绿,黑” - 我只能得到“红”,也许是“红,绿”,而不是“红,绿,黑”。

一些代码:

Thread.CurrentThread.CurrentCulture = new CultureInfo("ru-RU");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("ru-RU");

// Create a new SpeechRecognitionEngine instance.
_sre = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("ru-RU"));

_sre.SpeechHypothesized += _sre_SpeechHypothesized;
_sre.SpeechDetected += _sre_SpeechDetected;
//_sre.SetInputToWaveFile(@"c:\Test\Wavs\Wavs-converted\file.wav");
_sre.SetInputToDefaultAudioDevice();

public void LoadGrammarIntoEngine(IEnumerable<String> textColl)
{
    Choices choices = new Choices();
    GrammarBuilder gb = new GrammarBuilder();
    gb.Culture = new CultureInfo("ru-RU");


    if (choices != null && textColl != null)
    {
        choices.Add(textColl.ToArray());
        gb.Append(choices);
    }

}
public void Recognize() {
   if (_sre != null && _sre.Grammars.Count != 0) {                   
       _sre.RecognizeAsync(RecognizeMode.Multiple);                    
   }
}

那么,如何解决这个问题? 我应该做的SGR-语法的规则? 语法文件是这样的话txt文件:

Dictionary.txt

green
black
yellow
red
some other words

Answer 1:

您可以使用Append方法与重复 :

 gb.Append(choices, 1, 10);


文章来源: Microsoft Speech Platform: recognize word repetitions