📄 headapt.c
字号:
HError(2719,"HEAdapt: channel description string expected"); chan = GetStrArg(); } else if (strcmp(fmt,"DESC")==0){ if (NextArg()!=STRINGARG) HError(2719,"HEAdapt: a general description string expected"); desc = GetStrArg(); } else HError(2719,"HEAdapt: Unrecognised format, should be one of [uid,uname,chan,desc]"); break; case 'g': /* global adaptation! */ global = TRUE; break; case 'i': if (NextArg()!=INTARG) HError(2719,"HEAdapt: Number of utterances before transformation expected"); update = GetIntArg(); break; case 'j': map = TRUE; if (NextArg()==FLOATARG || NextArg()==INTARG) tau = GetChkedFlt(0.0,1.0E20,s); break; case 'k': mapUseMLLR = TRUE; break; case 'm': occThresh = GetChkedFlt(0.0,1.0E20,s); break; case 'n': if (NextArg()!=STRINGARG) HError(2719,"HEAdapt: Full name string expected"); uname = GetStrArg(); break; case 'o': if (NextArg()!=STRINGARG) HError(2719,"HEAdapt: HMM file extension expected"); newExt = GetStrArg(); 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 'u': SetuFlags(); break; case 'v': minVar = GetChkedFlt(0.0,10.0,s); break; case 'x': if (NextArg()!=STRINGARG) HError(2319,"HERest: HMM file extension expected"); hmmExt = GetStrArg(); break; case 'B': saveBinary=TRUE; break; case 'F': if (NextArg() != STRINGARG) HError(2719,"HEAdapt: Data File format expected"); if((dff = Str2Format(GetStrArg())) == ALIEN) HError(-2789,"HEAdapt: Warning ALIEN Data file format set"); break; case 'G': if (NextArg() != STRINGARG) HError(2719,"HEAdapt: Label File format expected"); if((lff = Str2Format(GetStrArg())) == ALIEN) HError(-2789,"HEAdapt: Warning ALIEN Label file format set"); break; case 'H': if (NextArg() != STRINGARG) HError(2719,"HEAdapt: HMM macro file name expected"); AddMMF(&hset,GetStrArg()); break; case 'I': if (NextArg() != STRINGARG) HError(2719,"HEAdapt: MLF file name expected"); LoadMasterFile(GetStrArg()); break; case 'J': if (NextArg()!=STRINGARG) HError(2719,"HEAdapt: Transforms file name expected"); transFile = GetStrArg(); break; case 'K': if (NextArg()!=STRINGARG) HError(2719,"HEAdapt: Stats file name expected"); saveTransFN = GetStrArg(); break; case 'L': if (NextArg()!=STRINGARG) HError(2719,"HEAdapt: Label file directory expected"); labDir = GetStrArg(); break; case 'M': if (NextArg()!=STRINGARG) HError(2719,"HEAdapt: Output model file directory expected"); newDir = GetStrArg(); break; case 'T': trace = GetChkedInt(0,0100000,s); break; case 'X': if (NextArg()!=STRINGARG) HError(2719,"HEAdapt: Label file extension expected"); labExt = GetStrArg(); break; default: HError(2719,"HEAdapt: Unknown switch %s",s); } } if (NextArg() != STRINGARG) HError(2719,"HEAdapt: file name of vocabulary list expected"); /* set number of blocks and regression class kind here */ rt->nBlocks = blocks; rt->classKind = regClass; rt->transKind = regTrans; rt->nodeOccThresh = occThresh; rt->adptSil = TRI_UNDEF; if (map && update > 0) { if (mapUseMLLR) { HError(-2741, "HEAdapt: MLLR + MAP adaptation only available is static mode -- switching to static mode"); update = 0; } else { HError(-2740, "HEAdapt: MAP adaptation only available is static mode -- switching to static mode"); update = 0; } } Initialise(fbInfo, &fbInfoStack, &hset, GetStrArg(), rt, transFile); InitUttInfo(utt, twoDataFiles); numUtt = 0; do { if (NextArg()!=STRINGARG) HError(2719,"HEAdapt: data file name expected"); datafn = GetStrArg(); DoForwardBackward(fbInfo, utt, datafn, NULL) ; if (update > 0) { if (((numUtt+1) % update) == 0) { DoAdaptation(rt, global); ClearRegCompStats(&hset, rt); } } numUtt += 1; } while (NumArgs()>0); if (map) { if (mapUseMLLR) DoAdaptation(rt, global); UpdateMAP(rt, tau); } else if (update == 0 || (update > 0 && numUtt%update > 0)) DoAdaptation(rt, global); if (saveTransFN == NULL || map) { if (trace&T_TOP && map) printf("MAP Reest complete -\n\t\taverage log prob per frame = %e (%d)\n", totalPr/totalT, totalT); ConvDiagC(&hset,TRUE); if(SaveHMMSet(&hset,newDir,newExt,saveBinary)<SUCCESS) HError(2710,"HEAdapt: Saving HMMSet failed"); } if (saveTransFN != NULL) { SaveTransformSet(&hset, rt, saveTransFN, newDir, uid, uname, chan, desc, FALSE, global, saveBinary); } Exit(0); return (0); /* never reached -- make compiler happy */}/* -------------------------- Initialisation ----------------------- */void Initialise(FBInfo *fbInfo, MemHeap *x, HMMSet *hset, char *hmmListFn, RegTransInfo *rt, char *transFile){ Boolean loadTransStats=FALSE; /* Load HMMs and init HMMSet related global variables */ if(MakeHMMSet( hset, hmmListFn )<SUCCESS) HError(2728,"Initialise: MakeHMMSet failed"); if(LoadHMMSet( hset,hmmDir,hmmExt)<SUCCESS) HError(2728,"Initialise: LoadHMMSet failed"); SetParmHMMSet(hset); /* needs to be plain or shard system for adaptation purposes */ if (hset->hsKind == TIEDHS || hset->hsKind == DISCRETEHS) HError(2730, "Initialise: MLLR adaptation only available for PLAIN or SHARED systems!"); /* needs to currently be single stream data */ if (hset->swidth[0] != 1) HError(2731, "Initialise: MLLR adaptation only currently available for single stream data"); ConvDiagC(hset,TRUE); InitialiseTransform(hset, ®Stack, rt, TRUE); if (trace & T_TOP) { printf("Updating Mean "); if (rt->transKind == MEANVAR) printf("and Variance "); printf("Transforms\n"); } if (transFile != NULL) { LoadTransformSet(hset, transFile, uid, rt, &loadTransStats); ApplyTransforms(rt); } InitialiseAdapt(hset, ®Stack, rt); SetVFloor(hset, vFloor, minVar); /* initialise and pass information to the forward backward library */ InitialiseForBack(fbInfo, x, hset, rt, (UPDSet) (UPADAPT|UPMIXES), pruneInit, pruneInc, pruneLim, minFrwdP);}/* Load data and call FBFile: apply forward-backward to given utterance */void DoForwardBackward(FBInfo *fbInfo, UttInfo *utt, char * datafn, char * datafn2){ utt->twoDataFiles = twoDataFiles ; utt->S = fbInfo->up_hset->swidth[0]; /* Load the labels */ LoadLabs(utt, lff, datafn, labDir, labExt); /* Load the data */ LoadData(fbInfo->up_hset, utt, dff, datafn, datafn2); if (firstTime) { InitUttObservations(utt, fbInfo->up_hset, datafn, fbInfo->maxMixInS); firstTime = FALSE; } /* fill the alpha beta and otprobs (held in fbInfo) */ if (FBFile(fbInfo, utt, datafn)) { /* update totals */ totalT += utt->T ; totalPr += utt->pr ; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -