我编写了简单的语音识别应用程序,可以将语法加载到引擎中。
但我明白了,不能将许多语法加载到引擎中,而不是 1024 个语法。
Additional information: Too many grammars have been loaded. Number of grammars cannot exceed 1024.
当我加载 1024 语法时,它无法识别输入流.wav
(和我的语音)文件:
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");
public void LoadGrammarIntoEngine(IEnumerable<String> textColl)
{
Choices choises = new Choices();
GrammarBuilder gb = new GrammarBuilder();
gb.Culture = new CultureInfo("ru-RU");
if (choises != null && textColl != null)
{
choises.Add(textColl.ToArray());
if (gb != null)
gb.Append(choises);
else
{
Console.WriteLine();
}
if (_sre.Grammars.Count < 1024)
{
Grammar g = new Grammar(gb);
if (_sre != null && g != null)
_sre.LoadGrammar(g);
else
{
Console.WriteLine();
}
}
else
{
Console.WriteLine("too many grammars");
}
}
}
PS 当我加载 5-10 个语法(每个 100 个单词)时,效果很好。
也许我可以\应该一起使用多个识别引擎?