int inithtk(int argc, char *argv[],const char * app_version, bool noGraphics) { InitThreads(HT_MSGMON); // enable msg driven monitoring if(InitShell(argc,argv,app_version)<SUCCESS) return FAIL; // CommonInit() expanded with incompatible things commented out: InitMem(); InitLabel(); InitMath(); InitSigP(); InitUtil(); InitWave(); /*InitAudio();*/ InitModel(); if(InitParm()<SUCCESS) return FAIL; InitGraf((Boolean)noGraphics); InitDict(); InitNet(); InitLM(); InitRec(); InitLat(); /*InitAdapt();*/ EnableBTrees(); /* allows unseen triphones to be synthesised */ /* Register(abuffer_version); Register(acode_version); Register(acomponent_version); Register(adict_version); Register(agram_version); Register(angram_version); Register(ahmms_version); Register(ahtk_version); Register(amonitor_version); Register(apacket_version); Register(arec_version); Register(aresource_version); Register(arman_version); Register(asource_version); */ InfoPrinted(); return SUCCESS; }
int main(int argc, char *argv[]) { char * labFn, *listfn, *s; int i,fidx; MLFEntry *me = NULL; Transcription *t; void InitStats(char *listfn); void GatherStats(Transcription *t); void OutputStats(void); if(InitShell(argc,argv,hlstats_version,hlstats_vc_id)<SUCCESS) HError(1300,"HLStats: InitShell failed"); InitMem(); InitMath(); InitWave(); InitLabel(); InitLM(); if (!InfoPrinted() && NumArgs() == 0) ReportUsage(); if (NumArgs() == 0) Exit(0); SetConfParms(); enterId=GetLabId("!ENTER",TRUE); /* All sentences should or are coerced */ exitId=GetLabId("!EXIT",TRUE); /* to start enterId and end exitId */ nullId=GetLabId("!NULL",TRUE); /* Name for words not in list */ while (NextArg() == SWITCHARG) { s = GetSwtArg(); if (strlen(s)!=1) HError(1319,"HLStats: Bad switch %s; must be single letter",s); switch(s[0]){ case 'b': doBigram = TRUE; if (NextArg() != STRINGARG) HError(1319,"HLStats: Ngram output file name expected"); bigFile = GetStrArg(); break; case 'c': doLCount = TRUE; lCountLimit = GetChkedInt(0,100000,s); break; case 'd': doDurs = TRUE; break; case 'f': bigFloor = GetChkedFlt(0.0,1000.0,s); break; case 'h': hSize = GetChkedInt(1,2,s); break; case 'l': doList = TRUE; if (NextArg() != STRINGARG) HError(1319,"HLStats: Output label list file name expected"); listFile = GetStrArg(); break; case 'o': doBOff = TRUE; break; case 'p': doPCount = TRUE; pCountLimit = GetChkedInt(0,100000,s); break; case 's': if (NextArg() != STRINGARG) HError(1319,"HLStats: ENTER label name expected"); enterId=GetLabId(GetStrArg(),TRUE); if (NextArg() != STRINGARG) HError(1319,"HLStats: EXIT label name expected"); exitId=GetLabId(GetStrArg(),TRUE); break; case 't': bigThresh = GetChkedInt(0,100,s); break; case 'u': uniFloor = GetChkedFlt(0.0,1000.0,s); break; case 'G': if (NextArg() != STRINGARG) HError(1319,"HLStats: Input label File format expected"); if((ff = Str2Format(GetStrArg())) == ALIEN) HError(-1389,"HLStats: Warning ALIEN Label file format set"); break; case 'I': if (NextArg() != STRINGARG) HError(1319,"HLStats: Input MLF file name expected"); LoadMasterFile(GetStrArg()); break; case 'T': if (NextArg() != INTARG) HError(1319,"HLStats: Trace value expected"); trace = GetChkedInt(0,017,s); break; default: HError(1319,"HLStats: Unknown switch %s",s); } } if (NextArg()!=STRINGARG) HError(1319,"HLStats: Label list file name expected"); listfn = GetStrArg(); if (!(doDurs || doBigram || doList || doLCount || doPCount)) HError(1330,"HLStats: Nothing to do!"); InitStats(listfn); i=0; while (NumArgs()>0) { if (NextArg()!=STRINGARG) HError(1319,"HLStats: Input label file name expected"); labFn = GetStrArg(); if (IsMLFFile(labFn)) { fidx = NumMLFFiles(); if ((me=GetMLFTable()) != NULL) { while(me->next != NULL) me=me->next; LoadMasterFile(labFn); me=me->next; } else { LoadMasterFile(labFn); me=GetMLFTable(); } while (me != NULL) { if (me->type == MLF_IMMEDIATE && me->def.immed.fidx == fidx) { if (trace&T_FIL) { printf(" Processing file %s\n",me->pattern); fflush(stdout); } t = LOpen(&tmpHeap,me->pattern,ff); if (t->numLists<1) HError(-1330,"HLStats: Empty file %s",me->pattern); else GatherStats(t),i++; Dispose(&tmpHeap,t); } me = me->next; if ((trace&T_BAS) && !(trace&T_FIL) && NumMLFEntries()>5000 && i%1000==0) printf(". "),fflush(stdout); } if ((trace&T_BAS) && !(trace&T_FIL) && NumMLFEntries()>5000) printf("\n"); } else { if (trace&T_FIL) { printf(" Processing file %s\n",labFn); fflush(stdout); } t = LOpen(&tmpHeap,labFn,ff); if (t->numLists<1) HError(-1330,"HLStats: Empty file %s",me->pattern); else GatherStats(t),i++; Dispose(&tmpHeap,t); } } if (trace&T_MEM) PrintAllHeapStats(); OutputStats(); if (trace&T_MEM) PrintAllHeapStats(); Exit(0); return (0); /* never reached -- make compiler happy */ }
#include "HLM.h" typedef enum {unknown, wordLoop, boBiGram, matBiGram, multiLat, wordPair} BuildType; static int trace = 0; /* Trace flags */ static LabId enterId; /* id of !ENTRY label in ngram */ static LabId exitId; /* id of !EXIT label in ngram */ static LabId bStartId=NULL; /* id of start bracket */ static LabId bEndId=NULL; /* id of end bracket */ static LabId unknownId; /* id of unknown label in ngram */ static Boolean zapUnknown = FALSE; /* zap unknown symbols from bigram */ MemHeap buildStack; /* ---------------- Configuration Parameters --------------------- */ static ConfParam *cParm[MAXGLOBS]; static int nParm = 0; /* total num params */ /* ---------------- Process Command Line ------------------------- */ /* SetConfParms: set conf parms relevant to this tool */ void SetConfParms(void) { int i; nParm = GetConfig("HBUILD", TRUE, cParm, MAXGLOBS); if (nParm>0){ if (GetConfInt(cParm,nParm,"TRACE",&i)) trace = i; } } void ReportUsage(void) { printf("\nUSAGE: HBuild [options] wordList latFile\n\n"); printf(" Option Default\n\n"); printf(" -b binary lattice output ASCII\n"); printf(" -m s load matrix bigram from s off\n"); printf(" -n s load back-off bigram from s off\n"); printf(" -s s1 s2 s1/s2 are bigram start/end labels !ENTER !EXIT\n"); printf(" -t s1 s2 bracket word-loop/pair with s1 s2 off\n"); printf(" -u s set unknown symbol to s !NULL\n"); printf(" -w s load word-pair grammar from s off\n"); printf(" -x s load multi-level lattice from s off\n"); printf(" -z ignore ngrams with unknown symbol off\n"); PrintStdOpts(""); printf("\n\n"); } int main(int argc, char *argv[]) { char *wordListFn,*latFn,*ipFn=NULL; LModel *bigramLm; BuildType bType = unknown; Boolean saveLatBin = FALSE; LatFormat format = HLAT_LMLIKE; Lattice *lat,*ipLat; Vocab voc; char *s; Lattice *ProcessWordLoop(MemHeap *latHeap, Vocab *voc); Lattice *ProcessBiGram(MemHeap *latHeap, Vocab *voc, LModel *biLM); void SaveLattice(Lattice *lat, char *latFn, LatFormat format); Lattice *LoadLattice(MemHeap *latHeap, char *latFn, Vocab *voc, Boolean shortArc); Lattice *ProcessWordPair(MemHeap *latHeap, Vocab *voc, char *fn); if(InitShell(argc,argv,hbuild_version,hbuild_vc_id)<SUCCESS) HError(3000,"HBuild: InitShell failed"); InitMem(); InitLabel(); InitMath(); InitDict(); InitNet(); InitLM(); CreateHeap(&buildStack, "HBuild Stack", MSTAK, 1, 0.0, 100000, LONG_MAX ); if (!InfoPrinted() && NumArgs() == 0) ReportUsage(); if (NumArgs() == 0) Exit(0); SetConfParms();