0

I am using an Chinese Windows 7 with speech recognition working fine if I use the grammar to recognize English sentences which is constructed with the object of Choice.But the object of SpeechRecognitionEngine only can arise SpeechDetectedEventArgs and doesn't arise LoadGrammarCompletedEventArgs or RecognizeCompletedEventArgs when the the object of Grammar is constructed with the object of SrgsDocement.There is my fragement of the project.

    SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine ( System.Globalization.CultureInfo.CreateSpecificCulture("zh-CN"));
            SrgsDocument srgsdoc = new SrgsDocument(./commongreetingGrammar.grxml");
            recognizer.MaxAlternates = 5;
            recognizer.LoadGrammarCompleted += new EventHandler<LoadGrammarCompletedEventArgs>(recognizer_LoadGrammarCompleted);
            recognizer.SpeechDetected += new EventHandler<SpeechDetectedEventArgs>(recognizer_SpeechDetected);
            recognizer.RecognizeCompleted += new EventHandler<RecognizeCompletedEventArgs>(recognizer_RecognizeCompleted);
            recognizer.LoadGrammar(new Grammar(srgsdoc));

            recognizer.SetInputToDefaultAudioDevice();
            recognizer.RecognizeAsync (RecognizeMode .Multiple);
        }
        catch (Exception ex)
        { Console.WriteLine(ex.Message); }
        Console.ReadKey();
    }

    static void recognizer_SpeechDetected(object sender, SpeechDetectedEventArgs e)
    {
        Console.WriteLine("Detect that someone is speeching");
    }

    static void recognizer_LoadGrammarCompleted(object sender, LoadGrammarCompletedEventArgs e)
    {
        if (e.Error == null)
            Console.WriteLine("complete to load grammar ");
        else
            Console.WriteLine("Fail to load grammar");
    }

    static void recognizer_RecognizeCompleted(object sender, RecognizeCompletedEventArgs e)
    {
        if (e.Result.Semantics["step"].Value.ToString() == "A1")
        {
            Console.WriteLine("A start to speak:{0}", e.Result.Text);
        }
    }

And there is the file named commongreetingGrammar.grxml that constructs the object of SrgsDocement named srgsdoc .(Sorry to add the image of the .grxml file instead of the plain text of the .grxml file)

![enter image description here][1]

1 Answers1

0

I’m afraid that I didn’t present my problem clearly. I try to recognize English sentences using the SpeechRecognitionEngine class ,which is part of SAPI5.4,on an Chinese Windows7 which has installed the Microsoft Speech Recognizer 8.0 for Windows (Chinese Simplified - PRC).Using the object of Grammar class constructed with the object of Choice class,the object of the SpeechRecognitionEngine class loaded the grammar can recognize some of simple English sentences,for example,”How are you ”,”yes”,”quit”. However, using the object of Grammar class constructed with the SrgsDocement object which is constructed with .grxml file,the SpeechRecognitionEngine object loaded the grammar can’t recognize some of simple English sentences and only can detect audioinput.The fragments of code as follewed.

Luckliy,I find the solution to the problem today. The problem is that I didn’t install the English language pack and constructed the Grammar object wrongly,which cause the SpeechRecognitionEngine object to fail to recognize the English sentences.The details of the solution I has posted in CodeProject.