コード例 #1
0
ファイル: HLabel.c プロジェクト: nlphacker/OpenSpeech
/* SplitPath: last name in path is removed and prefixed to name, then
              this new name is suffixed to subdir and stored in tryspec */            
static void SplitPath(char *path, char *name, char *subdir, char *tryspec)
{
   char buf1[MAXFNAMELEN],buf2[MAXFNAMELEN],*p;
   char pch[2] = " ";
   
   pch[0] = PATHCHAR;
   PathOf(path,buf1); NameOf(path,buf2);
   if (strlen(name)>0 ) strcat(buf2,pch);    /* new name */
   strcat(buf2,name); strcpy(name,buf2);
   p = buf1+strlen(buf1)-1;                  /* new path */
   if (*p == PATHCHAR) *p = '\0';
   strcpy(path,buf1);   
   strcpy(buf1,subdir);                      /* tryspec */
   p = buf1+strlen(buf1)-1;
   if (*p != PATHCHAR) strcat(buf1,pch);
   strcat(buf1,name);
   strcpy(tryspec,buf1);
}
コード例 #2
0
/* Initialise: load HMMs and create accumulators */
static void Initialise(void)
{
   int s,V;
   Boolean eSep;
   char base[MAXSTRLEN];
   char path[MAXSTRLEN];
   char ext[MAXSTRLEN];

   /* Load HMM defs */     
   if(MakeOneHMM(&hset,BaseOf(hmmfn,base))<SUCCESS)
      HError(2028,"Initialise: MakeOneHMM failed");
   if(LoadHMMSet(&hset,PathOf(hmmfn,path),ExtnOf(hmmfn,ext))<SUCCESS)
      HError(2028,"Initialise: LoadHMMSet failed");
   SetParmHMMSet(&hset);
   if (hset.hsKind==DISCRETEHS || hset.hsKind==TIEDHS)
      HError(2030,"Initialise: HCompV only uses continuous models");

   /* Create a heap to store the input data */
   /*CreateHeap(&iStack,"InBuf", MSTAK, 1, 0.5, 100000, LONG_MAX);*/
   
   /* Get a pointer to the physical HMM */
   hmmId = GetLabId(base,FALSE);
   macroLink = FindMacroName(&hset,'h',hmmId);
   if (macroLink==NULL)
      HError(2020,"Initialise: cannot find hmm %s in hset",hmmfn);
   hmmLink = (HLink)macroLink->structure;

   /* Find out for which streams full covariance is needed */
   CheckVarianceKind( );

   /* Create accumulators for the mean and variance */
   for (s=1;s<=hset.swidth[0]; s++){
      V = hset.swidth[s];
      accs[s].meanSum=CreateVector(&gstack,V);
      ZeroVector(accs[s].meanSum);
      if (fullcNeeded[s]) {
         accs[s].squareSum.inv=CreateSTriMat(&gstack,V);
         accs[s].fixed.inv=CreateSTriMat(&gstack,V);
         ZeroTriMat(accs[s].squareSum.inv);
      }
      else {
         accs[s].squareSum.var=CreateSVector(&gstack,V);
         accs[s].fixed.var=CreateSVector(&gstack,V);
         ZeroVector(accs[s].squareSum.var);
      }
   }

   /* Create an object to hold the input parameters */
   SetStreamWidths(hset.pkind,hset.vecSize,hset.swidth,&eSep);
   obs=MakeObservation(&gstack,hset.swidth,hset.pkind,FALSE,eSep);
   if(segLab != NULL) {
      segId = GetLabId(segLab,TRUE);
   }

   if (trace&T_TOP) {
      printf("Calculating Fixed Variance\n");
      printf("  HMM Prototype: %s\n",hmmfn);
      printf("  Segment Label: %s\n",(segLab==NULL)?"None":segLab);
      printf("  Num Streams  : %d\n",hset.swidth[0]);
      printf("  UpdatingMeans: %s\n",(meanUpdate)?"Yes":"No");
      printf("  Target Direct: %s\n",(outDir==NULL)?"Current":outDir);     
   }
}