/* 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); }
/* 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->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); }
/* SetConfParms: set conf parms relevant to HSmooth */ void SetConfParms(void) { int i; Boolean b; nParm = GetConfig("HSMOOTH", TRUE, cParm, MAXGLOBS); if (nParm>0) { if (GetConfInt(cParm,nParm,"TRACE",&i)) trace = i; if (GetConfBool(cParm,nParm,"SAVEBINARY",&b)) saveBinary = b; if (GetConfBool(cParm,nParm,"BINARYACCFORMAT",&b)) ldBinary = b; } }
#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 */
/* 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; } }
// 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); } }
/* EXPORT->InitLM: initialise configuration parameters */ void InitLM(void) { Boolean b; int i; Register(hlm_version,hlm_vc_id); nParm = GetConfig("HLM", TRUE, cParm, MAXGLOBS); if (nParm>0){ if (GetConfInt(cParm,nParm,"TRACE",&i)) trace = i; if (GetConfBool(cParm,nParm,"RAWMITFORMAT",&b)) rawMITFormat = b; } }
static void SetConfParms(void) { int s, i, nParm; char *c, buf[MAXSTRLEN], tmp[MAXSTRLEN]; Boolean b; for (s = 1; s < SMAX; s++) winFn[s] = NULL; nParm = GetConfig("HMGETOOL", TRUE, cParm, MAXGLOBS); if (nParm > 0) { if (GetConfInt(cParm, nParm, "TRACE", &i)) trace = i; if (GetConfBool(cParm, nParm, "SAVEBINARY", &b)) inBinary = b; if (GetConfStr(cParm, nParm, "PDFSTRSIZE", buf)) nPdfStr = ParseConfIntVec(&gstack, buf, TRUE); if (GetConfStr(cParm, nParm, "PDFSTRORDER", buf)) pdfStrOrder = ParseConfIntVec(&gstack, buf, TRUE); if (GetConfStr(cParm, nParm, "MGETRNFLAG", buf)) pbMTrn = ParseConfIntVec(&gstack, buf, TRUE); if (GetConfStr(cParm, nParm, "GVTRNFLAG", buf)) pbGVTrn = ParseConfIntVec(&gstack, buf, TRUE); if (GetConfStr(cParm, nParm, "ACCERRFLAG", buf)) pbAccErr = ParseConfIntVec(&gstack, buf, TRUE); if (GetConfStr(cParm, nParm, "INVQUASIZE", buf)) pnInvQuaSize = ParseConfIntVec(&gstack, buf, TRUE); if (GetConfStr(cParm, nParm, "VARWINSIZE", buf)) pnVarWin = ParseConfIntVec(&gstack, buf, TRUE); if (GetConfStr(cParm, nParm, "GVDISTWGHT", buf)) pfGVWght = ParseConfVector(&gstack, buf, TRUE); if (GetConfStr(cParm, nParm, "GAINWTFLAG", buf)) pbGainWght = ParseConfIntVec(&gstack, buf, TRUE); if (GetConfStr(cParm, nParm, "WINEXT", buf)) winExt = CopyString(&gstack, buf); if (GetConfStr(cParm, nParm, "WINDIR", buf)) winDir = CopyString(&gstack, buf); if (GetConfStr(cParm, nParm, "WINFN", buf)) { for (s = 1, c = buf; s < SMAX && c != NULL; s++) { winFn[s] = ParseConfStrVec(&gstack, c, FALSE); for (i = 1; i <= winFn[s][0][0] + 2; i++) /* "StrVec" + "n" + # of file names */ c = ParseString(c, tmp); if (ParseString(c, tmp) == NULL) break; } } } }
/* EXPORT->InitMem: Initialise the module. */ void InitMem(void) { int i; Boolean b; Register(hmem_version, hmem_vc_id); CreateHeap(&gstack, "Global Stack", MSTAK, 1, 0.0, 100000, ULONG_MAX ); /* #### should be max size_t */ CreateHeap(&gcheap, "Global C Heap", CHEAP, 1, 0.0, 0, 0 ); numParm = GetConfig("HMEM", TRUE, cParm, MAXGLOBS); if (numParm>0){ if (GetConfInt(cParm,numParm,"TRACE",&i)) trace = i; if (GetConfBool(cParm,numParm,"PROTECTSTAKS",&b)) protectStaks = b; } }
void SetConfParms(void) { int s, i; char *c, buf[MAXSTRLEN], tmp[MAXSTRLEN]; Boolean b; for (s = 1; s < SMAX; s++) winFn[s] = NULL; nParm = GetConfig("HMGENS", TRUE, cParm, MAXGLOBS); if (nParm > 0) { if (GetConfInt(cParm, nParm, "TRACE", &i)) trace = i; if (GetConfBool(cParm, nParm, "SAVEBINARY", &b)) inBinary = b; if (GetConfBool(cParm, nParm, "OUTPDF", &b)) outPdf = b; if (GetConfInt(cParm, nParm, "PARMGENTYPE", &i)) type = (ParmGenType) i; if (GetConfBool(cParm, nParm, "MODELALIGN", &b)) modelAlign = b; if (GetConfBool(cParm, nParm, "STATEALIGN", &b)) stateAlign = b; if (GetConfBool(cParm, nParm, "USEALIGN", &b)) useAlign = b; if (GetConfBool(cParm, nParm, "USEHMMFB", &b)) useHMMFB = b; if (GetConfStr(cParm, nParm, "INXFORMMASK", buf)) xfInfo_hmm.inSpkrPat = xfInfo_dur.inSpkrPat = CopyString(&genStack, buf); if (GetConfStr(cParm, nParm, "PAXFORMMASK", buf)) xfInfo_hmm.paSpkrPat = xfInfo_dur.paSpkrPat = CopyString(&genStack, buf); if (GetConfStr(cParm, nParm, "PDFSTRSIZE", buf)) nPdfStr = ParseConfIntVec(&gstack, buf, TRUE); if (GetConfStr(cParm, nParm, "PDFSTRORDER", buf)) pdfStrOrder = ParseConfIntVec(&gstack, buf, TRUE); if (GetConfStr(cParm, nParm, "PDFSTREXT", buf)) pdfStrExt = ParseConfStrVec(&gstack, buf, TRUE); if (GetConfStr(cParm, nParm, "WINEXT", buf)) winExt = CopyString(&gstack, buf); if (GetConfStr(cParm, nParm, "WINDIR", buf)) winDir = CopyString(&gstack, buf); if (GetConfStr(cParm, nParm, "WINFN", buf)) { for (s = 1, c = buf; s < SMAX && c != NULL; s++) { winFn[s] = ParseConfStrVec(&gstack, c, FALSE); for (i = 1; i <= winFn[s][0][0] + 2; i++) /* "StrVec" + "n" + # of file names */ c = ParseString(c, tmp); if (ParseString(c, tmp) == NULL) break; } } } }
/* EXPORT->InitMap: initialise configuration parameters */ void InitMap(void) { int i; double f; Boolean b; 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; applyVFloor = TRUE; } if (GetConfFlt(cParm,nParm,"MAPTAU",&f)) mapTau = f; if (GetConfBool(cParm,nParm,"APPLYVFLOOR",&b)) applyVFloor = b; if (GetConfFlt(cParm,nParm,"MIXWEIGHTFLOOR",&f)) mixWeightFloor = MINMIX*f; } }
/* SetConfParms: set conf parms relevant to this tool */ void SetConfParms(void) { int i; Boolean b; char buf[MAXSTRLEN]; nParm = GetConfig("HVITE", TRUE, cParm, MAXGLOBS); if (nParm>0){ if (GetConfInt(cParm,nParm,"TRACE",&i)) trace = i; if (GetConfStr(cParm,nParm,"RECOUTPREFIX",buf)) roPrefix=CopyString(&gstack,buf); if (GetConfStr(cParm,nParm,"RECOUTSUFFIX",buf)) roSuffix=CopyString(&gstack,buf); if (GetConfBool(cParm,nParm,"SAVEBINARY",&b)) saveBinary = b; if (GetConfStr(cParm,nParm,"LABFILEMASK",buf)) { labFileMask = CopyString(&gstack, buf); } } }
/* SetConfParms: set conf parms relevant to this tool */ void SetConfParmsHCopy(void) { int i; Boolean b; char buf[MAXSTRLEN]; nParm = GetConfig("HCOPY", TRUE, cParm, MAXGLOBS); if (nParm>0){ if (GetConfInt(cParm,nParm,"TRACE",&i)) trace = i; if (GetConfBool(cParm,nParm,"SAVEASVQ",&b)) saveAsVQ = b; if (GetConfInt(cParm,nParm,"NSTREAMS",&i)) swidth0 = i; if (GetConfStr(cParm,nParm,"SOURCEFORMAT",buf)) srcFF = Str2Format(buf); if (GetConfStr(cParm,nParm,"TARGETFORMAT",buf)) tgtFF = Str2Format(buf); if (GetConfStr(cParm,nParm,"SOURCEKIND",buf)) srcPK = Str2ParmKind(buf); if (GetConfStr(cParm,nParm,"TARGETKIND",buf)) { tgtPK = Str2ParmKind(buf); if (tgtPK&HASNULLE) HError(1019, "SetConfParms: incompatible TARGETKIND=%s for coding", buf); } } }