Microsoft Speech Platform: recognize word repetitions

99封情书 提交于 2019-12-24 14:34:52

问题


I use Microsoft Speech Platform to recognize speech at output it on screen. But, i have problem: for example, i have grammar (constructs by GrammarBuilder and Choices - "red","green","black")

When i say- "red green black"- i can get only "red", maybe "red green" , but not "red green black".

Some code:

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

So, how to fix this problem? Should i make SGRS-grammar with rules? The grammar file is txt file with words like that:

Dictionary.txt

green
black
yellow
red
some other words

回答1:


You can use Append method with repeat:

 gb.Append(choices, 1, 10);


来源:https://stackoverflow.com/questions/27879560/microsoft-speech-platform-recognize-word-repetitions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!