@@ -34,7 +34,7 @@ static void create_mel_fbank(MFCC_STR *mfcc_struct)
3434 float mel_high_freq = MelScale (MEL_HIGH_FREQ );
3535 float left_mel , center_mel , right_mel , freq , mel , weight ;
3636 int32_t first_index ,last_index ;
37- float mel_freq_delta = (mel_high_freq - mel_low_freq ) / (NUM_FBANK_BINS + 1 ); //mel频率三角滤波器的步长
37+ float mel_freq_delta = (mel_high_freq - mel_low_freq ) / (NUM_FBANK_BINS + 1 ); //Step size of the Mel frequency delta filter
3838
3939 float * this_bin = (float * )malloc (sizeof (float )* num_fft_bins );
4040
@@ -96,7 +96,7 @@ int32_t mfcc_init(MFCC_STR *mfcc_str, int num_mfcc_features, int frame_len, int
9696 mfcc_str -> frame_len = frame_len ;
9797 mfcc_str -> mfcc_dec_bits = mfcc_dec_bits ;
9898
99- /* 需要填充的数据个数,填充至2的n次方,便于做FFT */
99+ /* The number of data to be filled, filled to the Nth power of 2, in order to do FFT */
100100 mfcc_str -> frame_len_padded = pow (2 ,ceil ((log (mfcc_str -> frame_len )/log (2 ))));
101101
102102 /* 大小为4kBytes */
@@ -107,39 +107,39 @@ int32_t mfcc_init(MFCC_STR *mfcc_str, int num_mfcc_features, int frame_len, int
107107 return -1 ;
108108 }
109109
110- /* 大小为4kBytes */
110+ /* the size is 4kBytes */
111111 mfcc_str -> buffer = (float * )malloc (2 * sizeof (float ) * mfcc_str -> frame_len_padded );
112112 if (mfcc_str -> buffer == NULL )
113113 {
114114 EMBARC_PRINTF ("The mfcc buffer malloc failed\r\n" );
115115 return -1 ;
116116 }
117117
118- /* 大小约为0 .16k */
118+ /* the size is about 0 .16k */
119119 mfcc_str -> mel_energies = (float * )malloc (sizeof (float ) * NUM_FBANK_BINS );
120120 if (mfcc_str -> mel_energies == NULL )
121121 {
122122 EMBARC_PRINTF ("The mfcc mel_energies malloc failed\r\n" );
123123 return -1 ;
124124 }
125125
126- /* 大小约为0 .16kBytes */
126+ /* the size is about 0 .16kBytes */
127127 mfcc_str -> fbank_filter_first = (int32_t * )malloc (sizeof (int32_t ) * NUM_FBANK_BINS );
128128 if (mfcc_str -> fbank_filter_first == NULL )
129129 {
130130 EMBARC_PRINTF ("The mfcc mel_energies malloc failed\r\n" );
131131 return -1 ;
132132 }
133133
134- /* 大小约为0 .16kBytes */
134+ /* the size is about 0 .16kBytes */
135135 mfcc_str -> fbank_filter_last = (int32_t * )malloc (sizeof (int32_t ) * NUM_FBANK_BINS );
136136 if (mfcc_str -> fbank_filter_last == NULL )
137137 {
138138 EMBARC_PRINTF ("The mfcc mel_energies malloc failed\r\n" );
139139 return -1 ;
140140 }
141141
142- /* 大小约为2 .5k */
142+ /* the size is about 2 .5k */
143143 mfcc_str -> window_func = (float * )malloc (sizeof (float ) * mfcc_str -> frame_len );
144144 if (mfcc_str -> window_func == NULL )
145145 {
@@ -186,34 +186,34 @@ void mfcc_compute(MFCC_STR *mfcc_str, const int16_t * audio_data, int8_t* mfcc_o
186186 float sum ;
187187 float first_energy , last_energy ;
188188
189- /* 临时变量 */
189+ /* Temporary variables */
190190 float * frame_tmp = mfcc_str -> frame ;
191191 float * buffer_tmp = mfcc_str -> buffer ;
192192 float * * mel_fbank_tmp = mfcc_str -> mel_fbank ;
193193 float * mel_energies_tmp = mfcc_str -> mel_energies ;
194194 float * dct_matrix_tmp = mfcc_str -> dct_matrix ;
195195
196- //将wav数据压缩到 (-1,1)
196+ //Compress wav data to (-1,1)
197197 for (i = 0 ; i < FRAME_LEN ; i ++ ) {
198198 frame_tmp [i ] = (float )audio_data [2 * i ] / (1 <<15 );
199199 }
200200
201- //FFT变换需要2的n次方,这里将多于一帧的数据点填充0
201+ //The FFT transform requires the Nth power of 2, datas here more than one frame are filled with zero
202202 memset (& frame_tmp [FRAME_LEN ], 0 , sizeof (float ) * (mfcc_str -> frame_len_padded - FRAME_LEN ));
203203
204204 for (i = 0 ; i < FRAME_LEN ; i ++ ) {
205205 frame_tmp [i ] *= mfcc_str -> window_func [i ];
206206 }
207207
208- //做傅里叶变换
208+ //FFT
209209 //arm_rfft_fast_f32(mfcc_str->rfft, frame_tmp, buffer_tmp, 0);
210210 memset (buffer_tmp , 0 , sizeof (float ) * 1024 * 2 );
211211 for (i = 0 ;i < 1024 ;i ++ )
212212 buffer_tmp [2 * i ] = frame_tmp [i ];
213213
214214 fftx ((Complex * )buffer_tmp , 10 );
215215
216- //获取各个频率分量的实际幅值
216+ //Get the actual amplitude of each frequency component
217217 //[real0, realN/2-1, real1, im1, real2, im2, ...]
218218 half_dim = mfcc_str -> frame_len_padded / 2 ;
219219 first_energy = buffer_tmp [0 ] * buffer_tmp [0 ];
@@ -227,7 +227,7 @@ void mfcc_compute(MFCC_STR *mfcc_str, const int16_t * audio_data, int8_t* mfcc_o
227227 buffer_tmp [0 ] = first_energy ;
228228 buffer_tmp [half_dim ] = last_energy ;
229229
230- //使用梅尔滤波器进行滤波
230+ //Filtering with a Mel filter
231231 for (bin = 0 ; bin < NUM_FBANK_BINS ; bin ++ )
232232 {
233233 j = 0 ;
@@ -241,16 +241,16 @@ void mfcc_compute(MFCC_STR *mfcc_str, const int16_t * audio_data, int8_t* mfcc_o
241241 }
242242 mel_energies_tmp [bin ] = mel_energy ;
243243
244- //这是为了下面去对数的时候不为0
244+ //Logarithm cannot be based on 0
245245 if (mel_energy == 0.0 )
246246 mel_energies_tmp [bin ] = FLT_MIN ;
247247 }
248248
249- //取对数
249+ //Logarithm
250250 for (bin = 0 ; bin < NUM_FBANK_BINS ; bin ++ )
251251 mel_energies_tmp [bin ] = logf (mel_energies_tmp [bin ]);
252252
253- //做离散余弦变换
253+ //DCT
254254 for (i = 0 ; i < NUM_MFCC_COEFFS ; i ++ )
255255 {
256256 sum = 0.0 ;
@@ -259,7 +259,7 @@ void mfcc_compute(MFCC_STR *mfcc_str, const int16_t * audio_data, int8_t* mfcc_o
259259 sum += dct_matrix_tmp [i * NUM_FBANK_BINS + j ] * mel_energies_tmp [j ];
260260 }
261261
262- //将MFCC特征量化为q7_t格式
262+ //Convert MFCC feature quantities to q7_t format
263263 sum *= (0x1 <<(mfcc_str -> mfcc_dec_bits ));
264264 sum = round (sum );
265265 if (sum >= 127 )
0 commit comments