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