/* AppendLabs: append label file corresponding to src to trans, len is time length of this file; accumulate to find offset for concatenated files */ void AppendLabs(Transcription *t, HTime len) { LabList *ll,*transll; LLink p,q; int maxAux; if(trace & T_SEGMENT) printf("Adding labels, len: %.0f off: %.0f\n",len,off); if(trans == NULL) trans = CopyTranscription(&lStack, t); else for (ll = t->head,transll = trans->head; ll != NULL; ll = ll->next,transll = transll->next){ if (transll == NULL) HError(1031,"AppendLabs: lablist has no target to append to"); maxAux = ll->maxAuxLab; if (maxAux > transll->maxAuxLab){ HError(-1031,"AppendLabs: truncating num aux labs from %d down to %d", maxAux, transll->maxAuxLab); maxAux = transll->maxAuxLab; } for (p=ll->head->succ; p->succ!= NULL; p=p->succ){ q = AddLabel(&lStack,transll, p->labid,p->start + off,p->end + off,p->score); if (maxAux>0) AddAuxLab(q,maxAux,p->auxLab,p->auxScore); } } /* accumulate length of this file for total offset */ off += len; }
/* EXPORT->CopyLabelList: return a copy of given label list */ LabList* CopyLabelList(MemHeap *x, LabList* ll) { LabList *newll; LLink p,q; newll = CreateLabelList(x,ll->maxAuxLab); for (q=ll->head->succ; q->succ != NULL; q = q->succ){ p = AddLabel(x,newll,q->labid,q->start,q->end,q->score); if (ll->maxAuxLab > 0) AddAuxLab(p,ll->maxAuxLab,q->auxLab,q->auxScore); } return newll; }
/* LoadHTKList: load a single HTK label list - dont create anything if transAlt>0 and alt != transAlt */ static LabList * LoadHTKList(MemHeap *x, Source *src, int alt) { LabList *ll = NULL; LabId labid, auxLab[100]; LLink p = NULL; HTime start,end; float score, auxScore[100]; int n,maxAux = 0; Boolean ok; ok = ((transAlt==0) || (transAlt == alt)) ? TRUE : FALSE; if (ok) ll = CreateLabelList(x,maxAux); /* assume no aux labels */ if (trace&T_HTKL) printf("HLabel: looking for lab list\n"); while (trSym==TRNUM || trSym==TRSTR){ start = -1; end = -1; score = 0.0; if (trSym==TRNUM) { start = trNum; GetTrSym(src,TRUE); start *= htkLabelTimeScale; if (trSym==TRNUM) { end = trNum; GetTrSym(src,TRUE); end *= htkLabelTimeScale; } } if (trSym != TRSTR) HError(6550,"LoadHTKList: Label Name Expected"); labid = GetLabId(trStr,TRUE); GetTrSym(src,TRUE); if (trSym==TRNUM){ score = trNum; GetTrSym(src,TRUE); } if (trace&T_HTKL) printf("HLabel: adding %.0f %.0f %s %f\n",start,end,labid->name,score); if (ok) p = AddLabel(x,ll,labid,start,end,score); /* Any aux labels ? */ n = 0; while (trSym != TREOL && trSym!=TREOF) { n++; if (trSym != TRSTR) HError(6550,"LoadHTKList: Aux Label Name Expected"); auxLab[n] = GetLabId(trStr,TRUE); if (trace&T_HTKL) printf("HLabel: adding aux lab %d = %s\n",n,auxLab[n]->name); GetTrSym(src,TRUE); if (trSym==TRNUM){ auxScore[n] = trNum; if (trace&T_HTKL) printf("HLabel: adding aux score %d = %f\n",n,trNum); GetTrSym(src,TRUE); } else auxScore[n] = 0.0; } if (ok && n>0) { /* need to add aux info */ if (n>maxAux) { ExtendAux(x,ll,n); maxAux = n; } else while (n<maxAux) { ++n; auxLab[n] = NULL; auxScore[n] = 0.0; } AddAuxLab(p,n,auxLab,auxScore); } if (trSym!=TREOF) GetTrSym(src,TRUE); } return ll; }