none
请问如何解决使用speech sdk v11.0时的”The language of the grammar does not match the speech recognizer"的问题? RRS feed

  • 问题

  • 以下是微软speech sdk v11.0的帮助文档中给出的示例程序:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using Microsoft.Speech.Recognition;
    using System.Windows.Forms;

    namespace SDKHP_01
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }

            private void Form1_Load(object sender, EventArgs e)
            {
                // Create a new SpeechRecognitionEngine instance.
                sre = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US"));

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

                // Create a GrammarBuilder object and append the Choices object.
                GrammarBuilder gb = new GrammarBuilder();
                gb.Append(colors);

                // 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<SpeechRecognizedEventArgs>(sre_SpeechRecognized);

            }
            // Create a simple handler for the SpeechRecognized event.
            void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
            {
                MessageBox.Show(e.Result.Text);
            }

            SpeechRecognitionEngine sre;

        }
    }

    运行时出现如题的问题,请问如何解决?本人使用win7系统只支持简体中文语言,是否与此有关?

    2013年5月26日 8:07