diff options
author | lnetsch | 2013-10-14 14:26:59 -0500 |
---|---|---|
committer | lnetsch | 2013-10-14 14:26:59 -0500 |
commit | 52fab2d0be3cb65a3c99f8e12b0d1dfd8452fd72 (patch) | |
tree | 04a99a6b9922036771516e2b1d25fe949530fd7e | |
parent | beb5885a0d77eeb1bed19d4a7c3e353b0c5dbfff (diff) | |
download | tiesr-52fab2d0be3cb65a3c99f8e12b0d1dfd8452fd72.tar.gz tiesr-52fab2d0be3cb65a3c99f8e12b0d1dfd8452fd72.tar.xz tiesr-52fab2d0be3cb65a3c99f8e12b0d1dfd8452fd72.zip |
[#1451] Merge changes from C55 branch to expand frames search engine can handle to SHRT_MAX.
git-svn-id: https://gforge.ti.com/svn/tiesr/trunk@147 469fd053-429d-4955-9e4c-93c0d7a8ff27
-rwxr-xr-x | TIesrEngine/src/gmhmm_type_common.cpp | 10 | ||||
-rwxr-xr-x | TIesrEngine/src/jac-estm.cpp | 9 | ||||
-rwxr-xr-x | TIesrEngine/src/liveproc.cpp | 137 | ||||
-rwxr-xr-x | TIesrEngine/src/rapidsearch.cpp | 10 |
4 files changed, 96 insertions, 70 deletions
diff --git a/TIesrEngine/src/gmhmm_type_common.cpp b/TIesrEngine/src/gmhmm_type_common.cpp index 6ebd43b..d07b7a5 100755 --- a/TIesrEngine/src/gmhmm_type_common.cpp +++ b/TIesrEngine/src/gmhmm_type_common.cpp | |||
@@ -168,11 +168,15 @@ TIESRENGINECOREAPI_API short GetVolumeStatus(const gmhmm_type *gvv) | |||
168 | return (gvv)->vol; | 168 | return (gvv)->vol; |
169 | } | 169 | } |
170 | 170 | ||
171 | /* GMHMM_SI_API */ | 171 | /* GMHMM_SI_API */ |
172 | TIESRENGINECOREAPI_API short GetConfidenceScore(const gmhmm_type *gvv) | 172 | TIESRENGINECOREAPI_API short GetConfidenceScore( const gmhmm_type *gvv ) |
173 | { | 173 | { |
174 | #ifdef USE_CONFIDENCE | 174 | #ifdef USE_CONFIDENCE |
175 | return (gvv )->cm_score; | 175 | /* Return confidence score if cm_score calculated */ |
176 | if( gvv->pConf->bCalced ) | ||
177 | return (gvv)->cm_score; | ||
178 | else | ||
179 | return 0; | ||
176 | #else | 180 | #else |
177 | return 0; | 181 | return 0; |
178 | #endif | 182 | #endif |
diff --git a/TIesrEngine/src/jac-estm.cpp b/TIesrEngine/src/jac-estm.cpp index 826b15e..37de5d7 100755 --- a/TIesrEngine/src/jac-estm.cpp +++ b/TIesrEngine/src/jac-estm.cpp | |||
@@ -987,7 +987,14 @@ TIesrEngineJACStatusType JAC_update(gmhmm_type *gvv) | |||
987 | ushort frame_cnt[NBR_TRANSFO] /* total number of frames */; | 987 | ushort frame_cnt[NBR_TRANSFO] /* total number of frames */; |
988 | long temp[3*N_FILTER26]; | 988 | long temp[3*N_FILTER26]; |
989 | 989 | ||
990 | 990 | /* Can not do JAC_update if there was not enough memory to store mfcc vectors | |
991 | recognized. This test along with access to the stored vectors and counts | ||
992 | should be supplied outside of JAC_update to increase modularity. The | ||
993 | error condition is flagged as no alignment, since it is not possible to | ||
994 | do the alignment. */ | ||
995 | if( gv->frm_cnt > gv->max_frame_nbr ) | ||
996 | return eTIesrEngineJACNoAlignment; | ||
997 | |||
991 | //IF word based backtrace is used, do a forced alignment here. | 998 | //IF word based backtrace is used, do a forced alignment here. |
992 | if (gvv->word_backtrace==WORDBT) | 999 | if (gvv->word_backtrace==WORDBT) |
993 | { | 1000 | { |
diff --git a/TIesrEngine/src/liveproc.cpp b/TIesrEngine/src/liveproc.cpp index 7612ba5..ec503f3 100755 --- a/TIesrEngine/src/liveproc.cpp +++ b/TIesrEngine/src/liveproc.cpp | |||
@@ -201,101 +201,110 @@ MP_CallEachPass(short sig_frm[], gmhmm_type * gvv, Boolean bDoSearch) | |||
201 | 201 | ||
202 | 202 | ||
203 | 203 | ||
204 | if( gv->speech_detected && bDoSearch ) | 204 | /* Speech has been detected, do recognition */ |
205 | { | 205 | if( gv->speech_detected && bDoSearch ) |
206 | if( gv->frm_cnt < gv->max_frame_nbr ) | 206 | { |
207 | { | 207 | /* Check if frames processed above maximum. frm_cnt must always increase |
208 | /* several speech frames have already been detected, go back as far | 208 | for each frame processed by the recognizer. If frm_cnt has reached its |
209 | as possible in the circular buffer */ | 209 | maximum, then declare eTIesrEngineTimeOut */ |
210 | idx = circ_idx( gv->buf_idx - ( MFCC_BUF_SZ - 1 ) + REG_SPAN ); | 210 | if( gv->frm_cnt < SHRT_MAX ) |
211 | /* fprintf(pf, "speech = %d\n", signal_cnt - ( MFCC_BUF_SZ - 1 ) + REG_SPAN); */ | 211 | { |
212 | /* several speech frames have already been detected, go back as far | ||
213 | as possible in the circular buffer */ | ||
214 | idx = circ_idx( gv->buf_idx - ( MFCC_BUF_SZ - 1 ) + REG_SPAN ); | ||
215 | /* fprintf(pf, "speech = %d\n", signal_cnt - ( MFCC_BUF_SZ - 1 ) + REG_SPAN); */ | ||
212 | 216 | ||
213 | compute_regression( idx, 1, reg_mfcc, gv->n_mfcc, gv->muScaleP2, gv->mfcc_buf ); | 217 | /* Compute delta mfcc coefficients. Build feature vector for current frame*/ |
218 | compute_regression( idx, 1, reg_mfcc, gv->n_mfcc, gv->muScaleP2, gv->mfcc_buf ); | ||
214 | 219 | ||
215 | for( i = 0; i < gv->n_mfcc; i++ ) | 220 | for( i = 0; i < gv->n_mfcc; i++ ) |
216 | { | 221 | { |
217 | mfcc_feature[i] = gv->mfcc_buf[idx][i]; | 222 | mfcc_feature[i] = gv->mfcc_buf[idx][i]; |
218 | mfcc_feature[i + gv->n_mfcc] = reg_mfcc[i]; | 223 | mfcc_feature[i + gv->n_mfcc] = reg_mfcc[i]; |
219 | } | 224 | } |
220 | 225 | ||
221 | #if defined(USE_GAUSS_SELECT) || defined(USE_ORM_VAD) | 226 | #if defined(USE_GAUSS_SELECT) || defined(USE_ORM_VAD) |
222 | 227 | ||
223 | /* compute Gaussian cluster scores */ | 228 | /* compute Gaussian cluster scores */ |
224 | i = rj_clear_obs_scr( gv, mfcc_feature ); | 229 | i = rj_clear_obs_scr( gv, mfcc_feature ); |
225 | /* update scores from an on-line reference model */ | 230 | /* update scores from an on-line reference model */ |
226 | rj_update_noise( gv, mfcc_feature, i ); | 231 | rj_update_noise( gv, mfcc_feature, i ); |
227 | 232 | ||
228 | #if defined(USE_ORM_VAD) | 233 | #if defined(USE_ORM_VAD) |
229 | /* GMM-based VAD */ | 234 | /* GMM-based VAD. Retrieve and process all mfcc vectors available from |
230 | while( ( p_fea = rj_vad_proc( gv, mfcc_feature ) ) != NULL ) | 235 | storage buffer. */ |
231 | { | 236 | while( ( p_fea = rj_vad_proc( gv, mfcc_feature ) ) != NULL ) |
237 | { | ||
232 | #else | 238 | #else |
233 | { | 239 | { |
234 | #endif | 240 | #endif |
235 | 241 | ||
236 | #endif | 242 | #endif |
237 | 243 | ||
244 | /* Save feature vector for post-recognition adaptation and confidence | ||
245 | measure calculations if room is still available the the buffer. */ | ||
246 | if( gv->frm_cnt < gv->max_frame_nbr ) | ||
247 | { | ||
238 | #ifdef BIT8FEAT | 248 | #ifdef BIT8FEAT |
239 | if( gv->mem_feature ) | 249 | if( gv->mem_feature ) |
240 | vector_packing( p_fea, gv->mem_feature + gv->mfcc_cnt, gv->scale_feat, gv->n_mfcc ); | 250 | vector_packing( p_fea, gv->mem_feature + gv->mfcc_cnt, gv->scale_feat, gv->n_mfcc ); |
241 | #else | 251 | #else |
242 | 252 | ||
243 | // Store integer values of features during recognition | 253 | // Store integer values of features during recognition |
244 | // TODO: modify to handle static, delta, acc ... | 254 | // TODO: modify to handle static, delta, acc ... |
245 | if( gv->mem_feature ) | 255 | if( gv->mem_feature ) |
246 | { | 256 | { |
247 | int idx; | 257 | int idx; |
248 | short *featmem = (short*)gv->mem_feature + 2 * gv->mfcc_cnt; | 258 | short *featmem = (short*)gv->mem_feature + 2 * gv->mfcc_cnt; |
249 | for( idx = 0; idx < gv->nbr_dim; idx++ ) | 259 | for( idx = 0; idx < gv->nbr_dim; idx++ ) |
250 | { | 260 | { |
251 | featmem[idx] = p_fea[idx]; | 261 | featmem[idx] = p_fea[idx]; |
252 | } | 262 | } |
253 | } | 263 | } |
254 | #endif | 264 | #endif |
265 | /* Advance number of mfcc in buffer */ | ||
266 | gv->mfcc_cnt += gv->n_mfcc; | ||
267 | } | ||
255 | 268 | ||
269 | /* Run recognition search if requested. Must start with frm_cnt = 0 */ | ||
270 | a_status = (TIesrEngineStatusType)search_a_frame( p_fea, 1, gv->frm_cnt, gv ); | ||
271 | gv->frm_cnt++; | ||
256 | 272 | ||
257 | /* search needs frm_cnt to start with 0 */ | ||
258 | 273 | ||
259 | /* if (bDoSearch) */ | ||
260 | a_status = (TIesrEngineStatusType)search_a_frame( p_fea, 1, gv->frm_cnt, gv ); | ||
261 | gv->frm_cnt++; | ||
262 | /* gv->mfcc_cnt += gv->n_mfcc; */ | ||
263 | if( gv->frm_cnt < gv->max_frame_nbr ) | ||
264 | gv->mfcc_cnt += gv->n_mfcc; | ||
265 | 274 | ||
266 | 275 | ||
267 | 276 | ||
268 | #if defined(USE_GAUSS_SELECT) || defined(USE_ORM_VAD) | 277 | #if defined(USE_GAUSS_SELECT) || defined(USE_ORM_VAD) |
269 | } | 278 | } |
270 | #endif | 279 | #endif |
271 | 280 | ||
272 | } | 281 | } |
273 | 282 | ||
274 | else | 283 | else |
275 | /* Not allowed to do search, since the MFCC input frame buffer is full */ | 284 | /* Not allowed to do search, since frm_cnt has reached its maximum. */ |
276 | a_status = eTIesrEngineFeatureMemoryOut; | 285 | a_status = eTIesrEngineTimeOut; |
277 | } | 286 | } |
278 | 287 | ||
279 | 288 | ||
280 | /* Update input frame counter and MFCC circular buffer index */ | 289 | /* Update input frame counter and MFCC circular buffer index */ |
281 | if( gv->signal_cnt < USHRT_MAX - 1) | 290 | if( gv->signal_cnt < USHRT_MAX - 1 ) |
282 | ( gv->signal_cnt )++; | 291 | ( gv->signal_cnt )++; |
283 | 292 | ||
284 | gv->buf_idx = circ_idx( ++gv->buf_idx ); | 293 | gv->buf_idx = circ_idx( ++gv->buf_idx ); |
294 | |||
295 | |||
296 | /* Prepare overlap (WINDOW_LEN - FRAME_LEN) for next input frame */ | ||
297 | for( i = 0; i < OVERLAP; i++ ) | ||
298 | { | ||
299 | gv->sample_signal[ i ] = gv->sample_signal[ i + FRAME_LEN ]; | ||
285 | 300 | ||
286 | /* | ||
287 | if ( gv->signal_cnt > TIMEOUT) return eTIesrEngineTimeOut; | ||
288 | */ | ||
289 | |||
290 | /* Prepare overlap for next input frame */ | ||
291 | for (i = 0; i < OVERLAP /* WINDOW_LEN - FRAME_LEN */ ; i++) { | ||
292 | gv->sample_signal[ i ] = gv->sample_signal[ i + FRAME_LEN ]; | ||
293 | #ifdef USE_AUDIO | 301 | #ifdef USE_AUDIO |
294 | if (gv->sample_signal[i] > gv->amplitude_max) gv->amplitude_max = gv->sample_signal[i]; | 302 | if( gv->sample_signal[i] > gv->amplitude_max ) gv->amplitude_max = gv->sample_signal[i]; |
295 | else if (gv->sample_signal[i] < gv->amplitude_min) gv->amplitude_min = gv->sample_signal[i]; | 303 | else if( gv->sample_signal[i] < gv->amplitude_min ) gv->amplitude_min = gv->sample_signal[i]; |
296 | #endif | 304 | #endif |
297 | } | 305 | |
298 | return a_status; | 306 | } |
307 | return a_status; | ||
299 | } | 308 | } |
300 | 309 | ||
301 | /*--------------------------------------------------------------------------- | 310 | /*--------------------------------------------------------------------------- |
diff --git a/TIesrEngine/src/rapidsearch.cpp b/TIesrEngine/src/rapidsearch.cpp index 4ff695c..f875ea7 100755 --- a/TIesrEngine/src/rapidsearch.cpp +++ b/TIesrEngine/src/rapidsearch.cpp | |||
@@ -2057,11 +2057,17 @@ static void cm_update_logistic( short iTrue, short pCM, ConfType * pConf ) | |||
2057 | 2057 | ||
2058 | 2058 | ||
2059 | #ifdef USE_CONFIDENCE | 2059 | #ifdef USE_CONFIDENCE |
2060 | /* This function not currently used */ | ||
2060 | short cm_score(gmhmm_type *gv) | 2061 | short cm_score(gmhmm_type *gv) |
2061 | { | 2062 | { |
2062 | ConfType * pConf = (ConfType*) (gv->pConf); | 2063 | ConfType * pConf = (ConfType*) (gv->pConf); |
2063 | if (pConf->bCalced == FALSE) cm_update_status(gv); | 2064 | |
2064 | return gv->cm_score; | 2065 | /* At present can only update status if JAC_update was successfully called. */ |
2066 | if (pConf && pConf->bCalced == TRUE ) | ||
2067 | return gv->cm_score; | ||
2068 | else | ||
2069 | /* cm_update_status(gv); */ | ||
2070 | return 0; | ||
2065 | } | 2071 | } |
2066 | 2072 | ||
2067 | /* update confidence measure status */ | 2073 | /* update confidence measure status */ |