main_astar.c
来自「CMU大名鼎鼎的SPHINX-3大词汇量连续语音识别系统」· C语言 代码 · 共 497 行 · 第 1/2 页
C
497 行
/* ==================================================================== * Copyright (c) 1995-2004 Carnegie Mellon University. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * This work was supported in part by funding from the Defense Advanced * Research Projects Agency and the National Science Foundation of the * United States of America, and the CMU Sphinx Speech Consortium. * * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * ==================================================================== * *//* * main_astar.c -- Driver for N-best list creation from DAGs using A* algorithm. * * ********************************************** * CMU ARPA Speech Project * * Copyright (c) 1996 Carnegie Mellon University. * ALL RIGHTS RESERVED. * ********************************************** * * HISTORY * * $Log: main_astar.c,v $ * Revision 1.9 2004/12/06 11:31:47 arthchan2003 * Fix brief comments for programs. * * Revision 1.8 2004/12/06 11:15:11 arthchan2003 * Enable doxygen in the program directory. * * Revision 1.7 2004/12/05 12:01:32 arthchan2003 * 1, move libutil/libutil.h to s3types.h, seems to me not very nice to have it in every files. 2, Remove warning messages of main_align.c 3, Remove warning messages in chgCase.c * * Revision 1.6 2004/12/02 18:24:42 dhdfu * Remove some compiler warnings * * Revision 1.5 2004/11/16 05:53:10 arthchan2003 * small warning problems in main_astar.c * * Revision 1.4 2004/11/16 05:13:19 arthchan2003 * 1, s3cipid_t is upgraded to int16 because we need that, I already check that there are no magic code using 8-bit s3cipid_t * 2, Refactor the ep code and put a lot of stuffs into fe.c (should be renamed to something else. * 3, Check-in codes of wave2feat and cepview. (cepview will not dump core but Evandro will kill me) * 4, Make the same command line frontends for decode, align, dag, astar, allphone, decode_anytopo and ep . Allow the use a file to configure the application. * 5, Make changes in test such that test-allphone becomes a repeatability test. * 6, cepview, wave2feat and decode_anytopo will not be installed in 3.5 RCIII * (Known bugs after this commit) * 1, decode_anytopo has strange bugs in some situations that it cannot find the end of the lattice. This is urgent. * 2, default argument file's mechanism is not yet supported, we need to fix it. * 3, the bug discovered by SonicFoundry is still not fixed. * * Revision 1.3 2004/10/07 22:46:26 dhdfu * Fix compiler warnings that are also real bugs (but why does this * function take an int32 when -lw is a float parameter?) * * Revision 1.2 2004/09/13 08:13:28 arthchan2003 * update copyright notice from 200x to 2004 * * Revision 1.1 2004/08/09 05:15:23 arthchan2003 * incorporate s3.0 astar * * * 26-Jun-2004 ARCHAN (archan@cs.cmu.edu) at Carnegie Mellon Unversity * First incorporate it from CarlQ's patch. * * Revision 1.1 2003/02/12 16:30:42 cbq * A simple n-best program for sphinx. * * Revision 1.1 2000/04/24 09:39:41 lenzo * s3 import. * * * 31-Oct-1997 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University * Added compound words handling option. Compound words are broken up * into component words for computing LM probabilities. * * 08-Sep-97 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University * Added .Z compression option to lattice and nbest files. * * 22-Nov-96 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University * Added -maxedge argument to control memory usage. * Added -maxlmop and -maxlpf options to control execution time. * Added -maxppath option to control CPU/memory usage. * * 05-Nov-96 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University * Added -dagfudge and -min_endfr parameter handling. * * 29-Oct-96 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University * Created from nbest-main.c *//** \file main_astar.c * \brief Driver for N-best list creation from DAGs using A* algorithm. */#include <stdio.h>#include <stdlib.h>#include <string.h>#if (! WIN32)#include <unistd.h>#endif#include <assert.h>#include <s3types.h>#include <logs3.h>#include <tmat.h>#include <mdef.h>#include <dict.h>#include <lm.h>#include <fillpen.h>#include <search.h>#include <hyp.h>#include <wid.h>static mdef_t *mdef; /* Model definition */static s3wid_t startwid, finishwid, silwid;static ptmr_t tm_utt; /* Entire utterance */extern dict_t *dict; /* The dictionary */extern lm_t *lm; /* The lm. */extern fillpen_t *fpen; /* The filler penalty structure. */extern s3lmwid_t *dict2lmwid; /* Mapping from decoding dictionary wid's to lm ones. They may not be the same! */void nbest_search (char *filename, char *uttid);int32 s3astar_dag_load (char *file);int32 dag_destroy ( void );void nbest_init ( void );/* * Command line arguments. */static arg_t defn[] = { { "-logbase", ARG_FLOAT32, "1.0003", "Base in which all log values calculated" }, { "-lminmemory", ARG_INT32, "0", "Load language model into memory (default: use disk cache for lm"}, { "-log3table", ARG_INT32, "1", "Determines whether to use the log3 table or to compute the values at run time."}, { "-mdef", ARG_STRING, NULL, "Model definition input file: triphone -> senones/tmat tying" }, { "-dict", ARG_STRING, NULL, "Main pronunciation dictionary (lexicon) input file" }, { "-fdict", ARG_STRING, NULL, "Optional filler word (noise word) pronunciation dictionary input file" }, { "-compwd", ARG_INT32, "0", "Whether compound words should be broken up internally into component words" }, { "-lm", ARG_STRING, NULL, "Language model input file (precompiled .DMP file)" }, { "-lw", ARG_FLOAT32, "9.5", "Language weight: empirical exponent applied to LM probabilty" }, { "-ugwt", ARG_FLOAT32, "0.7", "LM unigram weight: unigram probs interpolated with uniform distribution with this weight" }, { "-inspen", ARG_FLOAT32, "0.65", "Word insertion penalty" }, { "-beam", ARG_FLOAT64, "1e-64", "Partial path pruned if below beam * score of best partial ppath so far" }, { "-silpen", ARG_FLOAT32, "0.1", "Language model 'probability' of silence word" }, { "-noisepen", ARG_FLOAT32, "0.05", "Language model 'probability' of each non-silence filler word" }, { "-fillpen", ARG_STRING, NULL, "Filler word probabilities input file (used in place of -silpen and -noisepen)" }, { "-maxlpf", ARG_INT32, "40000", "Max LMops/frame after which utterance aborted; controls CPU use (see maxlmop)" }, { "-maxlmop", ARG_INT32, "100000000", "Max LMops in utterance after which it is aborted; controls CPU use (see maxlpf)" }, { "-maxedge", ARG_INT32, "2000000", "Max DAG edges allowed in utterance; aborted if exceeded; controls memory usage" }, { "-maxppath", ARG_INT32, "1000000", "Max partial paths created after which utterance aborted; controls CPU/memory use" }, { "-ctl", ARG_STRING, NULL, "Input control file listing utterances to be decoded" }, { "-ctloffset", ARG_INT32, "0", "No. of utterances at the beginning of -ctl file to be skipped" }, { "-ctlcount", ARG_INT32, 0, "No. of utterances in -ctl file to be processed (after -ctloffset). Default: Until EOF" }, { "-inlatdir", ARG_STRING, NULL,
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?