int16 const * acmod_score(acmod_t *acmod, int *inout_frame_idx) { int frame_idx, feat_idx; /* Calculate the absolute frame index to be scored. */ frame_idx = calc_frame_idx(acmod, inout_frame_idx); /* If all senones are being computed, or we are using a senone file, then we can reuse existing scores. */ if ((acmod->compallsen || acmod->insenfh) && frame_idx == acmod->senscr_frame) { if (inout_frame_idx) *inout_frame_idx = frame_idx; return acmod->senone_scores; } /* Calculate position of requested frame in circular buffer. */ if ((feat_idx = calc_feat_idx(acmod, frame_idx)) < 0) return NULL; /* If there is an input senone file locate the appropriate frame and read it. */ if (acmod->insenfh) { fseek(acmod->insenfh, acmod->framepos[feat_idx], SEEK_SET); if (acmod_read_scores_internal(acmod) < 0) return NULL; } else { /* Build active senone list. */ acmod_flags2list(acmod); /* Generate scores for the next available frame */ ps_mgau_frame_eval(acmod->mgau, acmod->senone_scores, acmod->senone_active, acmod->n_senone_active, acmod->feat_buf[feat_idx], frame_idx, acmod->compallsen); } if (inout_frame_idx) *inout_frame_idx = frame_idx; acmod->senscr_frame = frame_idx; /* Dump scores to the senone dump file if one exists. */ if (acmod->senfh) { if (acmod_write_scores(acmod, acmod->n_senone_active, acmod->senone_active, acmod->senone_scores, acmod->senfh) < 0) return NULL; E_DEBUG(1,("Frame %d has %d active states\n", frame_idx, acmod->n_senone_active)); } return acmod->senone_scores; }
int16 const * acmod_score(acmod_t *acmod, int frame_idx) { /* Obtain the frame to be scored. */ if (featbuf_consumer_wait(acmod->fb, frame_idx, 0, acmod->feat_buf[0][0]) < 0) return NULL; /* Build active senone list. */ acmod_flags2list(acmod); /* Generate scores for the next available frame */ ps_mgau_frame_eval(acmod->mgau, acmod->senone_scores, acmod->senone_active, acmod->n_senone_active, acmod->feat_buf[0], frame_idx, acmod->compallsen); return acmod->senone_scores; }