语法的语言与语音识别器的语言不匹配

 小丁啊小丁 发布于 2023-01-05 19:24

美好的一天!它是关于Microsoft Server Speech SDK v11.0(服务器版本).

我在MSDN示例中运行了测试示例.所以英语短语-red,blue--很好.但我也想识别俄语 - 安装微软语音识别语言-TELE(ru-RU)并运行我的app /

码:

 static void DoWork()
    {

        Thread.CurrentThread.CurrentCulture = new CultureInfo("ru-RU");
        Thread.CurrentThread.CurrentUICulture = new CultureInfo("ru-RU");

        // Create a new SpeechRecognitionEngine instance.
        SpeechRecognitionEngine sre = new SpeechRecognitionEngine();

        // Configure the input to the recognizer.
        sre.SetInputToWaveFile(@"c:\Test\???????.wav");

        // Create a simple grammar that recognizes "red", "green", or "blue".
        Choices colors = new Choices(); 
       // colors.Add(new string[] { "red", "green", "blue","???????" });
        colors.Add(new string[] { "???????" }); //russian word- "red"

        // Create a GrammarBuilder object and append the Choices object.
        GrammarBuilder gb = new GrammarBuilder();
        gb.Culture = new CultureInfo("ru-RU"); // add Culture Info

        gb.Append(colors);

        Console.WriteLine(gb.Culture.CultureTypes);

        // Create the Grammar instance and load it into the speech recognition engine.
        Grammar g = new Grammar(gb);
        sre.LoadGrammar(g);

        // Register a handler for the SpeechRecognized event.
        sre.SpeechRecognized +=
          new EventHandler(sre_SpeechRecognized);

        // Start recognition.
        sre.Recognize();
    }

    // Create a simple handler for the SpeechRecognized event.
    static void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
    {
        Console.WriteLine(String.Format("Speech recognized: {0}",e.Result.Text));

    }

此行显示错误:

 sre.LoadGrammar(g);

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

那么,如何修复此错误?我尝试设置CultureInfo,但它不起作用......谢谢!

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有