我编写了一个简单的语音识别应用程序,可以将语法加载到引擎中。
但是我明白了,那不能把很多语法装进引擎,不超过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");
}
}
}当我加载5-10克(每个100字)时,效果很好。
也许我可以\应该使用多个识别引擎在一起?
发布于 2015-01-14 16:58:09
从评论中看,你从根本上采取了错误的做法。您需要使用类似于System.Speech.Recognition.DictationGrammar的东西--它使用的是微软桌面SR引擎。
这将接受大多数英语单词。如果你需要限制它的1000个字,有几个选项。
如果word列表中包含的单词不在默认的word列表中(相当广泛),那么您可以使用词汇接口,遗憾的是,它没有通过System.Speech.Recognition公开,所以您必须使用SAPI才能使用它们。
这也假设你可以拒绝词汇外的认知.如果不是这样的话,您可以使用口述资源工具包,它将允许您构建一个自定义语言模型;请注意,它是由语音科学家为语音科学家构建的,因此文档非常困难。
在实践中,用户会说出一些词汇量不足的东西,最好检查一下,然后拒绝.小的(是的,1000个单词是小的)词汇表往往有错误阳性的问题(用户说一些词汇外的东西,被认为是词汇中的东西)。这种情况也发生在命令和控制语法中。
https://stackoverflow.com/questions/27684069
复制相似问题