Microsoft 语音平台:识别单词重复



我使用语音平台Microsoft在屏幕上输出时识别语音。但是,我有问题:例如,我有语法(由GrammarBuilder和Choices构造 - "红色","绿色","黑色")

当我说"红绿黑"时,我只能得到"红",也许是"红绿

",但不能得到"红绿黑"。

一些代码:

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:TestWavsWavs-convertedfile.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文件,其中包含这样的单词:

字典.txt

green
black
yellow
red
some other words

您可以将 Append 方法与 repeat:

 gb.Append(choices, 1, 10);

相关内容

  • 没有找到相关文章

最新更新