backtrellis.c
来自「julius version 4.12.about sound recognit」· C语言 代码 · 共 589 行 · 第 1/2 页
C
589 行
/** * @file backtrellis.c * * <JA> * @brief 帽胳トレリスの瘦赂ˇ徊救 * * 妈1パスの冯蔡を帽胳トレリスとして瘦赂し·妈2パスで徊救するための簇眶凡 * です. Julius では·妈1パスで玫瑚面に姜眉が栏き荒っていた帽胳は链て· * その幌姜眉フレ〖ム·幌眉からの芜姥锑刨および帽胳旺悟とともに * 瘦赂され·妈2パスでその礁圭の面から浩玫瑚が乖われます. * この妈1パスでフレ〖ムごとに荒される帽胳攫鼠のことを≈トレリス帽胳∽· * トレリス帽胳の礁圭链挛を≈帽胳トレリス∽と钙びます. * * トレリス帽胳は·妈1パスの千急面に称フレ〖ムごとに瘦赂されます. * 妈1パス姜位稿·トレリス链挛の腊妨ˇ浩芹弥とフレ〖ムごとのインデックス * を侯喇します. * * 妈2パスでは·この帽胳トレリスを徊救して * 称箕粗∈掐蜗フレ〖ム∷における鸥倡材墙な簿棱のリストを评るとともに· * その妈1パスでの(稿ろ羹きの)芜姥锑刨を·妈2パスにおける簿棱の踏鸥倡婶尸の * 夸年スコアとして脱います. このしくみから·帽胳トレリスは≈バックトレリス∽ * とも钙ばれています. * </JA> * * <EN> * @brief Word trellis operations * * Functions to store the result of the 1st pass as "word trellis", * and functions to access them from the 2nd pass are defined in this * file. On the 1st pass of Julius, all the promising words whose * word end has been survived at the 1st pass will be stored as "word * trellis", which consists of surviving words: word boundary, * accumulated score and word history. * * The trellis word will be stored per frame at the 1st pass. After * the 1st pass ended, the word trellis will be re-organized and * indexed by frame to prepare for access at the 2nd pass. * * In the 2nd pass of reverse stack decoding, this word trellis will be * used to constrain the word hypothesis, and also used to estimate * the score of unseen area by the obtained backward scores in the 1st pass. * Thus the word trellis information is also called as "back trellis" in * Julius. * </EN> * * @author Akinobu LEE * @date Tue Feb 22 15:40:01 2005 * * $Revision: 1.2 $ * *//* * Copyright (c) 1991-2007 Kawahara Lab., Kyoto University * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology * Copyright (c) 2005-2007 Julius project team, Nagoya Institute of Technology * All rights reserved */#include <julius/julius.h>/** * <JA> * 帽胳トレリスを瘦积する 帽胳トレリス 菇陇挛を介袋步する(弹瓢箕に1搀だけ悸乖) * * @param bt [in] 介袋步する 帽胳トレリス 菇陇挛へのポインタ * </JA> * <EN> * Initialize backtrellis that will hold the whole word trellis * (called once on startup). * * @param bt [in] pointer to the backtrellis structure to initialize * </EN> * * @callergraph * @callgraph * */voidbt_init(BACKTRELLIS *bt){ bt->num = NULL; bt->rw = NULL; bt->list = NULL; bt->root = NULL;}/** * <JA> * 肌搀の千急脱に 帽胳トレリス 菇陇挛を洁洒する (千急倡幌箕ごとに悸乖). * * @param bt [in] 滦据とする帽胳トレリス菇陇挛へのポインタ * </JA> * <EN> * Prepare backtrellis for the next input (called at beginning of each * speech segment). * * @param bt [in] pointer to the word trellis structure * </EN> * @callergraph * @callgraph * */voidbt_prepare(BACKTRELLIS *bt){ /* free previously allocated data */ mybfree2(&(bt->root)); /* reset entry point */ bt->num = NULL; bt->rw = NULL; bt->list = NULL; bt->root = NULL;} /** * <EN> * Free memories of backtrellis. * </EN> * <JA> * 帽胳トレリスのメモリを倡庶する. * </JA> * * @param bt [out] pointer to the word trellis structure. * * @callergraph * @callgraph * */voidbt_free(BACKTRELLIS *bt){ if (bt->root) mybfree2(&(bt->root)); free(bt);}/** * <EN> * Allocate a new trellis word atom. * </EN> * <JA> * トレリス帽胳を糠たに充り烧ける. * </JA> * * @param bt [out] pointer to the word trellis structure. * * @return pointer to the newly allocated trellis word. * * @callergraph * @callgraph * */TRELLIS_ATOM *bt_new(BACKTRELLIS *bt){ TRELLIS_ATOM *new; new = (TRELLIS_ATOM *)mybmalloc2(sizeof(TRELLIS_ATOM), &(bt->root)); return new;}/** * <JA> * 妈1パスで叫附したトレリス帽胳∈帽胳姜眉のトレリス攫鼠∷を呈羌する. * * ここでは呈羌だけ乖い·妈1パス姜位稿に bt_relocate_rw() で * フレ〖ム界に浩芹弥する. * * @param bt [i/o] トレリス帽胳を呈羌するバックトレリス菇陇挛 * @param tatom [in] 叫附したトレリス帽胳へのポインタ * </JA> * <EN> * Store a trellis word generated on the 1st pass for the 2nd pass. * * This function just store the new atom into backtrellis. * They will be re-located per frame after 1st pass for quick access * in the 2nd pass. * * @param bt [i/o] backtrellis structure to store the trellis word * @param tatom [in] the trellis word to be stored * </EN> * * @callergraph * @callgraph * */voidbt_store(BACKTRELLIS *bt, TRELLIS_ATOM *tatom){#ifdef WORD_GRAPH tatom->within_context = FALSE; tatom->within_wordgraph = FALSE;#endif tatom->next = bt->list; bt->list = tatom;}/** * <JA> * 妈1パス姜位稿, 呈羌された帽胳トレリス攫鼠をフレ〖ム界に浩芹弥する. * * @param bt [i/o] 帽胳トレリス菇陇挛 * </JA> * <EN> * Re-locate the stored atom lists per frame (will be called after the * 1st pass). * * @param bt [i/o] word trellis structure * </EN> * * @callergraph * @callgraph * */voidbt_relocate_rw(BACKTRELLIS *bt){ TRELLIS_ATOM *tre; int t; int totalnum, n; TRELLIS_ATOM **tmp; if (bt->framelen == 0) { bt->num = NULL; return; } bt->num = (int *)mybmalloc2(sizeof(int) * bt->framelen, &(bt->root)); /* count number of trellis atom (= survived word end) for each frame */ for (t=0;t<bt->framelen;t++) bt->num[t] = 0; totalnum = 0; for (tre=bt->list;tre;tre=tre->next) { /* the last frame (when triggered from sp to non-sp) should be discarded */ if (tre->endtime >= bt->framelen) continue; bt->num[tre->endtime]++; totalnum++; } /* if no atom found, return here with all bt->num[t] set to 0 */ if (totalnum <= 0) { bt->num = NULL; return; } /* allocate area */ bt->rw = (TRELLIS_ATOM ***)mybmalloc2(sizeof(TRELLIS_ATOM **) * bt->framelen, &(bt->root)); tmp = (TRELLIS_ATOM **)mybmalloc2(sizeof(TRELLIS_ATOM *) * totalnum, &(bt->root)); n = 0; for (t=0;t<bt->framelen;t++) { if (bt->num[t] > 0) { bt->rw[t] = (TRELLIS_ATOM **)&(tmp[n]); n += bt->num[t]; } } /* then store the atoms */ for (t=0;t<bt->framelen;t++) bt->num[t] = 0; for (tre=bt->list;tre;tre=tre->next) { /* the last frame (when triggered from sp to non-sp) should be discarded */ if (tre->endtime >= bt->framelen) continue; t = tre->endtime; bt->rw[t][bt->num[t]] = tre; bt->num[t]++; }}/* 笆布の簇眶は bt_relocate_rw 悸乖稿にのみ蝗脱材墙となる. *//* functions below this line should be called after bt_relocate_rw() *//** * <JA> * 绵肌デコ〖ディング箕, 妈1パス姜位稿に· * 掐蜗セグメントの尉眉に荒った呵锑帽胳簿棱を艰り叫し, それらを * 妈2パスにおける介袋/呵姜簿棱としてセットする. * * @param r [in] 千急借妄インスタンス * </JA> * <EN> * When using progressive decoding with short pause segmentation, * This function extracts the best word hypothesis on head and tail of * the current input segment just after the 1st pass ends, * and store them as start/end word in the following 2nd pass. * * @param r [in] recognition process instance * </EN> * * @callergraph * @callgraph * */voidset_terminal_words(RecogProcess *r)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?