⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gauss_main.cpp

📁 Intel开发的IPP库的应用实例
💻 CPP
📖 第 1 页 / 共 2 页
字号:
   model=parm.model;

   Prob_Cache *cache= new Prob_Cache(mixnum,veclen,cachelen);

   if (cache->Init_Cache()<0){
       num_err++;
       return "ERROR! Could not create probabilities cache\n";
   }
   if (!cache->Attach_Calc(calc)){
       num_err++;
       return "ERROR! Could not attach mixture calculator\n";
   }

   Fake_Decoder *dec = new Fake_Decoder(mixnum,actlen);
   if (dec->Init_Decoder()<0){
       num_err++;
       return "ERROR! Could not create fake decoder\n";
   }
   if (!dec->Attach_Cache(cache)){
       num_err++;
       return "ERROR! Could not attach probabilities cache\n";
   }
   if (dec->Init_LogFile(problogfile)<0){
       num_err++;
       return "ERROR! Could not open probability log file\n";
   }

   stat_dec.len=256;
   stat_dec.nums=(int*)calloc(sizeof(int),256);

   stat_cache.len=veclen;
   stat_cache.nums=(int*)calloc(sizeof(int),veclen);

   m_clocks=ippGetCpuClocks();
   framenum=1;
   while (dec->Decode_Frame(avrmix)) {
      framenum++;
   }
   sec_time = getUSec(m_clocks,ippGetCpuClocks());
   speech_sec = (framenum+1)/100.0;

   dec->Close_Decoder();
   dec->Get_Statistics(&stat_dec);
   cache->Get_Statistics(&stat_cache);
   delete dec;
   delete cache;

   calc->Stop();
   GetExitCodeThread(Hdl1,&Hdl1_Id);
   while(Hdl1_Id==STILL_ACTIVE){
      GetExitCodeThread(Hdl1,&Hdl1_Id);
   }

   if(Hdl1!=NULL){
      CloseHandle(Hdl1);
      Hdl1=NULL;
   }


//   delete calc;
//   delete feat;

   printf("Feature type                        %s\n", (featfile[0]==0)?"    fake":
                                                                       "     HTK");
   printf("\n");
   printf("Calculation type                    %s\n", (hint==calcNone)?"  none":
                                                      (hint==calcVect)?"  vector":
                                                      (hint==calcVecM)?"  vecmax":
                                                      (hint==calcMix) ?"  mixture":
                                                      (hint==calcMMix)?"  multimix vector":
                                                                       "  unknown");
   printf("Active states per frame               %6i\n",avrmix);
   printf("Max activity interval                 %6i\n",actlen);
   printf("Cache size                            %6i\n",cachelen);
   printf("Probability vector length             %6i\n",veclen);
   printf("\n");

   printf("Model type                          %s\n", (model==0)      ?"    fake":
                                                      (model==1)      ?"    file":
                                                                       " unknown");
   printf("States                                %6i\n",mixnum);
   printf("Gaussians per mixture                 %6i\n",gaussnum);
   printf("Observation vector length             %6i\n",dimension);

   printf("\n");
   printf("Decoder statistics\n");
   printf("Frames                                %6i\n",framenum);
   if (delay<=0)
   printf("Delay                                   full\n");
   else
   printf("Delay                                 %6i\n",delay);
   printf("Active states per frame             %8.2f\n",((float)stat_dec.all)/framenum);
   printf("Requested probabilities per frame   %8.2f\n",((float)(stat_dec.all+stat_dec.lost))/framenum);
   for (avl=num=t=0; t<stat_dec.len; t++) {
      avl+=(t+1)*stat_dec.nums[t];
      num+=stat_dec.nums[t];
   }
   printf("Average state activity interval     %8.2f\n",((float)avl)/num);
   printf("\n\nCache statistics\n");
   printf("Calculated mixtures per frame       %8.2f\n",((float)stat_cache.all)/framenum);
   printf("Wasted mixtures per frame           %8.2f  %6.2f%%\n",
      ((float)stat_cache.lost)/framenum,((float)stat_cache.lost)/stat_cache.all*100);
   for (avl=num=t=0; t<stat_cache.len; t++) {
      avl+=(t+1)*stat_cache.nums[t];
      num+=stat_cache.nums[t];
   }
   printf("Average probability vector length   %8.2f\n",((float)avl)/num);

   printf("\n");
   printf("Frequency                           %8.2f MHz\n",freq);
   printf("Speech time                         %8.2f sec\n", speech_sec);
   printf("Decoding time                       %8.2f sec\n", sec_time/freq);
   printf("Speed                               %8.2f MHz %6.2f RT\n",
      sec_time/speech_sec,sec_time/speech_sec/freq);
   printf("\n");
   printf("\n");


   free(stat_cache.nums);
   free(stat_dec.nums);

   return "OK\n";
}



