当前位置: 首页>>代码示例>>C++>>正文


C++ HError函数代码示例

本文整理汇总了C++中HError函数的典型用法代码示例。如果您正苦于以下问题:C++ HError函数的具体用法?C++ HError怎么用?C++ HError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了HError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UpWeights

/* UpWeights: update given mixture weights */
void UpWeights(int i, int s, int M, WtAcc *wa, StreamElem *ste)
{
   int m;
   float sum=0.0;
   
   if (wa->occ == 0.0)
      HError(2127,"UpWeights: zero occ i=%d/s=%d",i,s);
   for (m=1; m<=M; m++){
      sum += wa->c[m];
      switch(hset.hsKind){
      case PLAINHS:
      case SHAREDHS:
         ste->spdf.cpdf[m].weight = wa->c[m] / wa->occ;
         break;
      case TIEDHS:
         ste->spdf.tpdf[m] = wa->c[m] / wa->occ;
         break;
      }
   }
   if (fabs(sum-wa->occ)/sum > 0.001)
      HError(2190,"UpWeights: mix weight sum error");
}
开发者ID:cfxccn,项目名称:HTKLocker,代码行数:23,代码来源:Tool_HInit.c

示例2: UpMeans

/* UpMeans: update mean, leave old mean in acc */
void UpMeans(int i, int s, int m, int size, MuAcc *ma, Vector mean)
{
   int k;
   float x;
   
   if (ma->occ == 0.0)
      HError(2127,"UpMeans: zero occ i=%d/s=%d/m=%d",i,s,m);
   for (k=1; k<=size; k++){
      x = mean[k] + ma->mu[k]/ma->occ;
      ma->mu[k] = mean[k];  /* remember old mean */
      if (uFlags&UPMEANS) mean[k] = x;
   }
}
开发者ID:cfxccn,项目名称:HTKLocker,代码行数:14,代码来源:Tool_HInit.c

示例3: FloorMixes

/* FloorMixes: apply floor to given mix set */
void FloorMixes(HMMSet *hset, MixtureElem *mixes, int M, float floor)
{
   float sum,fsum,scale;
   MixtureElem *me;
   int m;
   
   if (hset->logWt == TRUE) HError(999,"FloorMixes requires linear weights");
   sum = fsum = 0.0;
   for (m=1,me=mixes; m<=M; m++,me++) {
      if (MixWeight(hset,me->weight)>floor)
         sum += me->weight;
      else {
         fsum += floor; me->weight = floor;
      }
   }
   if (fsum>1.0) HError(2327,"FloorMixes: Floor sum too large");
   if (fsum == 0.0) return;
   if (sum == 0.0) HError(2328,"FloorMixes: No mixture weights above floor");
   scale = (1.0-fsum)/sum;
   for (m=1,me=mixes; m<=M; m++,me++)
      if (me->weight>floor) me->weight *= scale;
}
开发者ID:2hanson,项目名称:voice_dialling,代码行数:23,代码来源:HERest.c

示例4: CheckUpdateSetUp

void CheckUpdateSetUp()
{
  AdaptXForm *xf;

  xf = xfInfo.paXForm;
  if ((xfInfo.paXForm != NULL) && !(uFlags&UPXFORM)) {
    while (xf != NULL) {
       if ((xf->xformSet->xkind != CMLLR) && (xf->xformSet->xkind != SEMIT))
	HError(999,"SAT only supported with SEMIT/CMLLR transforms");
      xf = xf->parentXForm;
    }
  }
}
开发者ID:2hanson,项目名称:voice_dialling,代码行数:13,代码来源:HERest.c

示例5: GenSentences

/* GenSentences: top level control of the sentence generator */
void  GenSentences(char * latfn, char * dicfn)
{
   int i,min,max,len;
   double e,p;
   MemHeap lheap;
   FILE *f;
   Boolean isPipe;

   InitVocab(&voc);
   if(ReadDict(dicfn,&voc)<SUCCESS)
      HError(3413,"GenSententces:ReadDict failed" );
   CreateHeap(&lheap,"Lattice Heap",MSTAK,1,0.4,1000,5000);
   if ((f=FOpen(latfn,NetFilter,&isPipe)) == NULL)
      HError(3410,"GenSentences: Can't open lattice file %s",latfn);
   if((lat = ReadLattice(f, &lheap, &voc, TRUE, FALSE))==NULL)
      HError(3410,"GenSentences: ReadLattice failed");
   FClose(f,isPipe);

   if (trace&T_TOP)
      printf("HSGen %d sents from lattice %s/dictionary %s\n",
             ngen,latfn,dicfn);
   psSum = 0.0; lenSum = 0; min = 100000; max = 0;
   if (trace&T_DET) quiet = TRUE;  /* kill output if detailed trace */
   for (i=1; i<=ngen; i++){
      len = GenSent(i);
      lenSum += len;
      if (len>max) max = len;
      if (len<min) min = len;
   }
   if (stats)  {
      ComputeVSize();
      e = psSum / lenSum;
      p = exp(e);
      e = e / log(2.0);
      printf("Entropy = %f,  Perplexity = %f\n",e,p);
      printf("%d Sentences: average len = %.1f, min=%d, max=%d\n",
             ngen,(float)lenSum/ngen,min,max);
   }
}
开发者ID:nlphacker,项目名称:OpenSpeech,代码行数:40,代码来源:HSGen.c

