The language for the grammar does not match the language of the speech recognizer

我的梦境 提交于 2019-11-28 12:46:01

Looks like you need

SpeechRecognitionEngine recognizer =
        new SpeechRecognitionEngine(
          new System.Globalization.CultureInfo("ru-RU")))
Kevor Wang

Change the GrammarBuilder.Culture property would solve this error.

After:

GrammarBuilder gb = new GrammarBuilder();

Add:

gb.Culture = Thread.CurrentThread.CurrentCulture

So that the grammar culture matches the recognizer.

The grammar builder culture has to match the speech recognizer. The easiest way to do this is by setting the grammar culture to be the same as the speech recognizer, as below:

var sr = new SpeechRecognizer();
var gb = new GrammarBuilder();

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