Пример #1
0
        public static void Release()
        {
            HciErrorCode hciErrorCode1 = HciCloudAsr.HciAsrSessionStop(ASR_Recog.session_id_);

            if (hciErrorCode1 == HciErrorCode.HCI_ERR_NONE)
            {
                Console.WriteLine("HciCloudAsr HciAsrSessionStop Success");
            }
            else
            {
                Console.WriteLine("HciCloudAsr HciAsrSessionStop 出错: " + (object)hciErrorCode1);
            }
            HciErrorCode hciErrorCode2 = HciCloudAsr.HciAsrSessionStop(ASR_Recog.session_id_novad);

            if (hciErrorCode2 == HciErrorCode.HCI_ERR_NONE)
            {
                Console.WriteLine("HciCloudAsr HciAsrSessionStop Success");
            }
            else
            {
                Console.WriteLine("HciCloudAsr HciAsrSessionStop 出错: " + (object)hciErrorCode2);
            }
            HciErrorCode hciErrorCode3 = HciCloudAsr.HciAsrRelease();

            hciErrorCode3 = HciCloudSys.HciRelease();
        }
Пример #2
0
        public static int Init()
        {
            string str1           = "conf/AccountInfo.txt";
            string capkeyFromFile = AccountInfo.GetCapkeyFromFile(str1);

            if (capkeyFromFile == null || capkeyFromFile.Length == 0)
            {
                Console.WriteLine("是不是忘记了在" + str1 + "中填写capkey了?");
                return(-1);
            }
            else
            {
                string config1 = ASR_Recog.GetConfig(str1);
                if (config1 == null || config1.Length == 0)
                {
                    Console.WriteLine("获取配置失败");
                    return(-1);
                }
                else
                {
                    HciErrorCode hciErrorCode1 = HciCloudSys.HciInit(config1);
                    if (hciErrorCode1 == HciErrorCode.HCI_ERR_NONE)
                    {
                        Console.WriteLine("HciCloudSys HciInit Success");
                        if (!ASR_Recog.CheckAndUpdataAuth())
                        {
                            int num = (int)HciCloudSys.HciRelease();
                            return(-1);
                        }
                        else if (!ASR_Recog.IsCapkeyEnable(capkeyFromFile))
                        {
                            Console.WriteLine("capkey " + capkeyFromFile + " is not enable\n");
                            int num = (int)HciCloudSys.HciRelease();
                            return(-1);
                        }
                        else
                        {
                            HciErrorCode hciErrorCode2 = HciCloudAsr.HciAsrInit("dataPath=data" + ",initCapkeys=" + capkeyFromFile);
                            if ((uint)hciErrorCode2 > 0U)
                            {
                                Console.WriteLine("HciAsrInit failed return " + (object)hciErrorCode2);
                                int num = (int)HciCloudSys.HciRelease();
                                return(-1);
                            }
                            else
                            {
                                Console.WriteLine("HciAsrInit success");
                                ASR_Recog.addpunc_ = AccountInfo.GetkAddPuncFromFile(str1);
                                ASR_Recog.capkey_  = capkeyFromFile;
                                string str2 = "capkey=" + capkeyFromFile + ",realtime=";
                                ASR_Recog.realtime_ = AccountInfo.GetRealTimeFromFile(str1);
                                if (ASR_Recog.realtime_ != "no")
                                {
                                    string config2 = str2 + ASR_Recog.realtime_ + ",audioformat=pcm16k16bit,vadThreshold=10";
                                    if (ASR_Recog.realtime_ == "yes")
                                    {
                                        config2 = config2 + ",encode=speex,vadHead=0,vadTail=500,vadSeg=500";
                                    }
                                    HciErrorCode hciErrorCode3 = HciCloudAsr.HciAsrSessionStart(config2, ref ASR_Recog.session_id_);
                                    if (hciErrorCode3 == HciErrorCode.HCI_ERR_NONE)
                                    {
                                        Console.WriteLine("HciCloudAsr HciAsrSessionStart Success");
                                    }
                                    else
                                    {
                                        Console.WriteLine("HciCloudAsr HciAsrSessionStart 出错: " + (object)hciErrorCode3);
                                        return(-1);
                                    }
                                }
                                return(0);
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("HciCloudSys HciInit 出错: " + (object)hciErrorCode1);
                        return(-1);
                    }
                }
            }
        }