示例6: GetNode

/* GetNode: read a node definition and create node */
static VQNode GetNode(Source *src, CovKind ck, short width)
{
   char buf[MAXSTRLEN];
   VQNode n;
   short vqidx,nid,lid,rid;
   Vector mean;
   Covariance cov;

   vqidx = GetVal(src,0,0,"VQ Index");
   nid = GetVal(src,0,0,"Node Id");
   lid = GetVal(src,0,0,"Left Id");
   rid = GetVal(src,0,0,"Right Id");
   mean = CreateVector(&vqHeap,width);
   if (!ReadVector(src, mean, FALSE))
      HError(6150,"GetNode: cannot read mean vector at %s",
             SrcPosition(*src, buf));
   switch(ck){
   case NULLC:
      cov.var = NULL;
      n = CreateVQNode(vqidx,nid,lid,rid,mean,ck,cov);
      break;
   case INVDIAGC:
      cov.var = CreateVector(&vqHeap,width);
      if (!ReadVector(src, cov.var, FALSE))
         HError(6150,"GetNode: cannot read variance vector at %s",
                SrcPosition(*src, buf));
      n = CreateVQNode(vqidx,nid,lid,rid,mean,ck,cov);
      break;
   case FULLC:
      cov.inv = CreateTriMat(&vqHeap,width);
      if (!ReadTriMat(src, cov.inv, FALSE))
         HError(6150,"GetNode: cannot read covariance matrix at %s",
                SrcPosition(*src, buf));
      n = CreateVQNode(vqidx,nid,lid,rid,mean,ck,cov);
      break;
   }
   return n;
}
开发者ID:deardaniel,项目名称:PizzaTest,代码行数:39,代码来源:HVQ.c

示例7: LoadMasterFile

/* EXPORT->LoadMasterFile: Load the Master Label File stored in fname 
                           and append the entries to the MLF table */
void LoadMasterFile(char *fname)
{
   char buf[MAXFNAMELEN];
   char *men;        /* end of mode indicator */
   char *pst,*pen;   /* start/end of pattern (inc quotes) */
   char *dst=NULL,*den=NULL;   /* start/end of subdirectory (inc quotes) */
   Boolean inEntry = FALSE;   /* ignore ".." within an entry */
   MLFEntry *e;
   FILE *f;
   
   if (numMLFs == MAXMLFS)
      HError(6520,"LoadMasterFile: MLF file limit reached [%d]",MAXMLFS);
   if ((f = fopen(fname,"rb")) == NULL)
      HError(6510,"LoadMasterFile: cannot open MLF %s",fname);
   if (fgets(buf,MAXFNAMELEN,f) == NULL)
      HError(6513,"LoadMasterFile: MLF file is empty");
   if (NoMLFHeader(buf))
      HError(6551,"LoadMasterFile: MLF file header is missing"); 
   incSpaces=FALSE;
   while (fgets(buf,MAXFNAMELEN,f) != NULL){
      if (!inEntry && FindMLFStr(buf,&pst,&pen)) {
         e = (MLFEntry *)New(&mlfHeap,sizeof(MLFEntry));
         e->type = FindMLFType(pen+1,&men);
         if (e->type == MLF_IMMEDIATE) {
            e->def.immed.fidx = numMLFs;
            e->def.immed.offset = ftell(f);
            if (e->def.immed.offset < 0)
               HError(6521,"LoadMasterFile: cant ftell on MLF file");
            inEntry = TRUE;
         } else {
            if (!FindMLFStr(men+1,&dst,&den))
               HError(6551,"LoadMasterFile: Missing subdir in MLF\n(%s)",buf);
            *den = '\0';
            e->def.subdir = NewString(&mlfHeap,den-dst-1);
            strcpy(e->def.subdir,dst+1);
         }
         *pen = '\0';         /* overwrite trailing pattern quote */
         ++pst;               /* skipover leading pattern quote */
         e->patType = ClassifyMLFPattern(pst);
         if (e->patType == PAT_ANYPATH) 
            pst += 2;         /* skipover leading "* /" */
         e->pattern = NewString(&mlfHeap,pen-pst);
         strcpy(e->pattern,pst);
         e->patHash = (e->patType==PAT_GENERAL)?0:MLFHash(e->pattern);
         StoreMLFEntry(e);
      } else
         if (inEntry && IsDotLine(buf)) inEntry = FALSE;
   }
   if (compatMode && incSpaces)
      HError(-6551,"LoadMasterFile: . or %s on line with spaces in %s",
             LEVELSEP,fname);
   mlfile[numMLFs++] = f;
}
开发者ID:nlphacker,项目名称:OpenSpeech,代码行数:55,代码来源:HLabel.c

