/** * Opens the file for decoding. No need to call if this is actually a * sound device. */ void DecoderSingleTest::openSource(FrontEnd *frontend) { #ifdef HAVE_HTKLIB if (sHTKLib.mHTKLibSource) { char * datFN = GetStrArg(); if (sHModels) if (sHModels->useHAdapt) { UpdateSpkrStats( &(sHModels->hSet) , sHModels->xfInfo , datFN ); // if ( UpdateSpkrStats( &(frontend->HTKLIBModels->hSet) , frontend->HTKLIBModels->xfInfo , datFN ) // && (!(frontend->HTKLIBModels->xfInfo->useInXForm)) // && (frontend->HTKLIBModels->hSet.semiTied == NULL) ) // { // frontend->HTKLIBModels->xfInfo->inXForm = NULL; // } } frontend->SetSource(datFN); } else { #endif assert(dataFName); frontend->SetSource(dataFName, extStartFrame, extEndFrame); // This is a hack - should deal with them properly later. extStartFrame = -1; extEndFrame = -1; #ifdef HAVE_HTKLIB } #endif }
/* SetConfParms: set conf parms relevant to HCompV */ void SetConfParms(void) { int i; Boolean b; double f; char buf[MAXSTRLEN]; nParm = GetConfig("HEREST", TRUE, cParm, MAXGLOBS); if (nParm>0) { if (GetConfInt(cParm,nParm,"TRACE",&i)) trace = i; if (GetConfFlt(cParm,nParm,"VARFLOORPERCENTILE",&f)) varFloorPercent = f; if (GetConfBool(cParm,nParm,"SAVEBINARY",&b)) saveBinary = b; if (GetConfBool(cParm,nParm,"BINARYACCFORMAT",&b)) ldBinary = b; /* 2-model reestimation alignment model set */ if (GetConfStr(cParm,nParm,"ALIGNMODELMMF",buf)) { strcpy(al_hmmMMF,buf); al_hmmUsed = TRUE; } if (GetConfStr(cParm,nParm,"ALIGNHMMLIST",buf)) { strcpy(al_hmmLst,buf); al_hmmUsed = TRUE; } /* allow multiple individual model files */ if (GetConfStr(cParm,nParm,"ALIGNMODELDIR",buf)) { strcpy(al_hmmDir,buf); al_hmmUsed = TRUE; } if (GetConfStr(cParm,nParm,"ALIGNMODELEXT",buf)) { strcpy(al_hmmExt,buf); al_hmmUsed = TRUE; } if (GetConfStr(cParm,nParm,"ALIGNXFORMEXT",buf)) { xfInfo.alXFormExt = CopyString(&hmmStack,buf); } if (GetConfStr(cParm,nParm,"ALIGNXFORMDIR",buf)) { xfInfo.alXFormDir = CopyString(&hmmStack,buf); } if (GetConfStr(cParm,nParm,"INXFORMMASK",buf)) { xfInfo.inSpkrPat = CopyString(&hmmStack,buf); } if (GetConfStr(cParm,nParm,"PAXFORMMASK",buf)) { xfInfo.paSpkrPat = CopyString(&hmmStack,buf); } if (GetConfStr(cParm,nParm,"LABFILEMASK",buf)) { labFileMask = (char*)malloc(strlen(buf)+1); strcpy(labFileMask, buf); } if (GetConfStr(cParm,nParm,"UPDATEMODE",buf)) { if (!strcmp (buf, "DUMP")) updateMode = UPMODE_DUMP; else if (!strcmp (buf, "UPDATE")) updateMode = UPMODE_UPDATE; else if (!strcmp (buf, "BOTH")) updateMode = UPMODE_BOTH; else HError(2319, "Unknown UPDATEMODE specified (must be DUMP, UPDATE or BOTH)"); } } } void ReportUsage(void) { printf("\nUSAGE: HERest [options] hmmList dataFiles...\n\n"); printf(" Option Default\n\n"); printf(" -a Use an input linear transform off\n"); printf(" -c f Mixture pruning threshold 10.0\n"); printf(" -d s dir to find hmm definitions current\n"); printf(" -h s set output speaker name pattern *.%%%%%%\n"); printf(" to s, optionally set input and parent patterns\n"); printf(" -l N set max files per speaker off\n"); printf(" -m N set min examples needed per model 3\n"); printf(" -o s extension for new hmm files as src\n"); printf(" -p N set parallel mode to N off\n"); printf(" -r Enable Single Pass Training... \n"); printf(" ...using two parameterisations off\n"); printf(" -s s print statistics to file s off\n"); printf(" -t f [i l] set pruning to f [inc limit] inf\n"); printf(" -u tmvwap update t)rans m)eans v)ars w)ghts tmvw\n"); printf(" a)daptation xform p)rior used \n"); printf(" s)semi-tied xform \n"); printf(" -v f set minimum variance to f 0.0\n"); printf(" -w f set mix weight floor to f*MINMIX 0.0\n"); printf(" -x s extension for hmm files none\n"); printf(" -z s Save all xforms to TMF file s TMF\n"); PrintStdOpts("BEFGHIJKLMSTX"); printf("\n\n"); } void SetuFlags(void) { char *s; s=GetStrArg(); uFlags=(UPDSet) 0; while (*s != '\0') switch (*s++) { case 't': uFlags = (UPDSet) (uFlags+UPTRANS); break; case 'm': uFlags = (UPDSet) (uFlags+UPMEANS); break; case 'v': uFlags = (UPDSet) (uFlags+UPVARS); break; case 'w': uFlags = (UPDSet) (uFlags+UPMIXES); break; case 's': uFlags = (UPDSet) (uFlags+UPSEMIT); break; case 'a': uFlags = (UPDSet) (uFlags+UPXFORM); break; case 'p': uFlags = (UPDSet) (uFlags+UPMAP); break; default: HError(2320,"SetuFlags: Unknown update flag %c",*s); break; } } /* ScriptWord: return next word from script */ char *ScriptWord(FILE *script, char *scriptBuf) { int ch,qch,i; i=0; ch=' '; while (isspace(ch)) ch = fgetc(script); if (ch==EOF) { scriptBuf=NULL; return NULL; } if (ch=='\'' || ch=='"'){ qch = ch; ch = fgetc(script); while (ch != qch && ch != EOF) { scriptBuf[i++] = ch; ch = fgetc(script); } if (ch==EOF) HError(5051,"ScriptWord: Closing quote missing in script file"); } else { do { scriptBuf[i++] = ch; ch = fgetc(script); }while (!isspace(ch) && ch != EOF); } scriptBuf[i] = '\0'; return scriptBuf; } void CheckUpdateSetUp() { AdaptXForm *xf;
int main(int argc, char *argv[]) { char *s; char *labfn; int numUtt; void Initialise(void); void DoGeneration(char *labfn); if (InitShell(argc, argv, hmgens_version, hmgens_vc_id) < SUCCESS) HError(2300, "HMGenS: InitShell failed"); InitMem(); InitMath(); InitSigP(); InitWave(); InitLabel(); InitModel(); if (InitParm() < SUCCESS) HError(2300, "HMGenS: InitParm failed"); InitUtil(); InitFB(); InitAdapt(&xfInfo_hmm, &xfInfo_dur); InitMap(); InitGen(); if (NumArgs() == 0) ReportUsage(); CreateHeap(&genStack, "genStore", MSTAK, 1, 1.0, 80000, 400000); CreateHeap(&uttStack, "uttStore", MSTAK, 1, 0.5, 100, 1000); CreateHeap(&fbInfoStack, "FBInfoStore", MSTAK, 1, 0.5, 100, 1000); CreateHeap(&hmmStack, "HmmStore", MSTAK, 1, 1.0, 50000, 500000); CreateHeap(&dmStack, "dmStore", MSTAK, 1, 1.0, 50000, 500000); SetConfParms(); CreateHMMSet(&hmset, &hmmStack, TRUE); CreateHMMSet(&dmset, &dmStack, TRUE); utt = (UttInfo *) New(&uttStack, sizeof(UttInfo)); genInfo = (GenInfo *) New(&genStack, sizeof(GenInfo)); fbInfo = (FBInfo *) New(&fbInfoStack, sizeof(FBInfo)); while (NextArg() == SWITCHARG) { s = GetSwtArg(); if (strlen(s) != 1) HError(9919, "HMGenS: Bad switch %s; must be single letter", s); switch (s[0]) { case 'a': xfInfo_hmm.useInXForm = TRUE; break; case 'b': xfInfo_dur.useInXForm = TRUE; break; case 'c': if (NextArg() != INTARG) HError(2119, "HMGenS: Parameter generation algorithm type value expected"); type = (ParmGenType) GetChkedInt(CHOLESKY, FB, s); break; case 'd': if (NextArg() != STRINGARG) HError(2319, "HMGenS: HMM definition directory expected"); hmmDir = GetStrArg(); break; case 'e': useAlign = TRUE; break; case 'f': frameRate = (HTime) GetChkedFlt(0.0, 10000000.0, s); break; case 'g': minFrwdP = GetChkedFlt(0.0, 1000.0, s); break; case 'h': if (NextArg() != STRINGARG) HError(1, "Speaker name pattern expected"); xfInfo_hmm.inSpkrPat = xfInfo_dur.inSpkrPat = GetStrArg(); if (NextArg() == STRINGARG) xfInfo_hmm.paSpkrPat = xfInfo_dur.paSpkrPat = GetStrArg(); if (NextArg() != SWITCHARG) HError(2319, "HMGenS: cannot have -h as the last option"); break; case 'm': modelAlign = TRUE; break; case 'n': if (NextArg() != STRINGARG) HError(2319, "HMGenS: duration model definition directory expected"); dmDir = GetStrArg(); break; case 'p': outPdf = TRUE; break; case 'r': if (NextArg() != FLOATARG) HError(2119, "HMGenS: Speaking rate value (float) expected"); speakRate = GetChkedFlt(0.0, 3.0, s); break; case 's': stateAlign = TRUE; break; case 't': pruneInit = GetChkedFlt(0.0, 1.0E20, s); if (NextArg() == FLOATARG || NextArg() == INTARG) { pruneInc = GetChkedFlt(0.0, 1.0E20, s); pruneLim = GetChkedFlt(0.0, 1.0E20, s); } else { pruneInc = 0.0; pruneLim = pruneInit; } break; case 'v': MSDthresh = GetChkedFlt(0.0, 1.0, s); break; case 'x': if (NextArg() != STRINGARG) HError(2319, "HMGenS: HMM file extension expected"); hmmExt = GetStrArg(); break; case 'y': if (NextArg() != STRINGARG) HError(2319, "HMGenS: duration model file extension expected"); dmExt = GetStrArg(); break; case 'B': inBinary = TRUE; break; case 'E': if (NextArg() != STRINGARG) HError(2319, "HMGenS: parent transform directory expected"); xfInfo_hmm.usePaXForm = TRUE; xfInfo_hmm.paXFormDir = GetStrArg(); if (NextArg() == STRINGARG) xfInfo_hmm.paXFormExt = GetStrArg(); if (NextArg() != SWITCHARG) HError(2319, "HMGenS: cannot have -E as the last option"); break; case 'G': if (NextArg() != STRINGARG) HError(2119, "HMGenS: Label File format expected"); if ((lff = Str2Format(GetStrArg())) == ALIEN) HError(-2189, "HMGenS: Warning ALIEN Label file format set"); break; case 'H': if (NextArg() != STRINGARG) HError(3219, "HMGenS: HMM MMF File name expected"); AddMMF(&hmset, GetStrArg()); break; case 'I': if (NextArg() != STRINGARG) HError(2319, "HMGenS: MLF file name expected"); LoadMasterFile(GetStrArg()); break; case 'J': if (NextArg() != STRINGARG) HError(2319, "HMGenS: input transform directory expected"); AddInXFormDir(&hmset, GetStrArg()); if (NextArg() == STRINGARG) xfInfo_hmm.inXFormExt = GetStrArg(); if (NextArg() != SWITCHARG) HError(2319, "HMGenS: cannot have -J as the last option"); break; case 'L': if (NextArg() != STRINGARG) HError(2319, "HMGenS: Label file directory expected"); labDir = GetStrArg(); break; case 'M': if (NextArg() != STRINGARG) HError(2319, "HMGenS: Output macro file directory expected"); genDir = GetStrArg(); break; case 'N': if (NextArg() != STRINGARG) HError(3219, "HMGenS: Duration MMF File name expected"); AddMMF(&dmset, GetStrArg()); break; case 'T': if (NextArg() != INTARG) HError(2119, "HMGenS: Trace value expected"); trace = GetChkedInt(0, 0002, s); break; case 'W': if (NextArg() != STRINGARG) HError(2319, "HMGenS: parent duration transform directory expected"); xfInfo_dur.usePaXForm = TRUE; xfInfo_dur.paXFormDir = GetStrArg(); if (NextArg() == STRINGARG) xfInfo_dur.paXFormExt = GetStrArg(); if (NextArg() != SWITCHARG) HError(2319, "HMGenS: cannot have -W as the last option"); break; case 'X': if (NextArg() != STRINGARG) HError(2319, "HMGenS: Label file extension expected"); labExt = GetStrArg(); break; case 'Y': if (NextArg() != STRINGARG) HError(2319, "HMGenS: input duration transform directory expected"); AddInXFormDir(&dmset, GetStrArg()); if (NextArg() == STRINGARG) { if (xfInfo_dur.inXFormExt == NULL) xfInfo_dur.inXFormExt = GetStrArg(); else HError(2319, "MGenS: only one input duration transform extension may be specified"); } if (NextArg() != SWITCHARG) HError(2319, "HMGenS: cannot have -Y as the last option"); break; default: HError(9919, "HMGenS: Unknown switch %s", s); } } if (NextArg() != STRINGARG) HError(2319, "HMGenS: file name of vocabulary list expected"); Initialise(); InitUttInfo(utt, FALSE); numUtt = 1; if (trace & T_TOP) SetTraceGen(); /* generate parameter sequences */ do { if (NextArg() != STRINGARG) HError(2319, "HMGenS: data file name expected"); labfn = GetStrArg(); /* track speakers */ if (UpdateSpkrStats(&hmset, &xfInfo_hmm, labfn)) { if (!xfInfo_hmm.useInXForm) xfInfo_hmm.inXForm = NULL; } if (UpdateSpkrStats(&dmset, &xfInfo_dur, labfn)) { if (!xfInfo_dur.useInXForm) xfInfo_dur.inXForm = NULL; else ResetDMMPreComps(&dmset); } fbInfo->xfinfo_hmm = &xfInfo_hmm; fbInfo->xfinfo_dur = &xfInfo_dur; fbInfo->inXForm_hmm = xfInfo_hmm.inXForm; fbInfo->inXForm_dur = xfInfo_dur.inXForm; fbInfo->al_inXForm_hmm = xfInfo_hmm.al_inXForm; fbInfo->al_inXForm_dur = xfInfo_dur.al_inXForm; fbInfo->paXForm_hmm = xfInfo_hmm.paXForm; fbInfo->paXForm_dur = xfInfo_dur.paXForm; /* generate parameters */ DoGeneration(labfn); numUtt++; } while (NumArgs() > 0); if (trace & T_TOP) { printf("Generation complete - average log prob per frame = %e (%d frames)\n", totalPr / totalT, totalT); } /* Reset stacks */ Dispose(&fbInfoStack, fbInfo); Dispose(&genStack, genInfo); Dispose(&uttStack, utt); ResetHeap(&fbInfoStack); ResetHeap(&uttStack); ResetHeap(&genStack); ResetHeap(&dmStack); ResetHeap(&hmmStack); /* Reset modules */ ResetGen(); ResetAdapt(&xfInfo_hmm, &xfInfo_dur); ResetFB(); ResetUtil(); ResetParm(); ResetModel(); ResetLabel(); ResetWave(); ResetSigP(); ResetMath(); ResetMem(); ResetShell(); Exit(0); return (0); /* never reached -- make compiler happy */ }
/* DoRecognition: use single network to recognise each input utterance */ void DoRecognition(void) { FILE *nf; Network *net; Boolean isPipe; int n=0; AdaptXForm *incXForm; if ( (nf = FOpen(wdNetFn,NetFilter,&isPipe)) == NULL) HError(3210,"DoRecognition: Cannot open Word Net file %s",wdNetFn); if((wdNet = ReadLattice(nf,&ansHeap,&vocab,TRUE,FALSE))==NULL) HError(3210,"DoAlignment: ReadLattice failed"); FClose(nf,isPipe); if (trace&T_TOP) { printf("Read lattice with %d nodes / %d arcs\n",wdNet->nn,wdNet->na); fflush(stdout); } CreateHeap(&netHeap,"Net heap",MSTAK,1,0, wdNet->na*sizeof(NetLink),wdNet->na*sizeof(NetLink)); net = ExpandWordNet(&netHeap,wdNet,&vocab,&hset); ResetHeap(&ansHeap); if (trace&T_TOP) { printf("Created network with %d nodes / %d links\n", net->numNode,net->numLink); fflush(stdout); } if (trace & T_MEM){ printf("Memory State Before Recognition\n"); PrintAllHeapStats(); } if (NumArgs()==0) { /* Process audio */ while(TRUE){ printf("\nREADY[%d]>\n",++n); fflush(stdout); /* no input transform possible for audio input .... */ ProcessFile(NULL,net,n,genBeam, FALSE); if (update > 0 && n%update == 0) { if (trace&T_TOP) { printf("Transforming model set\n"); fflush(stdout); } /* at every stage a new transform is created - fix?? Estimate transform and then set it up as the input XForm */ incXForm = CreateAdaptXForm(&hset,"inc"); TidyBaseAccs(); GenAdaptXForm(&hset,incXForm); xfInfo.inXForm = GetMLLRDiagCov(incXForm);; SetXForm(&hset,xfInfo.inXForm); ApplyHMMSetXForm(&hset,xfInfo.inXForm); } } } else { /* Process files */ while (NumArgs()>0) { if (NextArg()!=STRINGARG) HError(3219,"DoRecognition: Data file name expected"); datFN = GetStrArg(); if (trace&T_TOP) { printf("File: %s\n",datFN); fflush(stdout); } /* This handles the initial input transform, parent transform setting and output transform creation */ if (UpdateSpkrStats(&hset, &xfInfo, datFN) && (!(xfInfo.useInXForm)) && (hset.semiTied == NULL)) { xfInfo.inXForm = NULL; } ProcessFile(datFN,net,n++,genBeam,FALSE); if (update > 0 && n%update == 0) { if (trace&T_TOP) { printf("Transforming model set\n"); fflush(stdout); } /* at every stage a new transform is created - fix?? Estimate transform and then set it up as the input XForm */ incXForm = CreateAdaptXForm(&hset,"inc"); TidyBaseAccs(); GenAdaptXForm(&hset,incXForm); xfInfo.inXForm = GetMLLRDiagCov(incXForm);; SetXForm(&hset,xfInfo.inXForm); ApplyHMMSetXForm(&hset,xfInfo.inXForm); } } } }
/* DoAlignment: by creating network from transcriptions or lattices */ void DoAlignment(void) { FILE *nf; char lfn[MAXSTRLEN], buf[MAXSTRLEN]; Transcription *trans; Network *net; Boolean isPipe; int n=0; LogDouble currGenBeam; AdaptXForm *incXForm; if (trace&T_TOP) { if (loadNetworks) printf("New network will be used for each file\n"); else printf("Label file will be used to align each file\n"); fflush(stdout); } CreateHeap(&netHeap,"Net heap",MSTAK,1,0,8000,80000); while (NumArgs()>0) { if (NextArg() != STRINGARG) HError(3219,"DoAlignment: Data file name expected"); datFN = GetStrArg(); if (trace&T_TOP) { printf("Aligning File: %s\n",datFN); fflush(stdout); } if (labFileMask != NULL ) { /* support for rescoring lattice masks */ if (!MaskMatch(labFileMask,buf,datFN)) HError(2319,"DoAlignment: mask %s has no match with segemnt %s",labFileMask,datFN); MakeFN(buf,labInDir,labInExt,lfn); } else { MakeFN(datFN,labInDir,labInExt,lfn); } if (loadNetworks) { if ( (nf = FOpen(lfn,NetFilter,&isPipe)) == NULL) HError(3210,"DoAlignment: Cannot open Word Net file %s",lfn); if((wdNet = ReadLattice(nf,&netHeap,&vocab,TRUE,FALSE))==NULL) HError(3210,"DoAlignment: ReadLattice failed"); FClose(nf,isPipe); if (trace&T_TOP) { printf("Read lattice with %d nodes / %d arcs\n", wdNet->nn,wdNet->na); fflush(stdout); } } else { LabList *ll = NULL; trans=LOpen(&netHeap,lfn,ifmt); if (trans->numLists >= 1) ll = GetLabelList(trans,1); if (!ll && !bndId) HError(3233, "DoAlignment: cannot align empty transcription"); wdNet=LatticeFromLabels(ll, bndId, &vocab,&netHeap); if (trace&T_TOP) { printf("Created lattice with %d nodes / %d arcs from label file\n", wdNet->nn,wdNet->na); fflush(stdout); } } net=ExpandWordNet(&netHeap,wdNet,&vocab,&hset); ++n; currGenBeam = genBeam; /* This handles the initial input transform, parent transform setting and output transform creation */ if (UpdateSpkrStats(&hset, &xfInfo, datFN) && (!(xfInfo.useInXForm)) && (hset.semiTied == NULL)) { xfInfo.inXForm = NULL; } if (genBeamInc == 0.0) ProcessFile (datFN, net, n, currGenBeam, FALSE); else { Boolean completed; completed = ProcessFile (datFN, net, n, currGenBeam, TRUE); currGenBeam += genBeamInc; while (!completed && (currGenBeam <= genBeamLim - genBeamInc)) { completed = ProcessFile (datFN, net, n, currGenBeam, TRUE); currGenBeam += genBeamInc; } if (!completed) ProcessFile (datFN, net, n, currGenBeam, FALSE); } if (update > 0 && n%update == 0) { if (trace&T_TOP) { printf("Transforming model set\n"); fflush(stdout); } /* at every stage a new transform is created - fix?? Estimate transform and then set it up as the input XForm */ incXForm = CreateAdaptXForm(&hset,"inc"); TidyBaseAccs(); GenAdaptXForm(&hset,incXForm); xfInfo.inXForm = GetMLLRDiagCov(incXForm);; SetXForm(&hset,xfInfo.inXForm); ApplyHMMSetXForm(&hset,xfInfo.inXForm); } ResetHeap(&netHeap); } }
int main(int argc, char *argv[]) { char *s; void Initialise(void); void DoRecognition(void); void DoAlignment(void); if(InitShell(argc,argv,hvite_version,hvite_vc_id)<SUCCESS) HError(3200,"HVite: InitShell failed"); InitMem(); InitLabel(); InitMath(); InitSigP(); InitWave(); InitAudio(); InitVQ(); InitModel(); if(InitParm()<SUCCESS) HError(3200,"HVite: InitParm failed"); InitDict(); InitNet(); InitRec(); InitUtil(); InitAdapt(&xfInfo); InitMap(); if (!InfoPrinted() && NumArgs() == 0) ReportUsage(); if (NumArgs() == 0) Exit(0); SetConfParms(); CreateHeap(&modelHeap, "Model heap", MSTAK, 1, 0.0, 100000, 800000 ); CreateHMMSet(&hset,&modelHeap,TRUE); while (NextArg() == SWITCHARG) { s = GetSwtArg(); if (strlen(s)!=1) HError(3219,"HVite: Bad switch %s; must be single letter",s); switch(s[0]){ case 'a': loadLabels=TRUE; break; case 'b': if (NextArg()!=STRINGARG) HError(3219,"HVite: Utterance boundary word expected"); bndId = GetLabId(GetStrArg(),TRUE); break; case 'c': tmBeam = GetChkedFlt(0.0,1000.0,s); break; case 'd': if (NextArg()!=STRINGARG) HError(3219,"HVite: HMM definition directory expected"); hmmDir = GetStrArg(); break; case 'e': saveAudioOut=TRUE; break; case 'f': states=TRUE; break; case 'g': replay=TRUE; break; case 'i': if (NextArg()!=STRINGARG) HError(3219,"HVite: Output MLF file name expected"); /* if(SaveToMasterfile(GetStrArg())<SUCCESS) HError(3214,"HCopy: Cannot write to MLF"); */ SaveToMasterfile(GetStrArg()); break; case 'k': xfInfo.useInXForm = TRUE; break; case 'j': if (NextArg()!=INTARG) HError(3219,"HVite: No. of files per online adaptation step expected"); update = GetChkedInt(1,256,s); break; case 'l': if (NextArg()!=STRINGARG) HError(3219,"HVite: Label file directory expected"); labDir = GetStrArg(); break; case 'm': models=TRUE; break; case 'n': nToks = GetChkedInt(2,MAX_TOKS,s); if (NextArg()==FLOATARG || NextArg()==INTARG) nTrans = GetChkedInt(1,10000,s); else nTrans = 1; break; case 'o': if (NextArg()!=STRINGARG) HError(3219,"HVite: Output label format expected"); labForm = GetStrArg(); break; case 'p': wordPen = GetChkedFlt(-1000.0,1000.0,s); break; case 'q': if (NextArg()!=STRINGARG) HError(3219,"HVite: Output lattice format expected"); latForm = GetStrArg(); break; case 'r': prScale = GetChkedFlt(0.0,1000.0,s); break; case 's': lmScale = GetChkedFlt(0.0,1000.0,s); break; case 't': genBeam = GetChkedFlt(0,1.0E20,s); if (genBeam == 0.0) genBeam = -LZERO; if (NextArg()==FLOATARG || NextArg()==INTARG) { genBeamInc = GetChkedFlt(0.0,1.0E20,s); genBeamLim = GetChkedFlt(0.0,1.0E20,s); if (genBeamLim < (genBeam + genBeamInc)) { genBeamLim = genBeam; genBeamInc = 0.0; } } else { genBeamInc = 0.0; genBeamLim = genBeam; } break; case 'w': if (NextArg()!=STRINGARG) loadNetworks=TRUE; else { wdNetFn = GetStrArg(); if (strlen(wdNetFn)==0) { wdNetFn=NULL; loadNetworks=TRUE; } } break; case 'u': maxActive = GetChkedInt(0,100000,s); break; case 'v': wordBeam = GetChkedFlt(0,1.0E20,s); if (wordBeam == 0.0) wordBeam = -LZERO; break; case 'x': if (NextArg()!=STRINGARG) HError(3219,"HVite: HMM file extension expected"); hmmExt = GetStrArg(); break; case 'y': if (NextArg()!=STRINGARG) HError(3219,"HVite: Output label file extension expected"); labExt = GetStrArg(); break; case 'z': if (NextArg()!=STRINGARG) HError(3219,"HVite: Lattice output file extension expected"); latExt = GetStrArg(); break; case 'F': if (NextArg() != STRINGARG) HError(3219,"HVite: Data File format expected"); if((dfmt = Str2Format(GetStrArg())) == ALIEN) HError(-3289,"HVite: Warning ALIEN Input file format set"); break; case 'G': if (NextArg() != STRINGARG) HError(3219,"HVite: Source Label File format expected"); if((ifmt = Str2Format(GetStrArg())) == ALIEN) HError(-3289,"HVite: Warning ALIEN Input file format set"); break; case 'H': if (NextArg() != STRINGARG) HError(3219,"HVite: MMF File name expected"); AddMMF(&hset,GetStrArg()); break; case 'I': if (NextArg() != STRINGARG) HError(3219,"HVite: MLF file name expected"); LoadMasterFile(GetStrArg()); break; case 'L': if (NextArg()!=STRINGARG) HError(3219,"HVite: Label/network file directory expected"); labInDir = GetStrArg(); break; case 'P': if (NextArg() != STRINGARG) HError(3219,"HVite: Target Label File format expected"); if((ofmt = Str2Format(GetStrArg())) == ALIEN) HError(-3289,"HVite: Warning ALIEN Label output file format set"); break; case 'B': saveBinary = TRUE; break; case 'T': trace = GetChkedInt(0,511,s); break; case 'X': if (NextArg()!=STRINGARG) HError(3219,"HVite: Input label/network file extension expected"); labInExt = GetStrArg(); break; case 'h': if (NextArg()!=STRINGARG) HError(1,"Speaker name pattern expected"); xfInfo.outSpkrPat = GetStrArg(); if (NextArg()==STRINGARG) { xfInfo.inSpkrPat = GetStrArg(); if (NextArg()==STRINGARG) xfInfo.paSpkrPat = GetStrArg(); } if (NextArg() != SWITCHARG) HError(2319,"HERest: cannot have -h as the last option"); break; case 'E': if (NextArg()!=STRINGARG) HError(2319,"HERest: parent transform directory expected"); xfInfo.usePaXForm = TRUE; xfInfo.paXFormDir = GetStrArg(); if (NextArg()==STRINGARG) xfInfo.paXFormExt = GetStrArg(); if (NextArg() != SWITCHARG) HError(2319,"HVite: cannot have -E as the last option"); break; case 'J': if (NextArg()!=STRINGARG) HError(2319,"HERest: input transform directory expected"); AddInXFormDir(&hset,GetStrArg()); if (NextArg()==STRINGARG) xfInfo.inXFormExt = GetStrArg(); if (NextArg() != SWITCHARG) HError(2319,"HVite: cannot have -J as the last option"); break; case 'K': if (NextArg()!=STRINGARG) HError(2319,"HVite: output transform directory expected"); xfInfo.outXFormDir = GetStrArg(); xfInfo.useOutXForm = TRUE; if (NextArg()==STRINGARG) xfInfo.outXFormExt = GetStrArg(); if (NextArg() != SWITCHARG) HError(2319,"HVite: cannot have -K as the last option"); break; default: HError(3219,"HVite: Unknown switch %s",s); } } if (NextArg()!=STRINGARG) HError(3219,"HVite: Dictionary file name expected"); dictFn = GetStrArg(); if (NextArg()!=STRINGARG) HError(3219,"HVite: HMM list file name expected"); hmmListFn = GetStrArg(); #ifndef PHNALG if ((states || models) && nToks>1) HError(3230,"HVite: Alignment using multiple tokens is not supported"); #endif if (NumArgs()==0 && wdNetFn==NULL) HError(3230,"HVite: Network must be specified for recognition from audio"); if (loadNetworks && loadLabels) HError(3230,"HVite: Must choose either alignment from network or labels"); if (nToks>1 && latExt==NULL && nTrans==1) HError(-3230,"HVite: Performing nbest recognition with no nbest output"); if (nToks > 1 && latExt != NULL && nTrans > 1) HError(-3230,"HVite: Performing nbest recognition with 1-best and latttices output"); if ((update>0) && (!xfInfo.useOutXForm)) HError(3230,"HVite: Must use -K option with incremental adaptation"); Initialise(); /* Process the data */ if (wdNetFn==NULL) DoAlignment(); else DoRecognition(); /* Free up and we are done */ if (trace & T_MEM) { printf("Memory State on Completion\n"); PrintAllHeapStats(); } DeleteVRecInfo(vri); ResetHeap(&netHeap); FreePSetInfo(psi); UpdateSpkrStats(&hset,&xfInfo, NULL); ResetHeap(®Heap); ResetHeap(&modelHeap); Exit(0); return (0); /* never reached -- make compiler happy */ }