[hts-users:02312] A bug in HHEd.c:FloorAverageCommand()
Hi,
I found a bug in HHEd.c:FloorAverageCommand(): it doesn't support multi-stream
and/or MSD HMMs. The attached patch code fixes this problem.
Best regards,
Heiga ZEN (Byung Ha CHUN)
--
--------------------------
Heiga ZEN (Byung Ha CHUN)
Speech Technology Group
Cambridge Research Lab
Toshiba Research Europe
phone: +44 1223 436975
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________--- HHEd.c 2008-08-07 13:36:19.341080000 +0000
+++ HHEd.c 2009-12-14 10:36:38.490135000 +0000
@@ -6572,11 +6681,12 @@
StreamInfo *sti;
SVector var , mean;
DVector *varAcc;
- double occAcc;
+ double occAcc[SMAX];
float weight;
- float occ;
+ float occ,occs;
int l=0,k,i,s,S;
float varScale;
+ Boolean singleMix;
/* need stats for operation */
if (!occStatsLoaded)
@@ -6595,36 +6705,55 @@
ZeroDVector(varAcc[s]);
}
NewHMMScan(hset,&hss);
- occAcc = 0.0;
+ for (s=1; s<=hset->swidth[0]; s++) occAcc[s] = 0.0;
while(GoNextState(&hss,FALSE)) {
si = hss.si;
- memcpy(&occ,&(si->hook),sizeof(float));
- occAcc += occ;
- s=0;
while (GoNextStream(&hss,TRUE)) {
- l=hset->swidth[hss.s];
+ s=hss.s;
+ l=hset->swidth[s];
sti = hss.sti;
- s++;
- if ( hss.M > 1 ) {
+ memcpy(&occ,&(sti->hook),sizeof(float));
+
+ /* single/multiple mix check */
+ for (i=1,k=0; i<=hss.M; i++) {
+ if (hset->swidth[s] == VectorSize(sti->spdf.cpdf[i].mpdf->mean)) /* MSD check */
+ k++;
+ }
+ singleMix = (k==1) ? TRUE : FALSE;
+
+ /* accumulate statistics */
+ if ( !singleMix ) {
+ occs = 0.0;
for (k=1;k<=l;k++) { /* loop over k-th dimension */
double rvar = 0.0;
double rmean = 0.0;
for (i=1; i<=hss.M; i++) {
+ if (VectorSize(sti->spdf.cpdf[i].mpdf->mean) == l) { /* MSD check */
weight = sti->spdf.cpdf[i].weight;
var = sti->spdf.cpdf[i].mpdf->cov.var;
mean = sti->spdf.cpdf[i].mpdf->mean;
rvar += weight * ( var[k] + mean[k] * mean[k] );
rmean += weight * mean[k];
+
+ if (k==1) occs += weight * occ;
+ }
}
rvar -= rmean * rmean;
- varAcc[s][k] += rvar * occ ;
+ varAcc[s][k] += rvar * occs ;
}
+ occAcc[s] += occs;
}
- else { /* single mix */
- var = sti->spdf.cpdf[1].mpdf->cov.var;
+ else { /* single mix (single space matches the stream weight) */
+ for (i=1; i<=hss.M; i++) {
+ if (VectorSize(sti->spdf.cpdf[i].mpdf->mean) == l) {
+ weight = sti->spdf.cpdf[i].weight;
+ var = sti->spdf.cpdf[i].mpdf->cov.var;
for (k=1;k<=l;k++)
- varAcc[s][k] += var[k]*occ;
+ varAcc[s][k] += occ * weight * var[k];
+ occAcc[s] += occ * weight;
+ }
+ }
}
}
}
@@ -6632,7 +6761,8 @@
/* normalisation */
for (s=1;s<=S;s++)
for (k=1;k<=hset->swidth[s];k++)
- varAcc[s][k] /= occAcc;
+ varAcc[s][k] /= occAcc[s];
+
/* set the varFloorN macros */
for (s=1; s<=S; s++){
int size;
@@ -6657,7 +6787,7 @@
NewMacro(hset,hset->numFiles,'v',id,v);
}
/* scale and store */
- for (k=1;k<=l;k++)
+ for (k=1;k<=hset->swidth[s];k++)
v[k] = varAcc[s][k]*varScale;
}
/* and apply floors */