日期:2014-05-17  浏览次数:20769 次

请看语音转换成文字的代码,运行不成功?

        public class SpRecognition
        {
            private static SpRecognition _Instance = null;
            private SpeechLib.ISpeechRecoGrammar isrg;
            private SpeechLib.SpSharedRecoContextClass ssrContex = null;
            private System.Windows.Forms.Control cDisplay;  //fan:用来显示语音转化后的文本
            public System.Windows.Forms.TextBox textbox;   //fan:增加textbox在SpRecognition 类
            public SpRecognition()
            {
                ssrContex = new SpSharedRecoContextClass();
                isrg = ssrContex.CreateGrammar(1);
                SpeechLib._ISpeechRecoContextEvents_RecognitionEventHandler recHandle =
                new _ISpeechRecoContextEvents_RecognitionEventHandler(ContexRecognition);
                ssrContex.Recognition += recHandle;
            }
            public void BeginRec(Control tbResult)
            {
                isrg.DictationSetState(SpeechRuleState.SGDSActive);
                cDisplay = tbResult;
                //cDisplay.Text = "dddddddddd";  测试,可以成功在textbox1那里显示出来

            }
            public static SpRecognition instance()
            {
                if (_Instance == null)