示例8: ASpec2LPCep

/* EXPORT->ASpec2LPCep: Perform IDFT to get autocorrelation values then 
           produce autoregressive coeffs. and cepstral transform them */
void ASpec2LPCep (Vector as, Vector ac, Vector lp, Vector c, DMatrix cm)
{
   float lpcGain, E;

   /* Do IDFT to get autocorrelation values */
   E = MatrixIDFT(as, ac, cm);
   lp[VectorSize(lp)] = 0.0;    /* init to make Purify et al. happy */
   /* do Durbin recursion to get predictor coefficients */
   lpcGain = Durbin(NULL,lp,ac,E,VectorSize(ac)-1);
   if (lpcGain<=0) 
      HError(-5323,"ASpec2LPCep: Negative lpcgain");
   LPC2Cepstrum(lp,c);
   c[VectorSize(c)] = (float) -log((double) 1.0/lpcGain); /* value forms C0 */
}
开发者ID:2hanson,项目名称:voice_dialling,代码行数:16,代码来源:HSigP.c

示例9: StoreOOV

/* StoreOOV: store OOV wdid/count into ps */
static void StoreOOV(PStats *ps, LabId wdid, int count)
{
   int n;

   ps->oov[ps->uniqOOV].wdid  = wdid;
   ps->oov[ps->uniqOOV].count = count;
   ps->uniqOOV++; ps->nOOV++;
   if (ps->uniqOOV==MAX_OOV) {
     n = SortOOV(ps);
     printf("StoreOOV: sorting OOVs, compacting %d -> %d\n",MAX_OOV,n);
     if (n==MAX_OOV)
       HError(16630,"Maximum number of unique OOV's [%d] reached\n",MAX_OOV);
  }
}
开发者ID:DorisGao,项目名称:personal-uni,代码行数:15,代码来源:LPlex.c

示例10: UpTrans

/* UpTrans: update transition parameters */
void UpTrans(TrAcc *ta, Matrix tr)
{
   int i,j;
   float occi,x,sum;

   for (i=1; i<nStates; i++){
      occi = ta->occ[i];
      if (occi == 0.0)
         HError(2127,"UpTrans: zero occ in state %d",i);
      sum = 0.0;
      tr[i][1] = LZERO;
      for (j=2;j<=nStates;j++) {
         x = ta->tran[i][j]/occi;
         tr[i][j] = x; sum += x;
      }
      if (fabs(sum-1.0) > 0.001)
         HError(2190,"UpTrans: row %d, sum=%f",i,sum,occi);
      for (j=2;j<=nStates;j++) {
         x = tr[i][j]/sum;
         tr[i][j] = (x<MINLARG) ? LZERO : log(x);
      }
   }
}
开发者ID:songzhengxuan,项目名称:kata,代码行数:24,代码来源:HInit.c

示例11: FindVQTable

/* FindVQTable: find VQ table with given name and unless magic is 0, check
                that it is same, return NULL if not found */
static VQTable FindVQTable(char * tabFN, short magic)
{
   Boolean found=FALSE;
   VQTable p;

   for (p=vqList; p!=NULL && !found; p=p->next)
      if (strcmp(tabFN,p->tabFN)==0){
         if (magic != 0 && magic != p->magic)
            HError(6170,"FindVQTable: %s has magic=%d but new magic=%d",
                   tabFN,p->magic,magic);
         return p;
      }
   return NULL;
}
开发者ID:deardaniel,项目名称:PizzaTest,代码行数:16,代码来源:HVQ.c

示例12: FindBestMixes

