Esempio n. 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);
                }
            }
        }
Esempio n. 2
0
 public static void updateWindow()
 {
     CXYNN.Predict();
     double[] tmp = new double[caseNumber];
     CXYNN.calcProb();
     for (int i = 0; i < caseNumber; i++)
     {
         tmp[i] = CXYNN.readProb(i + 1);
     }
     addFrame(tmp);
 }
Esempio n. 3
0
        void Instruction()
        {
            // 计算每一帧所包含的sample的数量
            int bufferLen = frameLength * 16000 / 1000;

            // 等待输入足够的音频片段
            while (samples.Count < 15 * 16 && syncDataWithClip())
            {
            }

            if (samples.Count < 15 * 16)
            {
                Debug.Log("do not have enough info, exit");
                Loger.Log("do not have enough info, exit");
                return;
            }

            // Mfcc 填充 <= 我们使用的Mfcc代码中需要预先进行填充, 以保证最初的几帧得到的数据是有效的
            for (int i = 0; i < 15 * 16; i++)
            {
                CXYNN.SetPrev(i, (Int16)samples[i]);
            }

            // 识别过程
            int cnt     = 0;
            int cutFlag = 0;

            for (int i = 15 * 16; syncDataWithClip() || i + bufferLen - 1 < samples.Count;)
            {
                if (i + bufferLen > samples.Count)
                {
                    continue;
                }
                cnt += 1;
                instruction(i, i + bufferLen, cnt >= 30 && cutFlag % 3 == 0);
                i += bufferLen;
                cutFlag++;
            }

            // for debug
            Debug.Log("Done");
            Loger.Log("Done");
        }
Esempio n. 4
0
 public void Init()
 {
     CXYNN.InitCXYNN();
     CXYNN.InitMfcc(frameLength * 16000 / 1000);
 }