glist_t srch_FLAT_FWD_bestpath_impl(void *srch, /**< A void pointer to a search structure */ dag_t * dag) { srch_t *s; srch_FLAT_FWD_graph_t *fwg; float32 bestpathlw; float64 lwf; srch_hyp_t *tmph, *bph; glist_t ghyp, rhyp; s = (srch_t *) srch; fwg = (srch_FLAT_FWD_graph_t *) s->grh->graph_struct; assert(fwg->lathist); bestpathlw = cmd_ln_float32_r(kbcore_config(fwg->kbcore), "-bestpathlw"); lwf = bestpathlw ? (bestpathlw / cmd_ln_float32_r(kbcore_config(fwg->kbcore), "-lw")) : 1.0; flat_fwd_dag_add_fudge_edges(fwg, dag, cmd_ln_int32_r(kbcore_config(fwg->kbcore), "-dagfudge"), cmd_ln_int32_r(kbcore_config(fwg->kbcore), "-min_endfr"), (void *) fwg->lathist, s->kbc->dict); /* Bypass filler nodes */ if (!dag->filler_removed) { /* If Viterbi search terminated in filler word coerce final DAG node to FINISH_WORD */ if (dict_filler_word(s->kbc->dict, dag->end->wid)) dag->end->wid = s->kbc->dict->finishwid; if (dag_bypass_filler_nodes(dag, lwf, s->kbc->dict, s->kbc->fillpen) < 0) E_ERROR("maxedge limit (%d) exceeded\n", dag->maxedge); else dag->filler_removed = 1; } bph = dag_search(dag, s->uttid, lwf, dag->end, s->kbc->dict, s->kbc->lmset->cur_lm, s->kbc->fillpen); if (bph != NULL) { ghyp = NULL; for (tmph = bph; tmph; tmph = tmph->next) ghyp = glist_add_ptr(ghyp, (void *) tmph); rhyp = glist_reverse(ghyp); return rhyp; } else { return NULL; } }
/* Decode the given mfc file and write result to matchfp and matchsegfp */ static void decode_utt (char *uttid, FILE *matchfp, FILE *matchsegfp) { char dagfile[1024]; hyp_t *h, *hyp; char *latdir, *latext; int32 nfrm, ascr, lscr; timing_reset (tm_utt); timing_start (tm_utt); latdir = (char *) cmd_ln_access ("-inlatdir"); latext = (char *) cmd_ln_access ("-latext"); if (latdir) sprintf (dagfile, "%s/%s.%s", latdir, uttid, latext); else sprintf (dagfile, "%s.%s", uttid, latext); if ((nfrm = dag_load (dagfile)) >= 0) { hyp = dag_search (uttid); if ( *((int32 *) cmd_ln_access("-backtrace")) ) log_hyp_detailed (stdout, hyp, uttid, "BP", "bp"); /* Total scaled acoustic score and LM score */ ascr = lscr = 0; for (h = hyp; h; h = h->next) { ascr += h->ascr; lscr += h->lscr; } printf ("BSTPTH: "); log_hypstr (stdout, hyp, uttid, ascr+lscr); printf ("BSTXCT: "); log_hypseg (uttid, stdout, hyp, nfrm); lm_cache_stats_dump (); lm_cache_reset (); } else { E_ERROR("DAG search (%s) failed\n", uttid); hyp = NULL; } /* Log recognition output to the standard match and matchseg files */ if (matchfp) log_hypstr (matchfp, hyp, uttid, 0); if (matchsegfp) log_hypseg (uttid, matchsegfp, hyp, nfrm); dag_destroy (); timing_stop (tm_utt); printf ("%s: TMR: %5d Frm", uttid, nfrm); if (nfrm > 0) { printf (" %6.2f xEl", tm_utt->t_elapsed * 100.0 / nfrm); printf (" %6.2f xCPU", tm_utt->t_cpu * 100.0 / nfrm); } printf ("\n"); fflush (stdout); tot_nfr += nfrm; }