Example #1
0
         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 'w':

         mixWeightFloor = MINMIX * GetChkedFlt(0.0,10000.0,s); 

         break;
Example #2
0
bool CThread::MaskListMath(CString sStr, TPStrList& aMasks)
{
	for (int m = 0; m < aMasks.Size(); m++)
		if (MaskMatch(sStr, *aMasks[m]))
			return true;

	return false;
}
/* Accumulate stats from an utterance file */
SpkrAcc *AccGenUtt(char *SpkrPattern, char *UttFileName, SpkrAcc *sa)
{
   char SpkrName[MAXSTRLEN];
   ParmBuf pbuf;
   BufferInfo info;
   short swidth[SMAX];
   Boolean eSep;
   Vector tempV;
   int i;

   if (MaskMatch(SpkrPattern,SpkrName,UttFileName)==TRUE){
      /* open buffer and construct observation */
      pbuf = OpenBuffer(&iStack,UttFileName,0,dff,FALSE_dup,FALSE_dup);
      GetBufferInfo(pbuf,&info);
      if ((info.tgtPK & HASZEROM) && strchr(oflags,'m')) {
         HError(-2021,"HCompV: AccGenUtt: qualifier _Z not appropriate when calculating means!\n");
      }
      /* treat as single stream system though a bit weird */
      ZeroStreamWidths(1,swidth);
      SetStreamWidths(info.tgtPK,info.tgtVecSize,swidth,&eSep);
      obs = MakeObservation(&gstack,swidth,info.tgtPK,FALSE,eSep);
      if (info.tgtVecSize != vSize){
         vSize = info.tgtVecSize;
         /* if needed init a SpkrAcc */
         sa = InitSpkrAcc();
         fprintf(stdout,"Target observation vector size set to %d ......\n",info.tgtVecSize);
         fflush(stdout);
      }
      ParmKind2Str(info.tgtPK,TargetPKStr);
      /* accumulate stats for current utterance file */
      StartBuffer(pbuf);
      while (BufferStatus(pbuf) != PB_CLEARED) 
         {
            /* copy current observation and set vector ptr to first stream */
            ReadAsBuffer(pbuf,&obs);
            tempV = obs.fv[1];
            for (i=1;i<=vSize;i++){
               sa->meanSum[i] += tempV[i];
               sa->squareSum[i] += tempV[i]*tempV[i];
            }
            sa->NumFrame += 1;
         }
      CloseBuffer(pbuf);
      strcpy(sa->SpkrName,SpkrName);
      if (trace&T_CMV){
         fprintf(stdout,"Utterance %s accumulate generated for speaker %s\n",UttFileName,sa->SpkrName);
         fflush(stdout);
      }
      ResetHeap(&iStack);
      return sa;
   }
   else {
      HError(2039,"HCompV: AccGenUtt: speaker pattern matching failure on file: %s\n",UttFileName);
      return NULL;
   }
}
/* Export number of frames, mean, var to a given directory */
void ExportNMV(SpkrAccListItem *sal, char *OutDirName, char *tgtPKStr) 
{
   FILE *oFile;
   Boolean isPipe;
   char oFileName[MAXSTRLEN];
   char pathBuffer1[MAXSTRLEN];
   char pathBuffer2[MAXSTRLEN];
   SpkrAccListItem *p;
   int i;

   p = sal;
   while(p != NULL){
      /* create output file name for current spkr index */    
      if ( pathPattern[0] != '\0'){
         if ( MaskMatch(pathPattern,pathBuffer1,p->sa->SpkrName) != TRUE ){
            HError(2039,"HCompV: ExportNMV: path pattern matching failure on speaker: %s\n",p->sa->SpkrName);
         }
         MakeFN(pathBuffer1,OutDirName,NULL,pathBuffer2); 
         MakeFN(p->sa->SpkrName,pathBuffer2,NULL,oFileName);
      }
      else
         MakeFN(p->sa->SpkrName,OutDirName,NULL,oFileName);

      /* open and write */
      oFile = FOpen(oFileName,NoOFilter,&isPipe);
      if (oFile == NULL){
         HError(2011,"HCompV: ExportNMV: output file creation error %s",oFileName);
      }
    
      /* write header */
      fprintf(oFile,"<CEPSNORM> <%s>",tgtPKStr);
    
      /* write number frames */
      if (strchr(oflags,'n')){
         fprintf(oFile,"\n<NFRAMES> %d",p->sa->NumFrame);
      }
      /* write mean */
      if (strchr(oflags,'m')){
         fprintf(oFile,"\n<MEAN> %d\n",vSize);
         for (i=1;i<=vSize;i++){
            fprintf(oFile," %e",(p->sa->meanSum[i]));
         }
      }
      /* write variance */
      if (strchr(oflags,'v')){   
         fprintf(oFile,"\n<VARIANCE> %d\n",vSize);
         for (i=1;i<=vSize;i++){
            fprintf(oFile," %e",(p->sa->squareSum[i]));
         }
      }
      fprintf(oFile,"\n");
      FClose(oFile,isPipe);
      p = p->nextSpkr;
   }
}
Example #5
0
/* DoAlignment: by creating network from transcriptions or lattices */
void DoAlignment(void)
{
   FILE *nf;
   char lfn[MAXSTRLEN], buf[MAXSTRLEN];
   Transcription *trans;
   Network *net;
   Boolean isPipe;
   int n=0;
   LogDouble currGenBeam;
   AdaptXForm *incXForm;

   if (trace&T_TOP) {
      if (loadNetworks) 
         printf("New network will be used for each file\n");
      else
         printf("Label file will be used to align each file\n");
      fflush(stdout);
   }
   CreateHeap(&netHeap,"Net heap",MSTAK,1,0,8000,80000);
   while (NumArgs()>0) {
      if (NextArg() != STRINGARG)
         HError(3219,"DoAlignment: Data file name expected");
      datFN = GetStrArg();
      if (trace&T_TOP) {
         printf("Aligning File: %s\n",datFN);  fflush(stdout);
      }
      if (labFileMask != NULL ) { /* support for rescoring lattice masks */
         if (!MaskMatch(labFileMask,buf,datFN))
            HError(2319,"DoAlignment: mask %s has no match with segemnt %s",labFileMask,datFN);
         MakeFN(buf,labInDir,labInExt,lfn);
      } else {
         MakeFN(datFN,labInDir,labInExt,lfn);
      }
      if (loadNetworks) {
         if ( (nf = FOpen(lfn,NetFilter,&isPipe)) == NULL)
            HError(3210,"DoAlignment: Cannot open Word Net file %s",lfn);
         if((wdNet = ReadLattice(nf,&netHeap,&vocab,TRUE,FALSE))==NULL)
            HError(3210,"DoAlignment: ReadLattice failed");
         FClose(nf,isPipe);
         if (trace&T_TOP) {
            printf("Read lattice with %d nodes / %d arcs\n",
                   wdNet->nn,wdNet->na);
            fflush(stdout);
         }
      }
      else {
         LabList *ll = NULL;

         trans=LOpen(&netHeap,lfn,ifmt);
         if (trans->numLists >= 1)
            ll = GetLabelList(trans,1);
         if (!ll && !bndId)
            HError(3233, "DoAlignment: cannot align empty transcription");

         wdNet=LatticeFromLabels(ll, bndId, &vocab,&netHeap);
         if (trace&T_TOP) {
            printf("Created lattice with %d nodes / %d arcs from label file\n",
                   wdNet->nn,wdNet->na);
            fflush(stdout);
         }
      }
      net=ExpandWordNet(&netHeap,wdNet,&vocab,&hset);

      ++n;
      currGenBeam = genBeam;
      /* This handles the initial input transform, parent transform setting
	 and output transform creation */
      if (UpdateSpkrStats(&hset, &xfInfo, datFN) && (!(xfInfo.useInXForm)) && (hset.semiTied == NULL)) {
         xfInfo.inXForm = NULL;
      }
      if (genBeamInc == 0.0)
         ProcessFile (datFN, net, n, currGenBeam, FALSE);
      else {
         Boolean completed;

         completed = ProcessFile (datFN, net, n, currGenBeam, TRUE);
         currGenBeam += genBeamInc;
         while (!completed && (currGenBeam <= genBeamLim - genBeamInc)) {
            completed = ProcessFile (datFN, net, n, currGenBeam, TRUE);
            currGenBeam += genBeamInc;
         }
         if (!completed)
            ProcessFile (datFN, net, n, currGenBeam, FALSE);
      }

      if (update > 0 && n%update == 0) {
         if (trace&T_TOP) {
            printf("Transforming model set\n");
            fflush(stdout);
         }
	 /* 
	    at every stage a new transform is created - fix?? 
	    Estimate transform and then set it up as the 
	    input XForm
	 */
	 incXForm = CreateAdaptXForm(&hset,"inc");
         TidyBaseAccs();
	 GenAdaptXForm(&hset,incXForm);
         xfInfo.inXForm = GetMLLRDiagCov(incXForm);;
	 SetXForm(&hset,xfInfo.inXForm);
	 ApplyHMMSetXForm(&hset,xfInfo.inXForm);
      }
      ResetHeap(&netHeap);
   }
}