⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hlrescore.c

📁 该压缩包为最新版htk的源代码,htk是现在比较流行的语音处理软件,请有兴趣的朋友下载使用
💻 C
📖 第 1 页 / 共 2 页
字号:
/* ----------------------------------------------------------- *//*                                                             *//*                          ___                                *//*                       |_| | |_/   SPEECH                    *//*                       | | | | \   RECOGNITION               *//*                       =========   SOFTWARE                  */ /*                                                             *//*                                                             *//* ----------------------------------------------------------- *//* developed at:                                               *//*                                                             *//*      Speech Vision and Robotics group                       *//*      Cambridge University Engineering Department            *//*      http://svr-www.eng.cam.ac.uk/                          *//*                                                             *//* author: Gunnar Evermann <ge204@eng.cam.ac.uk>               *//* ----------------------------------------------------------- *//*         Copyright:                                          *//*         2001-2002  Cambridge University                     *//*                    Engineering Department                   *//*                                                             *//*   Use of this software is governed by a License Agreement   *//*    ** See the file License for the Conditions of Use  **    *//*    **     This banner notice must not be removed      **    *//*                                                             *//* ----------------------------------------------------------- *//*       File: HLRescore.c: Lattice rescoring/pruning          *//* ----------------------------------------------------------- *//*#### todo:     - implement lattice oracle WER calculation     - allow batch processing?*/char *hlrescore_version = "!HVER!HLRescore:   3.3 [CUED 28/04/05]";char *hlrescore_vc_id = "$Id: HLRescore.c,v 1.1.1.1 2005/05/12 10:52:54 jal58 Exp $";#include "HShell.h"#include "HMem.h"#include "HMath.h"#include "HWave.h"#include "HLabel.h"#include "HAudio.h"#include "HParm.h"#include "HModel.h"#include "HUtil.h"#include "HDict.h"#include "HNet.h"#include "HRec.h"#include "HLM.h"#include "HLat.h"/* -------------------------- Trace Flags & Vars ------------------------ */#define T_TOP  00001      /* Basic progress reporting */#define T_TRAN 00002      /* Output transcriptions */#define T_LAT  00004      /* Lattice I/O */#define T_MEM  00010      /* Memory usage, start and finish */static int trace = 0;/* ---------------- Configuration Parameters --------------------- */static ConfParam *cParm[MAXGLOBS];static int nParm = 0;            /* total num params *//* -------------------------- Global Variables etc ---------------------- */static char *dictfn;		/* dict filename from commandline */static char *latInDir = NULL;   /* Lattice input dir, set by -L  */static char *latInExt = "lat";  /* Lattice Extension, set by -X */static FileFormat ofmt=UNDEFF;  /* Label output file format */static char *labOutDir = NULL;  /* output label file directory */static char *labOutExt = "rec"; /* output label file extension */static char *labOutForm = NULL; /* output label format */static char *latOutForm = NULL; /* output lattice format */static double lmScale = 1.0;    /* LM scale factor */static double acScale = 1.0;    /* acoustic scale factor */static LogDouble wordPen = 0.0; /* inter word log penalty */static double prScale = 1.0;    /* pronunciation scale factor */static Boolean fixPronprobs = FALSE; /* get pron probs from dict */static char *lmFile = NULL;     /* LM filename */static LModel *lm;              /* LM for expandin lattices */static Vocab vocab;		/* wordlist or dictionary */static char *startWord;         /* word at start of Lattice (!SENT_START) */static char *endWord;           /* word at end of Lattice (!SENT_END) */static char *startLMWord;       /* word at start in LM (<s>) */static char *endLMWord;         /* word at end in LM (</s>) */static Boolean fixBadLats = FALSE;         /* fix final word in lattices */static Boolean sortLattice = TRUE;         /* sort lattice nodes by time & posterior */static LogDouble pruneInThresh = - LZERO;  /* beam for pruning (-t) */static LogDouble pruneOutThresh = - LZERO; /* beam for pruning (-u) */static LogDouble pruneInArcsPerSec = 0.0;  /* arcs per second threshold (-t) */static LogDouble pruneOutArcsPerSec = 0.0; /* arcs per second threshold (-u) *//* operations to perform: */static Boolean pruneInLat = FALSE;  /* -t */static Boolean writeLat = FALSE;    /* -w */static Boolean expandLat = FALSE;   /* -n */static Boolean pruneOutLat = FALSE; /* -u */static Boolean findBest = FALSE;    /* -f */static Boolean calcStats = FALSE;   /* -c *//* -------------------------- Heaps ------------------------------------- */static MemHeap latHeap;static MemHeap lmHeap;static MemHeap transHeap;/* -------------------------- Prototypes -------------------------------- */void SetConfParms (void);void ReportUsage (void);void ProcessLattice (char *latfn);/* ---------------- Process Command Line ------------------------- *//* SetConfParms: set conf parms relevant to this tool */void SetConfParms(void){   int i;   char buf[MAXSTRLEN];   Boolean b;   nParm = GetConfig ("HLRESCORE", TRUE, cParm, MAXGLOBS);   if (nParm>0){      if (GetConfInt (cParm, nParm, "TRACE", &i)) trace = i;      if (GetConfStr (cParm, nParm, "STARTWORD", buf))         startWord = CopyString (&gstack, buf);      if (GetConfStr (cParm, nParm, "ENDWORD", buf))         endWord = CopyString (&gstack, buf);      if (GetConfStr (cParm, nParm, "STARTLMWORD", buf))         startLMWord = CopyString (&gstack, buf);      if (GetConfStr (cParm, nParm, "ENDLMWORD", buf))         endLMWord = CopyString (&gstack, buf);      if (GetConfBool (cParm, nParm, "FIXBADLATS", &b)) fixBadLats = b;      if (GetConfBool (cParm, nParm, "SORTLATTICE", &b)) sortLattice = b;   }}void ReportUsage(void){   printf("\nUSAGE: HLRescore [options] vocabFile Files...\n\n");   printf(" Option                                   Default\n\n");   printf(" -i s    Output transcriptions to MLF s       off\n");    printf(" -l s    dir to store label/lattice files     current\n");   printf(" -n s    load n-gram LM and expand lattice    off\n");   printf(" -o s    output label formating NCSTWMX       none\n");   printf(" -t f [f] input lattice pruning threshold     off\n");   printf(" -u f [f] output lattice pruning threshold    off\n");   printf(" -p f    inter model trans penalty (log)      0.0\n");   printf(" -s f    grammar scale factor                 1.0\n");   printf(" -a f    acoustic scale factor                1.0\n");   printf(" -r f    pronunciation scale factor           1.0\n");   printf(" -d      get pronprobs from dict              off\n");   printf(" -c      calculate statistics                 off\n");   printf(" -f      find 1-best transcription            off\n");   printf(" -w      write output lattices                off\n");   printf(" -q s    output lattice format                tvaldmnr\n");    printf(" -y s    output label file extension          rec\n");   PrintStdOpts("ILSXTGP");   printf("\n\n");}int main(int argc, char *argv[]){   char *s, *latfn;   /*#### new error code range */   if(InitShell (argc, argv, hlrescore_version, hlrescore_vc_id) < SUCCESS)      HError (4000, "HLRescore: InitShell failed");     InitMem();   InitMath();   InitWave();   InitLabel();   InitAudio();   if (InitParm()<SUCCESS)       HError(4000,"HLRescore: InitParm failed");   InitModel();   InitUtil();   InitDict();   InitNet();    InitRec();   InitLM();   InitLat();   if (!InfoPrinted() && NumArgs() == 0)      ReportUsage();   if (NumArgs() == 0) Exit(0);     SetConfParms();   while (NextArg() == SWITCHARG) {      s = GetSwtArg();      if (strlen(s) != 1)          HError (4019, "HLRescore: Bad switch %s; must be single letter",s);      switch (s[0]){      case 'L':         if (NextArg() != STRINGARG)            HError (4019,"HLRescore: Lattice file directory expected");         latInDir = GetStrArg();          break;      case 'X':         if (NextArg() != STRINGARG)            HError (4019, "HLRescore: Lattice filename extension expected");         latInExt = GetStrArg();          break;      case 'i':         if (NextArg() != STRINGARG)            HError (4019, "HLRescore: Output MLF file name expected");         if (SaveToMasterfile (GetStrArg()) < SUCCESS)            HError (4014, "HLRescore: Cannot write to MLF");         break;      case 'I':         if (NextArg() != STRINGARG)            HError (4019, "HLRescore: Input MLF file name expected");         LoadMasterFile (GetStrArg ());         break;      case 'P':         if (NextArg() != STRINGARG)            HError (4019, "HLRescore: Output Label File format expected");         if((ofmt = Str2Format (GetStrArg ())) == ALIEN)            HError (-4089, "HLRescore: Warning ALIEN Label output file format set");         break;      case 'q':	 if (NextArg () != STRINGARG)	    HError (4019, "HLRescore: Output lattice format expected");	 latOutForm = GetStrArg ();	 break;            case 'l':         if (NextArg() != STRINGARG)            HError (4019, "HLRescore: Output Label file directory expected");         labOutDir = GetStrArg();          break;      case 'o':         if (NextArg() != STRINGARG)            HError (4019, "HLRescore: Output label format expected");         labOutForm = GetStrArg();          break;      case 'y':         if (NextArg() != STRINGARG)            HError (4019, "HLRescore: Output label file extension expected");         labOutExt = GetStrArg(); break;      

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -