/* EXPORT->InitExactMPE: initialise configuration parameters */ void InitExactMPE(void) { int i; double f; Boolean b; Register(hexactmpe_version,hexactmpe_vc_id); nParm = GetConfig("HEXACTMPE", TRUE, cParm, MAXGLOBS); if (nParm>0){ if (GetConfInt(cParm,nParm,"PHONEBEAM",&i)) PHONE_BEAM = i; if (GetConfFlt(cParm,nParm,"EXACTCORRPRUNE",&f)) EXACTCORR_PRUNE = f; /*default: log(0.0002) = -8.5 */ } nParm = GetConfig("HFBLAT", TRUE, cParm, MAXGLOBS); if (nParm>0){ if (GetConfFlt(cParm,nParm,"LATPROBSCALE",&f)) latProbScale = f;/* repeat of config also used in HFBLat.c */ if (GetConfFlt(cParm,nParm,"PHNINSPEN",&f)) phnInsPen = f; /* repeat of config also used in HFBLat.c */ #ifdef SUPPORT_QUINPHONE if (GetConfBool(cParm,nParm,"QUINPHONE",&b)) Quinphone = b; /* repeat of config also used in HFBLat.c */ #endif if (GetConfBool(cParm,nParm,"PHONEMEE",&b)) PhoneMEE=b; /* repeat of config also used in HFBLat.c */ if (GetConfBool(cParm,nParm,"MWE",&b)) if(b) PhoneMEE=FALSE; /* this config also used in HFBLat.c */ if (GetConfFlt(cParm,nParm,"INSCORRECTNESS",&f)) InsCorrectness=-fabs(f); /* to make sure negative.*/ if (GetConfFlt(cParm,nParm,"SUBCORRECTNESS",&f)) SubCorrectness=-fabs(f); /* to make sure negative.*/ } }
/* EXPORT->InitLVRec: register module & set configuration parameters */ void InitLVRec(void) { double f; int i; Boolean b; Register (hlvrec_version, hlvrec_vc_id); nParm = GetConfig("HLVREC", TRUE, cParm, MAXGLOBS); if (nParm>0){ if (GetConfInt(cParm,nParm,"TRACE",&i)) trace = i; if (GetConfFlt (cParm, nParm, "MAXLMLA", &f)) maxLMLA = f; if (GetConfBool (cParm, nParm, "BUILDLATSENTEND",&b)) buildLatSE = b; if (GetConfBool (cParm, nParm, "FORCELATOUT",&b)) forceLatOut = b; if (GetConfInt (cParm, nParm,"GCFREQ", &i)) gcFreq = i; if (GetConfBool (cParm, nParm, "PDE",&b)) pde = b; if (GetConfBool (cParm, nParm, "USEOLDPRUNE",&b)) useOldPrune = b; if (GetConfBool (cParm, nParm, "MERGETOKONLY",&b)) mergeTokOnly = b; if (GetConfFlt (cParm, nParm, "MAXLNBEAMFLR", &f)) maxLNBeamFlr = f; if (GetConfFlt (cParm, nParm, "DYNBEAMINC", &f)) dynBeamInc = f; if (useOldPrune) { mergeTokOnly = FALSE; maxLNBeamFlr = 0.0; dynBeamInc = 1.1; } } #if 0 printf ("sizeof(Token) = %d\n", sizeof (Token)); printf ("sizeof(LexNodeInst) = %d\n", sizeof (LexNodeInst)); printf ("sizeof(WordendHyp) = %d\n\n", sizeof (WordendHyp)); #endif CreateHeap (&recCHeap, "Decoder CHEAP", CHEAP, 1, 1.5, 10000, 100000); }
/* EXPORT->InitArc: initialise configuration parameters */ void InitArc(void) { int i; double f; Register(arc_version,arc_vc_id); nParm = GetConfig("HARC", TRUE, cParm, MAXGLOBS); if (nParm>0){ if (GetConfInt(cParm,nParm,"TRACE",&i)) trace = i; /* Set TRACE=1 for minimal tracing, 3 for fuller tracing. */ if (GetConfFlt(cParm,nParm,"LMSCALE",&f)){ LMSCALE = f; IsLMScale = TRUE; } /* Overrides lattice-specified one. */ if (GetConfFlt(cParm,nParm,"FRAMEDUR",&f)){ FRAMEDUR = f; } /* Important. Frame duration in seconds. If != 0.01, specify it. */ if (GetConfFlt(cParm,nParm,"WDPEN",&f)){ WDPEN = f; IsWdPen = TRUE; } /* Overrides lattice-specified one. */ } }
/* EXPORT->InitLabel: initialise module */ void InitLabel(void) { int i; Boolean b; double d; char str[MAXSTRLEN]; Register(hlabel_version,hlabel_vc_id); CreateHeap(&namecellHeap,"namecellHeap",MSTAK,1,0.5,5000,20000); for (i=0;i<HASHSIZE;i++) hashtab[i] = NULL; CreateHeap(&mlfHeap,"mlfHeap",MSTAK,1,0.5,10000,50000); numParm = GetConfig("HLABEL", TRUE, cParm, MAXGLOBS); if (numParm>0){ if (GetConfInt(cParm,numParm,"TRACE",&i)) trace = i; if (GetConfBool(cParm,numParm,"STRIPTRIPHONES",&b)) stripTriPhones = b; if (GetConfBool(cParm,numParm,"V1COMPAT",&b)) compatMode = b; if (GetConfStr(cParm,numParm,"LABELSQUOTE",str)) labelQuote=str[0]; if (GetConfInt(cParm,numParm,"TRANSALT",&i)) transAlt = i; if (GetConfInt(cParm,numParm,"TRANSLEV",&i)) transLev = i; if (GetConfFlt(cParm,numParm,"HTKLABELTIMESCALE",&d)) htkLabelTimeScale = d; } }
/* EXPORT->InitMap: initialise configuration parameters */ void InitMap(void) { int i; double f; Register(hmap_version,hmap_vc_id); nParm = GetConfig("HMAP", TRUE, cParm, MAXGLOBS); if (nParm>0){ if (GetConfInt(cParm,nParm,"TRACE",&i)) trace = i; if (GetConfInt(cParm,nParm,"MINEGS",&i)) minEgs = i; if (GetConfFlt(cParm,nParm,"MINOBS",&f)) minObs = f; if (GetConfFlt(cParm,nParm,"MINVAR",&f)) minVar = f; if (GetConfFlt(cParm,nParm,"MAPTAU",&f)) mapTau = f; if (GetConfFlt(cParm,nParm,"MIXWEIGHTFLOOR",&f)) mixWeightFloor = MINMIX*f; } }
/* EXPORT->InitLVRec: register module & set configuration parameters */ void InitLVRec(void) { double f; int i; Boolean b; Register (hlvrec_version, hlvrec_vc_id); nParm = GetConfig("HLVREC", TRUE, cParm, MAXGLOBS); if (nParm>0){ if (GetConfInt(cParm,nParm,"TRACE",&i)) trace = i; if (GetConfFlt (cParm, nParm, "MAXLMLA", &f)) maxLMLA = f; if (GetConfBool (cParm, nParm, "BUILDLATSENTEND",&b)) buildLatSE = b; if (GetConfBool (cParm, nParm, "FORCELATOUT",&b)) forceLatOut = b; if (GetConfInt (cParm, nParm,"GCFREQ", &i)) gcFreq = i; if (GetConfBool (cParm, nParm, "PDE",&b)) pde = b; } #if 0 printf ("sizeof(Token) = %d\n", sizeof (Token)); printf ("sizeof(LexNodeInst) = %d\n", sizeof (LexNodeInst)); printf ("sizeof(WordendHyp) = %d\n\n", sizeof (WordendHyp)); #endif CreateHeap (&recCHeap, "Decoder CHEAP", CHEAP, 1, 1.5, 10000, 100000); }
// ARec constructor ARec::ARec(const string & name, ABuffer *inb, ABuffer *outb, ARMan *armgr, int nnToks) : AComponent(name,(HasRealConsole()?2:ARECPRBUFSIZE)) { ConfParam *cParm[MAXGLOBS]; /* config parameters */ int numParm; int i; double f; Boolean b; char buf[100]; in = inb; out = outb; rmgr = armgr; strcpy(buf,name.c_str()); for (i=0; i<int(strlen(buf)); i++) buf[i] = toupper(buf[i]); numParm = GetConfig(buf, TRUE, cParm, MAXGLOBS); trace=0; width = 400; height=120; showRD = FALSE; sampPeriod = 100000.0; stTime = 0.0; rdx0 = 420; rdy0 =280; runmode = RunMode(CONTINUOUS_MODE+FLUSH_TOMARK+STOP_ATMARK+RESULT_ATEND); runstate = WAIT_STATE; laststate = RunState(-1); nToks = nnToks; wordPen = 0.0; lmScale = 1.0; ngScale=0.0; prScale = 1.0; genBeam = nBeam = 225.0; wordBeam = 200.0; maxActive = 0; grpName = ""; trbakFreq = 5; outseqnum = 0; inlevel = -1; trbakFrame = 0; trbakAc = 0.0; trbakCount = 0; trbakLastWidth=0; nBest=0; if (numParm>0){ if (GetConfBool(cParm,numParm,"DISPSHOW",&b)) showRD = b; if (GetConfInt(cParm,numParm,"DISPXORIGIN",&i)) rdx0 = i; if (GetConfInt(cParm,numParm,"DISPYORIGIN",&i)) rdy0 = i; if (GetConfInt(cParm,numParm,"DISPWIDTH",&i)) width = i; if (GetConfInt(cParm,numParm,"DISPHEIGHT",&i)) height = i; if (GetConfInt(cParm,numParm,"RUNMODE",&i)) runmode = RunMode(i); if (GetConfInt(cParm,numParm,"NTOKS",&i)) nToks = i; if (GetConfFlt(cParm,numParm,"WORDPEN",&f)) wordPen = float(f); if (GetConfFlt(cParm,numParm,"LMSCALE",&f)) lmScale = float(f); if (GetConfFlt(cParm,numParm,"NGSCALE",&f)) ngScale = float(f); if (GetConfFlt(cParm,numParm,"PRSCALE",&f)) prScale = float(f); if (GetConfFlt(cParm,numParm,"GENBEAM",&f)) genBeam = float(f); if (GetConfFlt(cParm,numParm,"WORDBEAM",&f)) wordBeam = float(f); if (GetConfFlt(cParm,numParm,"NBEAM",&f)) nBeam = float(f); if (GetConfInt(cParm,numParm,"MAXBEAM",&i)) maxActive = i; if (GetConfStr(cParm,numParm,"GRPNAME",buf)) grpName=string(buf); if (GetConfInt(cParm,numParm,"TRBAKFREQ",&i)) trbakFreq = i; if (GetConfFlt(cParm,numParm,"TARGETRATE",&f)) sampPeriod = float(f); if (GetConfInt(cParm,numParm,"TRACE",&i)) trace = i; if (GetConfInt(cParm,numParm,"NBEST",&i)) nBest = i; } if (nBeam < genBeam) nBeam = genBeam; if ((runmode&RESULT_ASAP) || (runmode&RESULT_IMMED)) runmode = RunMode(runmode|RESULT_ATEND); if(nBest>0){ CreateHeap(&ansHeap,"Lattice heap",MSTAK,1,0.0,4000,4000); CreateHeap(&altHeap,"Lattice heap",MSTAK,1,0.0,4000,4000); } }
/* LoadSCRIBELabels: load a SCRIBE (SAM) label file - searches for first occurrence of a label symbol LBA - acoustic label LBB - broad class label UTS - utterance it loads this symbol and all subsequent labels of the same type. All other SAM label types are ignored */ static void LoadSCRIBELabels(MemHeap *x, Transcription *t, Source *src) { LabList *ll; LabId labid; HTime start,end; float score; ScribeLab ltype, lx; double sp; char buf[MAXSTRLEN]; if (!GetConfFlt(cParm,numParm,"SOURCERATE",&sp)) sp = 500.0; /* actual SCRIBE rate */ ll = CreateLabelList(x,0); AddLabelList(ll,t); InitTrScan(); do { /* search for first label */ ltype = GetScribeLab(src); if (ltype == S_EOF) HError(6554,"LoadSCRIBELabels: Unexpected EOF"); } while (ltype != S_LBB && ltype != S_LBA && ltype != S_UTS); do { /* load this and all subsequent ltype labels */ GetTrSym(src,FALSE); if (trSym != TRNUM) HError(6554,"LoadSCRIBELabels: Start Index expected [%d]\n",trSym); start = trNum * sp; GetTrSym(src,FALSE); if (trSym != TRCOMMA) HError(6554,"LoadSCRIBELabels: Comma expected [%d]\n",trSym); GetTrSym(src,FALSE); if (ltype == S_LBA || ltype == S_LBB) { /* LBB and LBA have a centre field */ if (trSym != TRCOMMA) HError(6554,"LoadSCRIBELabels: Comma expected [%d]\n",trSym); GetTrSym(src,FALSE); } if (trSym != TRNUM) HError(6554,"LoadSCRIBELabels: End Index expected [%d]\n",trSym); end = trNum * sp; GetTrSym(src,FALSE); if (trSym != TRCOMMA) HError(6554,"LoadSCRIBELabels: Comma expected [%d]\n",trSym); GetTrSym(src,FALSE); if (trSym != TRSTR) HError(6554,"LoadSCRIBELabels: Label expected [%d]\n",trSym); strcpy(buf,trStr); GetTrSym(src,FALSE); while (trSym == TRSTR){ strcat(buf,"_"); strcat(buf,trStr); GetTrSym(src,FALSE); } labid = GetLabId(buf,TRUE); score = 0.0; AddLabel(x,ll,labid,start,end,score); if (trSym != TREOL) HError(6554,"LoadSCRIBELabels: End of Line expected [%d]\n",trSym); lx = GetScribeLab(src); } while (lx != S_EOF); }
/* SetConfParms: set conf parms relevant to this tool */ void SetConfParms(void) { double d; int i; nParm = GetConfig("HLSTATS", TRUE, cParm, MAXGLOBS); if (nParm>0){ if (GetConfFlt(cParm,nParm,"DISCOUNT",&d)) disCount = d; if (GetConfInt(cParm,nParm,"TRACE",&i)) trace = i; } }
#define T_TOP 0001 /* Top level tracing */ #define T_MAP 0002 /* logical/physical hmm map */ #define T_UPD 0004 /* Model updates */ /* possible values of updateMode */ #define UPMODE_DUMP 1 #define UPMODE_UPDATE 2 #define UPMODE_BOTH 3 /* 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 * statFN; /* stats file, if any */ static float minVar = 0.0; /* minimum variance (diagonal only) */ static float mixWeightFloor=0.0; /* Floor for mixture weights */ static int minEgs = 3; /* min examples to train a model */ static UPDSet uFlags = (UPDSet) (UPMEANS|UPVARS|UPTRANS|UPMIXES); /* update flags */ static int parMode = -1; /* enable one of the // modes */ static Boolean stats = FALSE; /* enable statistics reports */ static char * mmfFn = NULL; /* output MMF file, if any */
#include "HAudio.h" #include "HWave.h" #include "HVQ.h" #include "HParm.h" #include "HLabel.h" #include "HModel.h"
/* SetConfParms: set conf parms relevant to HCompV */ static void SetConfParms(void) { Boolean b,c; int i; double d; nParm = GetConfig("HCOMPV", TRUE, cParm, MAXGLOBS); if (nParm>0) { if (GetConfInt(cParm,nParm,"TRACE",&i)) trace = i; if (GetConfBool(cParm,nParm,"UPDATEMEANS",&b)) meanUpdate = b; if (GetConfBool(cParm,nParm,"SAVEBINARY",&c)) saveBinary = c; if (GetConfFlt(cParm,nParm,"MINVARFLOOR",&d)) minVar = d; } }