/* 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[]) { Source src; int tmpInt; float tmpFlt; char *accfn, *s; void Initialise(char *hmmListFn); void Interpolate(void); void UpdateModels(void); void MakeWtAccLists(void); void AttachWtAccLists(void); void StatReport(void); if(InitShell(argc,argv,hsmooth_version,hsmooth_vc_id)<SUCCESS) HError(2400,"HSmooth: InitShell failed"); InitMem(); InitLabel(); InitMath(); InitSigP(); InitWave(); InitAudio(); InitVQ(); InitModel(); if(InitParm()<SUCCESS) HError(2400,"HSmooth: InitParm failed"); InitTrain(); InitUtil(); if (!InfoPrinted() && NumArgs() == 0) ReportUsage(); if (NumArgs() == 0) Exit(0); SetConfParms(); CreateHeap(&hmmStack,"HmmStore", MSTAK, 1, 1.0, 50000, 500000); CreateHMMSet(&hset,&hmmStack,TRUE); while (NextArg() == SWITCHARG) { s = GetSwtArg(); if (strlen(s)!=1) HError(2419,"HSmooth: Bad switch %s; must be single letter",s); switch(s[0]){ case 'b': epsilon = GetChkedFlt(0.0,1.0,s); break; case 'c': maxStep = GetChkedInt(1,1000,s); break; case 'd': if (NextArg()!=STRINGARG) HError(2419,"HSmooth: HMM definition directory expected"); hmmDir = GetStrArg(); break; case 'e': if (NextArg()!=STRINGARG) HError(2419,"HSmooth: HMM definition directory expected"); newDir = GetStrArg(); break; case 'm': minEgs = GetChkedInt(1,1000,s); break; case 'o': if (NextArg()!=STRINGARG) HError(2419,"HSmooth: HMM file extension expected"); newExt = GetStrArg(); break; case 's': stats = TRUE; if (NextArg()!=STRINGARG) HError(2419,"HSmooth: Stats file name expected"); statFN = GetStrArg(); break; case 'u': SetuFlags(); break; case 'v': minVar = GetChkedFlt(0.0,10.0,s); break; case 'w': mixWeightFloor = MINMIX * GetChkedFlt(0.0,10000.0,s); break; case 'x': if (NextArg()!=STRINGARG) HError(2419,"HSmooth: HMM file extension expected"); hmmExt = GetStrArg(); break; case 'B': saveBinary=TRUE; break; case 'H': if (NextArg() != STRINGARG) HError(2419,"HSmooth: HMM macro file name expected"); AddMMF(&hset,GetStrArg()); break; case 'M': if (NextArg()!=STRINGARG) HError(2419,"HSmooth: Output macro file directory expected"); newDir = GetStrArg(); break; case 'T': trace = GetChkedInt(0,0100000,s); break; default: HError(2419,"HSmooth: Unknown switch %s",s); } } if (NextArg() != STRINGARG) HError(2419,"HSmooth: file name of HMM list expected"); Initialise(GetStrArg()); do { if (NextArg()!=STRINGARG) HError(2419,"HSmooth: accumulator file name expected"); accfn = GetStrArg(); src=LoadAccs(&hset,accfn,uFlags); ReadFloat(&src,&tmpFlt,1,ldBinary); totalPr += (LogDouble)tmpFlt; ReadInt(&src,&tmpInt,1,ldBinary); totalT += tmpInt; CloseSource(&src); nBlk++; MakeWtAccLists(); } while (NumArgs()>0); AttachWtAccLists(); Interpolate(); if (stats) StatReport(); UpdateModels(); Exit(0); return (0); /* never reached -- make compiler happy */ }