Example #1
0
void
vtln_alpha(Recog *recog, RecogProcess *r)
{
    Sentence *s;
    float alpha, alpha_bgn, alpha_end;
    float max_alpha;
    LOGPROB max_score;
    PROCESS_AM *am;
    MFCCCalc *mfcc;
    SentenceAlign *align;

    s = &(r->result.sent[0]);
    align = result_align_new();

    max_score = LOG_ZERO;

    printf("------------ begin VTLN -------------\n");

    mfcc = r->am->mfcc;

    alpha_bgn = mfcc->para->vtln_alpha - VTLN_RANGE;
    alpha_end = mfcc->para->vtln_alpha + VTLN_RANGE;

    for(alpha = alpha_bgn; alpha <= alpha_end; alpha += VTLN_STEP) {
        mfcc->para->vtln_alpha = alpha;
        if (InitFBank(mfcc->wrk, mfcc->para) == FALSE) {
            jlog("ERROR: VTLN: InitFBank() failed\n");
            return;
        }
        if (wav2mfcc(recog->speech, recog->speechlen, recog) == FALSE) {
            jlog("ERROR: VTLN: wav2mfcc() failed\n");
            return;
        }
        outprob_prepare(&(r->am->hmmwrk), mfcc->param->samplenum);
        word_align(s->word, s->word_num, mfcc->param, align, r);
        printf("%f: %f\n", alpha, align->allscore);
        if (max_score < align->allscore) {
            max_score = align->allscore;
            max_alpha = alpha;
        }
    }
    printf("MAX: %f: %f\n", max_alpha, max_score);
    mfcc->para->vtln_alpha = max_alpha;
    if (InitFBank(mfcc->wrk, mfcc->para) == FALSE) {
        jlog("ERROR: VTLN: InitFBank() failed\n");
        return;
    }

    printf("------------ end VTLN -------------\n");

    result_align_free(align);

}
void cTumkwsjSink::juAlignPass1Keywords(RecogProcess *r, HTK_Param *param)
{
//  int n;
  Sentence *s;
  SentenceAlign *now;//, *prev;


  s = &(r->result.pass1);
  /* do forced alignment if needed */
  if ((r->config->annotate.align_result_word_flag)&&(s->word_num>0)) {
    //now = result_align_new();
    //if (s->align == NULL) 
      now = result_align_new(); //else now = s->align;
    word_align(s->word, s->word_num, param, now, r);
    if (s->align == NULL) //result_align_free(s->align);
      s->align = now;
    else {
      result_align_free(s->align);
      s->align = now;
    }
//    else prev->next = now;
//    prev = now;
  }
}