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

📄 headapt.c

📁 隐马尔科夫模型工具箱
💻 C
📖 第 1 页 / 共 2 页
字号:
/* ----------------------------------------------------------- *//*                                                             *//*                          ___                                *//*                       |_| | |_/   SPEECH                    *//*                       | | | | \   RECOGNITION               *//*                       =========   SOFTWARE                  */ /*                                                             *//*                                                             *//* ----------------------------------------------------------- *//* developed at:                                               *//*                                                             *//*      Speech Vision and Robotics group                       *//*      Cambridge University Engineering Department            *//*      http://svr-www.eng.cam.ac.uk/                          *//*                                                             *//*      Entropic Cambridge Research Laboratory                 *//*      (now part of Microsoft)                                *//*                                                             *//* ----------------------------------------------------------- *//*         Copyright: Microsoft Corporation                    *//*          1995-2000 Redmond, Washington USA                  *//*                    http://www.microsoft.com                 *//*                                                             *//*              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: HEAdapt.c: Adaptation Tool                *//* ----------------------------------------------------------- */char *headapt_version = "!HVER!HEAdapt:   3.2 [CUED 09/12/02]";char *headapt_vc_id = "$Id: HEAdapt.c,v 1.10 2002/12/19 16:37:40 ge204 Exp $";#include "HShell.h"     /* HMM ToolKit Modules */#include "HMem.h"#include "HMath.h"#include "HSigP.h"#include "HAudio.h"#include "HWave.h"#include "HVQ.h"#include "HParm.h"#include "HLabel.h"#include "HModel.h"#include "HTrain.h"#include "HUtil.h"#include "HAdapt.h"#include "HFB.h"/* Trace Flags */#define T_TOP   0001    /* Top level tracing */#define T_MAP   0002    /* logical/physical hmm map */Boolean traceHFB = FALSE;        /* pass to HFB to retain top-level tracing *//* Global Settings */static char * labDir = NULL;      /* label (transcription) file directory */static char * labExt = "lab";     /* label file extension */static char * hmmDir = NULL;      /* directory to look for hmm def files */static char * hmmExt = NULL;      /* hmm def file extension */static char * newDir = NULL;      /* directory to store new hmm def files */static char * newExt = NULL;      /* extension of new reestimated hmm files */static char * saveTransFN=NULL;   /* stats file, if any */static char * uid ="unknown";     /* temporary uid */static char * uname ="Unknown";   /* temporary uname */static char * chan ="Standard";   /* temporary mic channel name */static char * desc ="None";       /* temporary description to save in tmf */static char * transFile = NULL;   /* file holding transformations */static int blocks=0;              /* number of block diagonal matrices */static RegClassType regClass=ADPTUNDEF;/* regClass type to be used */static RegTransType regTrans=TRANSUNDEF;/* reg transform type to be used */static float minVar  = 0.0;       /* minimum variance (diagonal only) */static float occThresh=0.0;       /* Regression tree ocupation count minimum */static int update    = 0;         /* update trans every "update" utterances */static int trace     = 0;         /* Trace level */static Boolean saveBinary=FALSE;  /* save output in binary  */static FileFormat dff=UNDEFF;     /* data file format */static FileFormat lff=UNDEFF;     /* label file format *//* Global Data Structures - valid for all training utterances */static LogDouble pruneInit = NOPRUNE;    /* pruning threshold initially */static LogDouble pruneInc = 0.0;         /* pruning threshold increment */static LogDouble pruneLim = NOPRUNE;     /* pruning threshold limit */static float minFrwdP = 10.0;    /* mix prune threshold */static float tau         = 15.0;    /* scaling for MAP adaptation */static Boolean map       = FALSE;   /* do MAP adaptation */static Boolean mapUseMLLR= FALSE;   /* do MAP + MLLR adaptation */static Boolean global    = FALSE;   /* do global adaptation only */static Boolean firstTime = TRUE;    /* Flag used to enable creation of ot */static Boolean twoDataFiles = FALSE; /* Enables creation of ot2 for FB                                        training using two data files */static Vector vFloor[SMAX]; /* variance floor - default is all zero */static LogDouble totalPr=0.0;   /* total log prob upto current utterance */static int totalT=0;            /* total number of frames in training data */static MemHeap hmmStack;   /*For Storage of all dynamic structures created...*/static MemHeap uttStack;static MemHeap regStack;static MemHeap fbInfoStack;/* ------------------ Process Command Line -------------------------- */   /* SetConfParms: set conf parms relevant to HCompV  */void SetConfParms(void){   int i;   Boolean b;   ConfParam *cParm[MAXGLOBS];/* configuration parameters */   int nParm = 0;             /* total num params */      nParm = GetConfig("HEADAPT", TRUE, cParm, MAXGLOBS);   if (nParm>0) {      if (GetConfInt(cParm,nParm,"TRACE",&i)) trace = i;      if (GetConfBool(cParm,nParm,"SAVEBINARY",&b)) saveBinary = b;   }}void ReportUsage(void){   printf("\nUSAGE: HEAdapt [options] hmmList dataFiles...\n\n");   printf(" Option                                       Default\n\n");   printf(" -b N    set no. of blocks for transform      1\n");   printf(" -c f    Mixture pruning threshold            10.0\n");   printf(" -d s    dir to find hmm definitions          current\n");   printf(" -f s1 s2  Save s2 for field s1 in tmf        defaults saved\n");   printf(" -g      do global adaptation only            reg classes\n");   printf(" -i N    update the transforms every N utts   static\n");   printf(" -j f    Map adaptation with scaling factor   off\n");   printf(" -k      Use MLLR before performing MAP       off\n");   printf(" -m f    occ count min. to calc transform     700.0\n");   printf(" -o s    extension for new hmm files          as src\n");   printf(" -t f [i l] set pruning to f [inc limit]      inf\n");   printf(" -u [mv] update means(m) vars(v)              means\n");   printf(" -v f    set minimum variance to f            0.0\n");   printf(" -x s    extension for hmm files              none\n");   PrintStdOpts("BFGHIJKLMSTX");   printf("\n\n");}void SetuFlags(void){   char *s;   Boolean meanFlag=FALSE;      s=GetStrArg();   while (*s != '\0')      switch (*s++) {      case 'm':         meanFlag = TRUE;         if (regTrans == TRANSUNDEF)            regTrans=MEANONLY;         break;      case 'v':regTrans=MEANVAR;break;      default: HError(2720,"SetuFlags: Unknown update flag %c",*s);         break;      }   if (!meanFlag)      HError(-2721,"SetuFlags: Mean transformation will be updated, even though unrequestred");}int main(int argc, char *argv[]){   int numUtt;   char fmt[MAXSTRLEN];   char *datafn, *s, *c;   UttInfo *utt;            /* utterance information storage */   RegTransInfo *rt;        /* regression transform information storage */   HMMSet hset;             /* Set of HMMs to be re-estimated */   FBInfo *fbInfo;          /* forward-backward information storage */   void Initialise(FBInfo *fbInfo, MemHeap *x, HMMSet *hset,                   char *hmmListFn, RegTransInfo *rt, char *transFile);   void DoForwardBackward(FBInfo *fbInfo, UttInfo *utt, char *datafn, char *datafn2);      if(InitShell(argc,argv,headapt_version,headapt_vc_id)<SUCCESS)      HError(2700,"HEAdapt: InitShell failed");   InitMem();   InitMath();   InitSigP();   InitAudio();   InitWave();   InitVQ();   InitModel();   if(InitParm()<SUCCESS)        HError(2700,"HEAdapt: InitParm failed");    InitLabel();   InitTrain();   InitUtil();   InitFB();   InitAdapt();     if (!InfoPrinted() && NumArgs() == 0)      ReportUsage();   if (NumArgs() == 0) Exit(0);   SetConfParms();   CreateHeap(&hmmStack,"HmmStore", MSTAK, 1, 1.0, 50000, 500000);   CreateHMMSet(&hset,&hmmStack,TRUE);   CreateHeap(&uttStack,   "uttStore",    MSTAK, 1, 0.5, 100,   1000);   utt = (UttInfo *) New(&uttStack, sizeof(UttInfo));   CreateHeap(&fbInfoStack,   "FBInfoStore",  MSTAK, 1, 0.5, 1000,  10000);   fbInfo = (FBInfo *) New(&fbInfoStack, sizeof(FBInfo));   CreateHeap(&regStack,   "regClassStore",    MSTAK, 1, 0.5, 500,   5000);   rt = (RegTransInfo *) New(&regStack, sizeof(RegTransInfo));   while (NextArg() == SWITCHARG) {          s = GetSwtArg();      if (strlen(s)!=1)          HError(2719,"HEAdapt: Bad switch %s; must be single letter",s);      switch(s[0]){      case 'b':         if (NextArg()!= INTARG)            HError(2719,"HEAdapt: Number of blocks in transform matrix expected");         blocks = GetIntArg(); break;       case 'c':         minFrwdP = GetChkedFlt(0.0,1000.0,s);         break;      case 'd':         if (NextArg()!=STRINGARG)            HError(2719,"HEAdapt: HMM definition directory expected");         hmmDir = GetStrArg(); break;         case 'f':         if (NextArg()!=STRINGARG)            HError(2719,"HEAdapt: TMF description type expected");         strcpy(fmt,GetStrArg());         for (c=fmt; *c!=0; *c++=toupper(*c));         if (strcmp(fmt,"UID")==0) {            if (NextArg()!=STRINGARG)               HError(2719,"HEAdapt: user id string expected");            uid = GetStrArg();         }         else if (strcmp(fmt,"UNAME")==0) {            if (NextArg()!=STRINGARG)               HError(2719,"HEAdapt: user name string expected");            uname = GetStrArg();         }         else if (strcmp(fmt,"CHAN")==0) {            if (NextArg()!=STRINGARG)

⌨️ 快捷键说明

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