/* FindBestMixes: for each state/obs pair find most likely mix component */
void FindBestMixes(int segNum, int segLen, IntVec states, IntVec *mixes)
{
   int i,s,m,bestm,M=0;
   StreamElem *ste;
   IntVec smix;
   Observation obs;
   Vector v;
   LogFloat bestP,p;
   MixtureElem *me;
   MixPDF *mp;

   if (trace&T_MIX)
      printf(" Mixture component alignment\n");
   for (i=1; i<=segLen; i++){
      ste = hmmLink->svec[states[i]].info->pdf+1;
      obs = GetSegObs(segStore, segNum, i);
      if (hset.hsKind == TIEDHS)
         PrecomputeTMix(&hset, &obs, 0.0, 1);
      for (s=1; s<=nStreams; s++,ste++){
         if (hset.hsKind != TIEDHS)
            M = ste->nMix;
         smix = mixes[s];
         if (hset.hsKind==TIEDHS) /* PrecomputeTMix has already sorted probs */
            bestm = hset.tmRecs[s].probs[1].index;
         else if (M==1)
            bestm = 1;   
         else{
            v = obs.fv[s];
            bestP = LZERO; bestm=0;
            if (trace&T_MIX)
               printf("  seg %d, stream %d: ",i,s);
            for (m=1; m<=M; m++){
               me =  ste->spdf.cpdf+m;
               mp = me->mpdf;
               p = MOutP(v,mp);
               if (p>bestP){
                  bestP=p; bestm=m;
               }
               if (trace&T_MIX)
                  printf(" P(mix[%d])=%.1f",m,p);
            }
            if (bestm==0)
               HError(2125,"FindBestMixes: no best mix");
            if (trace&T_MIX)
               printf(" [best=%d]\n",bestm);
         }
         smix[i] = bestm;
      }
   }
}
开发者ID:songzhengxuan,项目名称:kata,代码行数:51,代码来源:HInit.c

示例13: LoadNetwork

void LoadNetwork()
{
   FILE *nf;
   Boolean isPipe;
   int n=0;

   CreateHeap(&wdNetHeap,"Lattice heap",MSTAK,1,0.0,4000,4000);
   if ( (nf = FOpen(wdNetFn,NetFilter,&isPipe)) == NULL)
      HError(3210,"LoadNetwork: Cannot open Word Net file %s",wdNetFn);
   if((wdNet = ReadLattice(nf,&wdNetHeap,&vocab,TRUE,FALSE))==NULL)
      HError(3210,"LoadNetwork: ReadLattice failed");
   FClose(nf,isPipe);

   printf("Read Word Network with %d nodes / %d arcs\n",wdNet->nn,wdNet->na);

   CreateHeap(&netHeap,"Net heap",MSTAK,1,0,
      wdNet->na*sizeof(NetLink),wdNet->na*sizeof(NetLink));

   net = ExpandWordNet(&netHeap,wdNet,&vocab,&hset);
   printf("Created network with %d nodes / %d links\n",
      net->numNode,net->numLink);

}
开发者ID:deardaniel,项目名称:PizzaTest,代码行数:23,代码来源:HNetTest.c

示例14: GetVQ

/* EXPORT->GetVQ: get vq indices for vectors in fv */
void GetVQ(VQTable vqTab, int numS, Vector *fv, short *vq)
{
   short s,idx,size;
   float bestx, x,xl,xr;
   VQNode n,bestn;
   Vector v;

   for (s=1; s<=numS; s++) {
      n = vqTab->tree[s]; v = fv[s];
      size = VectorSize(v);
      if (n==NULL)
         HError(6174,"GetVQ: null tree in stream %d",s);
      if (size != vqTab->swidth[s])
         HError(6174,"GetVQ: stream %d width incompatible",s);
      switch(vqTab->type){
      case linTree:
         bestn = n; bestx = VQNodeScore(n,v,size,vqTab->ckind);
         for(n=bestn->right; n != NULL; n=n->right){
            x = VQNodeScore(n,v,size,vqTab->ckind);
            if (x<bestx) {
               bestx = x; bestn = n;
            }
         }
         idx = bestn->vqidx;
         break;
      case binTree:
         while (n->right != NULL){
            xr = VQNodeScore(n->right,v,size,vqTab->ckind);
            xl = VQNodeScore(n->left,v,size,vqTab->ckind);
            n =  (xr<xl)?n->right:n->left;
         }
         idx = n->vqidx;
         break;
      }
      vq[s] = idx;
   }
}
开发者ID:deardaniel,项目名称:PizzaTest,代码行数:38,代码来源:HVQ.c

示例15: LoadHTKLabels

/* LoadHTKLabels: load a HTK transcription */
static void LoadHTKLabels(MemHeap *x, Transcription *t, Source *src)
{
   LabList *ll;
   int alt = 0;
   
   InitTrScan();
   GetTrSym(src,TRUE);
   if (trSym==TRNUM || trSym==TRSTR){
      ll = LoadHTKList(x,src,++alt);
      AddLabelList(ll,t);
      while (trSym == TRLEV){
         GetTrSym(src,TRUE);
         if (trSym != TREOL)
            HError(6550,"LoadHTKList: End of Line after /// Expected");       
         GetTrSym(src,TRUE);
         ll = LoadHTKList(x,src,++alt);
         AddLabelList(ll,t);
      }
   }
   while (trSym==TREOL) 
      GetTrSym(src,TRUE);
   if (trSym != TREOF)
      HError(6550,"LoadHTKLabels: Junk at end of HTK transcription");
}
开发者ID:nlphacker,项目名称:OpenSpeech,代码行数:25,代码来源:HLabel.c


注:本文中的HError函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。