示例#1
0
        void instruction(int begin, int end, bool needPredict)   // [begin, end)
        {
            int len = end - begin;

            for (int i = 0; i < len; i++)
            {
                CXYNN.SetValue(i, (Int16)samples[begin + i]);
            }
            CXYNN.AddFrame();

            PosteriorHandler.updateWindow();
            if (needPredict)
            {
                int    ret  = PosteriorHandler.Predict();
                double conf = PosteriorHandler.CalcConfident();
                Debug.Log(ret + " <- " + conf); // for test
                Loger.Log(ret + " <- " + conf); // for test
                if (conf >= 0.3)
                {
                    Debug.LogError(ret);
                    Loger.LogError(ret);
                    PredictPool.AddPredict(ret);
                }
            }
        }
示例#2
0
        int lastPosition; // 本次读取clip中数据开始的位置

        // 异步语音识别
        // @param AudioClip _clip, 录音片段的引用
        // @param string _curDevice, 目标录音设备
        public void InstructionAsync(AudioClip _clip, string _curDevice)
        {
            clip         = _clip;
            curDevice    = _curDevice;
            samples      = new ArrayList(); samples.Clear(); // 初始化samples
            lastPosition = 0;
            PosteriorHandler.Init();
            NNThread = new Thread(new ThreadStart(Instruction));
            NNThread.Start();
        }