int main(int argc, char* argv[]) {

   ParseCommLine (argc-1, argv+1);  // get frequency, default - 500

   char *HMM_36="../data/hmm_36.param";
   char *HMM_39="../data/hmm_39.param";
   char *MFC_13="../data/feature_13.mfc";


   num_err=0;

   switch(TypeTest){
   case -1:
// arguments                    ( hint   ,paramf, featf,mixnum,gaussn,dimens,calcmx,calcmn,framen, delay,cachel,veclen,actlen,avrmix,problog,featlog,meanFact,varFact)
printf("\n etalon of vector\n\n");
printf("%s\n",Fake_Decoder_Test (calcVect,HMM_36,MFC_13,     6000,     4,    36,   100,    12,   455,     0,  1000,    12,    40,  1000,"../data/et_36.log",""));
       break;
   case -2:
// arguments                    ( hint   ,paramf, featf,mixnum,gaussn,dimens,calcmx,calcmn,framen, delay,cachel,veclen,actlen,avrmix,problog,featlog,meanFact,varFact)
printf("\n etalon of vecmax\n\n");
printf("%s\n",Fake_Decoder_Test (calcVecM,HMM_36,MFC_13,     6000,     4,    36,   100,    12,   455,     0,  1000,    12,    40,  1000,"../data/et_36.log",""));
       break;
   case 0:
// test vector calculation with different vector length
// arguments                    ( hint   ,paramf, featf,mixnum, gaussn,dimens,calcmx,calcmn, framen, delay,cachel,veclen,actlen,avrmix,problog,featlog)
printf("%s\n",Fake_Decoder_Test (calcVect,    "",    "",  6000,    24,    36,   100,    12,   455,    20,  1000,    12,    40,  1000,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcVect,    "",    "",  6000,    12,    36,   100,    12,   455,    20,  1000,    12,    40,  1000,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcVect,    "",    "",  6000,     4,    36,   100,    12,   455,    20,  1000,    12,    40,  1000,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcVect,    "",    "",  6000,     1,    36,   100,    12,   455,    20,  1000,    12,    40,  1000,    "",    ""));
// test mixture calculation with different vector length
printf("%s\n",Fake_Decoder_Test (calcMix ,    "",    "",  6000,    24,    36,   100,    12,   455,    20,  1000,    12,    40,  1000,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcMix ,    "",    "",  6000,    12,    36,   100,    12,   455,    20,  1000,    12,    40,  1000,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcMix ,    "",    "",  6000,     4,    36,   100,    12,   455,    20,  1000,    12,    40,  1000,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcMix ,    "",    "",  6000,     1,    36,   100,    12,   455,    20,  1000,    12,    40,  1000,    "",    ""));
// test multimix vector calculation with different vector length
printf("%s\n",Fake_Decoder_Test (calcMMix ,    "",    "",  6000,    24,    36,   100,    12,   455,    20,  1000,    12,    40,  1000,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcMMix ,    "",    "",  6000,    12,    36,   100,    12,   455,    20,  1000,    12,    40,  1000,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcMMix ,    "",    "",  6000,     4,    36,   100,    12,   455,    20,  1000,    12,    40,  1000,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcMMix ,    "",    "",  6000,     1,    36,   100,    12,   455,    20,  1000,    12,    40,  1000,    "",    ""));
// test vecmax calculation with different vector length
printf("%s\n",Fake_Decoder_Test (calcVecM ,    "",    "",  6000,    24,    36,   100,    12,   455,    20,  1000,    12,    40,  1000,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcVecM ,    "",    "",  6000,    12,    36,   100,    12,   455,    20,  1000,    12,    40,  1000,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcVecM ,    "",    "",  6000,     4,    36,   100,    12,   455,    20,  1000,    12,    40,  1000,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcVecM ,    "",    "",  6000,     1,    36,   100,    12,   455,    20,  1000,    12,    40,  1000,    "",    ""));
// test fake calculation with different vector length
printf("%s\n",Fake_Decoder_Test (calcNone,    "",    "",  6000,    24,    36,   100,    12,   455,    20,  1000,    12,    40,  1000,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcNone,    "",    "",  6000,    12,    36,   100,    12,   455,    20,  1000,    12,    40,  1000,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcNone,    "",    "",  6000,     4,    36,   100,    12,   455,    20,  1000,    12,    40,  1000,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcNone,    "",    "",  6000,     1,    36,   100,    12,   455,    20,  1000,    12,    40,  1000,    "",    ""));
/*
// test different models and feature files
printf("%s\n",Fake_Decoder_Test (calcNone,HMM_36,MFC_13, 6000,     4,    36,   100,    12,   455,     0,  1000,    12,    40,  1000,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcVect,HMM_36,MFC_13, 6000,     4,    36,   100,    12,   455,     0,  1000,    12,    40,  1000,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcNone,HMM_36,MFC_13, 6000,     4,    36,   100,    12,   455,     0,  1000,     1,    40,  1000,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcVect,HMM_36,MFC_13, 6000,     4,    36,   100,    12,   455,     0,  1000,     1,    40,  1000,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcNone,HMM_39,MFC_13, 6000,     4,    36,   100,    12,   455,     0,  1000,    12,    40,  1500,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcVect,HMM_39,MFC_13, 6000,     4,    39,   100,    12,   455,     0,  1000,    12,    40,  1500,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcNone,HMM_39,MFC_13, 6000,     4,    39,   100,    12,   455,     0,  1000,     1,    40,  1500,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcVect,HMM_39,MFC_13, 6000,     4,    39,   100,    12,   455,     0,  1000,     1,    40,  1500,    "",    ""));
// test delta calculation and energy cutting
printf("%s\n",Fake_Decoder_Test (calcVect,    "",MFC_13, 6000,    12,    36,   100,    12,   455,     0,  1000,    12,    40,  1500,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcVect,    "",MFC_13, 6000,    12,    24,   100,    12,   455,     0,  1000,    12,    40,  1500,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcVect,    "",MFC_13, 6000,    12,    12,   100,    12,   455,     0,  1000,    12,    40,  1500,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcVect,    "",MFC_13, 6000,    12,    39,   100,    12,   455,     0,  1000,    12,    40,  1500,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcVect,    "",MFC_13, 6000,    12,    26,   100,    12,   455,     0,  1000,    12,    40,  1500,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcVect,    "",MFC_13, 6000,    12,    13,   100,    12,   455,     0,  1000,    12,    40,  1500,    "",    ""));
// test different active state number
printf("%s\n",Fake_Decoder_Test (calcVect,HMM_36,MFC_13, 6000,     4,    36,   100,    12,   455,     0,  1000,    12,    40,  2000,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcVect,HMM_36,MFC_13, 6000,     4,    36,   100,    12,   455,     0,  1000,    12,    40,  1500,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcVect,HMM_36,MFC_13, 6000,     4,    36,   100,    12,   455,     0,  1000,    12,    40,  1000,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcVect,HMM_36,MFC_13, 6000,     4,    36,   100,    12,   455,     0,  1000,    12,    40,   500,    "",    ""));
// test different state activity intervals
printf("%s\n",Fake_Decoder_Test (calcVect,HMM_36,MFC_13, 6000,     4,    36,   100,    12,   455,     0,  1000,    12,   100,  1000,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcVect,HMM_36,MFC_13, 6000,     4,    36,   100,    12,   455,     0,  1000,    12,    40,  1000,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcVect,HMM_36,MFC_13, 6000,     4,    36,   100,    12,   455,     0,  1000,    12,    10,  1000,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcVect,HMM_36,MFC_13, 6000,     4,    36,   100,    12,   455,     0,  1000,    12,     2,  1000,    "",    ""));
// test different state number
printf("%s\n",Fake_Decoder_Test (calcVect,    "",    "",  6000,    12,    39,   100,    12,   455,     0,  1000,    12,   100,   500,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcVect,    "",    "",  3000,    12,    39,   100,    12,   455,     0,  1000,    12,   100,   500,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcVect,    "",    "",  1000,    12,    39,   100,    12,   455,     0,  1000,    12,   100,   500,    "",    ""));
printf("%s\n",Fake_Decoder_Test (calcVect,    "",    "",   500,    12,    39,   100,    12,   455,     0,  1000,    12,   100,   500,    "",    ""));*/
    break;
       case 1:
// arguments                    ( hint   ,paramf, featf,mixnum,gaussn,dimens,calcmx,calcmn,framen, delay,cachel,veclen,actlen,avrmix,problog,featlog)
printf("\n verification of vector calculation\n");
printf("%s\n",Fake_Decoder_Test (calcVect,HMM_36,MFC_13,     6000,     4,    36,   100,    12,   455,     0,  1000,    12,    40,  1000,"../data/prob_36.log",""));
       break;
       case 2:
printf("\n verification of mixture calculation\n");
printf("%s\n",Fake_Decoder_Test (calcMix ,HMM_36,MFC_13,     6000,     4,    36,   100,    12,   455,     0,  1000,    12,    40,  1000,"../data/prob_36.log",""));
       break;
       case 3:
printf("\n verification of multimix vector calculation\n");
printf("%s\n",Fake_Decoder_Test (calcMMix ,HMM_36,MFC_13,     6000,     4,    36,   100,    12,   455,     0,  1000,    12,    40,  1000,"../data/prob_36.log",""));
       break;
       case 4:
printf("\n verification of vecmax calculation\n");
printf("%s\n",Fake_Decoder_Test (calcVecM,HMM_36,MFC_13,     6000,     4,    36,   100,    12,   455,     0,  1000,    12,    40,  1000,"../data/prob_36.log",""));
       break;
    default:
      printf("Algorithm isn't define");
    break;
   }


   if(num_err>0){
       printf("\n There were an %d errors during this run. See output above. \n",num_err);
   }
   return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -