예제 #1
0
 public IntPtr QISRGetResult(IntPtr sessionID, ref E识别状态 rsltStatus, int waitTime, ref int errorCode)
 {
     return(Dll在线.QISRGetResult(sessionID, ref rsltStatus, waitTime, ref errorCode));
 }
예제 #2
0
 public int QISRAudioWrite(IntPtr sessionID, byte[] waveData, uint waveLen, E音频块位置 audioStatus, ref E检测状态 epStatus, ref E识别状态 recogStatus)
 {
     return(Dll在线.QISRAudioWrite(sessionID, waveData, waveLen, audioStatus, ref epStatus, ref recogStatus));
 }
예제 #3
0
 public static extern int QISRAudioWrite(IntPtr sessionID, byte[] waveData, uint waveLen, E音频块位置 audioStatus, ref E检测状态 epStatus, ref E识别状态 recogStatus);
예제 #4
0
 public static extern IntPtr QISRGetResult(IntPtr sessionID, ref E识别状态 rsltStatus, int waitTime, ref int errorCode);
예제 #5
0
        void 识别()
        {
            while (_任务状态 == E任务状态.运行中)
            {
                int __结果 = 0;
                try
                {
                    _会话 = DLL接口.QISRSessionBegin(获取语法id(), 获取识别参数(), ref __结果); //重新开始会话
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("开启会话出错: " + ex);
                    Thread.Sleep(300);
                    continue;
                }
                _检测状态 = E检测状态.等待输入;
                _识别状态 = E识别状态.正在识别中;
                if (__结果 != 0)
                {
                    Debug.WriteLine("开启会话出错, 错误码: " + __结果);
                    Thread.Sleep(300);
                    continue;
                }
                Debug.WriteLine("开启会话");

                while (_任务状态 == E任务状态.运行中 && _识别状态 != E识别状态.识别结束 && _识别状态 != E识别状态.没有识别结果)
                {
                    if (_检测状态 == E检测状态.等待输入)
                    {
                        Debug.Write("-");
                        Thread.Sleep(300);
                        continue;
                    }

                    IntPtr __识别结果 = DLL接口.QISRGetResult(_会话, ref _识别状态, 0, ref __结果);
                    //Debug.WriteLine("任务状态: {0}; 识别状态: {1}", _任务状态, _识别状态);
                    if (__结果 == 0)
                    {
                        if (__识别结果 != IntPtr.Zero)
                        {
                            var __文本 = Marshal.PtrToStringAnsi(__识别结果);
                            Debug.Write("\n识别出命令: " + Environment.NewLine + __文本 + Environment.NewLine);
                            分析识别结果(__文本);
                        }
                        Debug.Write(".");
                    }
                    else
                    {
                        Debug.WriteLine("\n识别出错: {0}", __结果);
                        break;
                    }
                    Thread.Sleep(300);
                }
                Debug.WriteLineIf(_任务状态 != E任务状态.运行中 || _识别状态 != E识别状态.识别结束, string.Format("\n任务状态: {0}; 识别状态: {1}; 检测状态: {2}", _任务状态, _识别状态, _检测状态));
                try
                {
                    __结果 = DLL接口.QISRSessionEnd(_会话, null);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(Environment.NewLine + "结束会话出错: " + ex + Environment.NewLine);
                }
                _会话 = IntPtr.Zero;
                if (__结果 == 0)
                {
                    Debug.WriteLine(Environment.NewLine + "结束会话" + Environment.NewLine);
                }
                else
                {
                    Debug.WriteLine(Environment.NewLine + "结束会话出错, 错误码: " + __结果 + Environment.NewLine);
                }
            }
            _任务状态 = E任务状态.停止;
        }