Julius 4.2
|
00001 00048 /* 00049 * Copyright (c) 1991-2011 Kawahara Lab., Kyoto University 00050 * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology 00051 * Copyright (c) 2005-2011 Julius project team, Nagoya Institute of Technology 00052 * All rights reserved 00053 */ 00054 00055 #include <sent/stddefs.h> 00056 #include <sent/htk_param.h> 00057 #include <sent/mfcc.h> 00058 00060 #define IS_INVALID_FRAME_MFCC(A) ((A) < -30.0 || (A) > 30.0) 00061 00069 static int 00070 guess_abs_e_location(HTK_Param *param) 00071 { 00072 short qualtype; 00073 int basenum, abs_e_num; 00074 qualtype = param->header.samptype & ~(F_COMPRESS | F_CHECKSUM); 00075 qualtype &= ~(F_BASEMASK); 00076 basenum = guess_basenum(param, qualtype); 00077 if (qualtype & F_ENERGY) { 00078 if (qualtype & F_ZEROTH) { 00079 abs_e_num = basenum + 1; 00080 } else { 00081 abs_e_num = basenum; 00082 } 00083 } else { 00084 /* absolute energy not included */ 00085 jlog("Stat: strip_mfcc: absolute energy coef. not exist, stripping disabled\n"); 00086 abs_e_num = -1; 00087 } 00088 return abs_e_num; 00089 } 00090 00098 boolean 00099 param_strip_zero(HTK_Param *param) 00100 { 00101 unsigned int src,dst; 00102 int eloc; 00103 00104 /* guess where the absolute energy coefficient is */ 00105 eloc = guess_abs_e_location(param); 00106 if ((eloc = guess_abs_e_location(param)) < 0) return FALSE; 00107 00108 /* guess the invalid range... */ 00109 dst = 0; 00110 for(src=0;src<param->samplenum;src++) { 00111 if (IS_INVALID_FRAME_MFCC(param->parvec[src][eloc])) { 00112 jlog("Warning: strip_mfcc: frame %d has invalid energy, stripped\n", src); 00113 continue; 00114 } 00115 if (src != dst) { 00116 memcpy(param->parvec[dst], param->parvec[src], sizeof(VECT) * param->veclen); 00117 } 00118 dst++; 00119 } 00120 if (dst != param->samplenum) { 00121 jlog("Warning: strip_mfcc: input shrinked from %d to %d frames\n", param->samplenum, dst); 00122 param->header.samplenum = param->samplenum = dst; 00123 } 00124 00125 return TRUE; 00126 } 00127