📄 gauss_main.cpp
字号:
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);
stat_calc.len=0;
stat_calc.nums=NULL;
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);
calc->Get_Statistics(&stat_calc);
delete dec;
delete cache;
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==calcVecS)?" select":
" 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);
if((hint==calcVecS)&&(stat_calc.all!=0))
printf("Calculated gaussians %8d from %8d (%d%%)\n",stat_calc.lost,stat_calc.all,stat_calc.lost*100/stat_calc.all);
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 *HMM_WW="../data/hmm_ww.param";
char *HMM_WW_BIG="../data/hmm_ww_big.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, Selection, CodeBookSize, Num Clusters, Threshold, NumVec, Is Row fill)
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", "", 88, 1, 1.3f, 0, false));
break;
case 0:
// arguments ( hint ,paramf, featf,mixnum,gaussn,dimens,calcmx,calcmn,framen, delay,cachel,veclen,actlen,avrmix,problog,featlog, CodeBookSize, Num Clusters, Threshold, NumVec, Is Row fill)
// test different models and feature files
printf("%s\n",Fake_Decoder_Test (calcVect,HMM_36,MFC_13, 6000, 4, 36, 100, 12, 455, 0, 1000, 12, 40, 1000, "", "", 88, 1, 1.3f, 0, false));
printf("%s\n",Fake_Decoder_Test (calcVecS,HMM_36,MFC_13, 6000, 4, 36, 100, 12, 455, 0, 1000, 12, 40, 1000, "", "", 88, 1, 1.3f, 0, false));
printf("%s\n",Fake_Decoder_Test (calcVecS,HMM_36,MFC_13, 6000, 4, 36, 100, 12, 455, 0, 1000, 12, 40, 1000, "", "", 88, 1, 1.3f, 1, false));
printf("%s\n",Fake_Decoder_Test (calcVecS,HMM_36,MFC_13, 6000, 4, 36, 100, 12, 455, 0, 1000, 12, 40, 1000, "", "", 88, 1, 1.3f, 2, false));
printf("%s\n",Fake_Decoder_Test (calcVecS,HMM_36,MFC_13, 6000, 4, 36, 100, 12, 455, 0, 1000, 12, 40, 1000, "", "", 88, 1, 1.3f, 3, false));
printf("%s\n",Fake_Decoder_Test (calcVecS,HMM_36,MFC_13, 6000, 4, 36, 100, 12, 455, 0, 1000, 12, 40, 1000, "", "", 88, 1, 1.3f, 4, false));
printf("%s\n",Fake_Decoder_Test (calcVecS,HMM_36,MFC_13, 6000, 4, 36, 100, 12, 455, 0, 1000, 12, 40, 1000, "", "", 88, 2, 1.3f, 0, false));
printf("%s\n",Fake_Decoder_Test (calcVecS,HMM_36,MFC_13, 6000, 4, 36, 100, 12, 455, 0, 1000, 12, 40, 1000, "", "", 88, 4, 1.3f, 0, false));
printf("%s\n",Fake_Decoder_Test (calcVecS,HMM_36,MFC_13, 6000, 4, 36, 100, 12, 455, 0, 1000, 12, 40, 1000, "", "", 88, 8, 1.3f, 0, false));
printf("%s\n",Fake_Decoder_Test (calcVecS,HMM_36,MFC_13, 6000, 4, 36, 100, 12, 455, 0, 1000, 12, 40, 1000, "", "", 88, 16, 1.3f, 0, false));
printf("%s\n",Fake_Decoder_Test (calcVecS,HMM_36,MFC_13, 6000, 4, 36, 100, 12, 455, 0, 1000, 12, 40, 1000, "", "", 88, 32, 1.3f, 0, false));
printf("%s\n",Fake_Decoder_Test (calcVecS,HMM_36,MFC_13, 6000, 4, 36, 100, 12, 455, 0, 1000, 12, 40, 1000, "", "", 88, 64, 1.3f, 0, false));
printf("%s\n",Fake_Decoder_Test (calcVecS,HMM_36,MFC_13, 6000, 4, 36, 100, 12, 455, 0, 1000, 12, 40, 1000, "", "", 88, 1, 0.7f, 4, false));
break;
case 1:
// arguments ( hint ,paramf, featf,mixnum,gaussn,dimens,calcmx,calcmn,framen, delay,cachel,veclen,actlen,avrmix,problog,featlog, Selection, CodeBookSize, Num Clusters, Threshold, NumVec, Is Row fill)
printf("\n verification of vector calculation without select\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", "", 88, 1, 1.3f, 0, false));
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", "", 88, 1, 1.3f, 0, false));
break;
case 3:
printf("\n verification of vector calculation with select with full search and column fill\n");
printf("%s\n",Fake_Decoder_Test (calcVecS,HMM_36,MFC_13, 6000, 4, 36, 100, 12, 455, 0, 1000, 12, 40, 1000, "../data/prob_36.log", "", 88, 88, 1.3f, 0, false));
break;
case 4:
printf("\n verification of vector calculation with select with row fill\n");
printf("%s\n",Fake_Decoder_Test (calcVecS,HMM_36,MFC_13, 6000, 4, 36, 100, 12, 455, 0, 1000, 12, 40, 1000, "../data/prob_36.log", "", 88, 1, 0.0f, 4, true));
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 + -