Microsoft Speech Platform:识别单词重复

Microsoft Speech Platform: recognize word repetitions

我使用 Microsoft Speech Platform 识别语音并将其输出到屏幕上。但是,我有问题:例如,我有语法(由 GrammarBuilder 和 Choices 构建 - "red"、"green"、"black")

当我说- "red green black"- 我只能得到 "red",也许 "red green",但不能得到 "red green black".

一些代码:

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);                    
   }
}

那么,如何解决这个问题?我应该用规则制作 SGRS 语法吗? 语法文件是 txt 文件,里面有这样的词:

Dictionary.txt

green
black
yellow
red
some other words

您可以使用 Append method with repeat:

 gb.Append(choices, 1, 10);