@@ -254,24 +254,23 @@ static int tflm_process(struct processing_module *mod,
254254{
255255 struct tflm_comp_data * cd = module_get_private_data (mod );
256256 struct comp_dev * dev = mod -> dev ;
257- size_t frame_bytes = source_get_frame_bytes (sources [0 ]);
258- int features = source_get_data_frames_available (sources [0 ]);
257+ int features_available = source_get_data_frames_available (sources [0 ]);
259258 const void * data_ptr , * buf_start ;
260259 size_t buf_size ;
261- int ret ;
260+ int ret = 0 ;
262261
263262 comp_dbg (dev , "entry" );
264263
265- /* Window size is TFLM_FEATURE_ELEM_COUNT and we increment
266- * by TFLM_FEATURE_SIZE until buffer empty.
264+ /* Window size is TFLM_FEATURE_ELEM_COUNT (1960 bytes int8_t) and we increment
265+ * by TFLM_FEATURE_SIZE (40 bytes int8_t) until buffer empty.
267266 */
268- while (features >= TFLM_FEATURE_ELEM_COUNT ) {
269- ret = source_get_data (sources [0 ], TFLM_FEATURE_ELEM_COUNT * frame_bytes ,
267+ while (features_available >= TFLM_FEATURE_ELEM_COUNT ) {
268+ ret = source_get_data (sources [0 ], TFLM_FEATURE_ELEM_COUNT ,
270269 & data_ptr , & buf_start , & buf_size );
271270 if (ret )
272271 return ret ;
273272
274- cd -> tfc .audio_features = data_ptr ;
273+ cd -> tfc .audio_features = ( int8_t * ) data_ptr ;
275274 cd -> tfc .audio_data_size = TFLM_FEATURE_ELEM_COUNT ;
276275 ret = TF_ProcessClassify (& cd -> tfc );
277276 if (!ret ) {
@@ -281,7 +280,7 @@ static int tflm_process(struct processing_module *mod,
281280 return ret ;
282281 }
283282
284- /* debug - dump the output */
283+ /* Evaluate predictions */
285284 int max_idx = 0 ;
286285 float max_score = cd -> tfc .predictions [0 ];
287286
@@ -301,9 +300,9 @@ static int tflm_process(struct processing_module *mod,
301300 tflm_send_keyword_notification (mod , max_idx );
302301 }
303302
304- /* advance by one stride */
305- source_release_data (sources [0 ], TFLM_FEATURE_SIZE * frame_bytes );
306- features = source_get_data_frames_available (sources [0 ]);
303+ /* advance by one 20ms stride (40 int8_t features) */
304+ source_release_data (sources [0 ], TFLM_FEATURE_SIZE );
305+ features_available = source_get_data_frames_available (sources [0 ]);
307306 }
308307
309308 return ret ;
0 commit comments