Example #1
0
bool CFont::InitModel()
{
  static CStrAny sPlain(ST_CONST, "Plain");
  static CStrAny sg_mWorld(ST_CONST, "g_mWorld");
  static CStrAny sg_mView(ST_CONST, "g_mView");
  static CStrAny sg_mProj(ST_CONST, "g_mProj");
  static CStrAny sg_mTexTransform(ST_CONST, "g_mTexTransform");
  static CStrAny sg_cMaterialDiffuse(ST_CONST, "g_cMaterialDiffuse");
  static CStrAny sg_txDiffuse(ST_CONST, "g_txDiffuse");
  static CStrAny sg_sDiffuse(ST_CONST, "g_sDiffuse");

  ASSERT(!m_pTextModel);
  bool bRes;
  CTechnique *pTech = CGraphics::Get()->GetTechnique(sPlain);
  if (!pTech)
    return false;
  CSmartPtr<CGeometry> pGeom(new CGeometry());
  bRes = pGeom->Init(pTech->m_pInputDesc, CGeometry::PT_TRIANGLELIST, INIT_BUFFER_CHARS * 4, INIT_BUFFER_CHARS * 6, 0, 0, 
                     CResource::RF_DYNAMIC | CResource::RF_KEEPSYSTEMCOPY, CResource::RF_DYNAMIC | CResource::RF_KEEPSYSTEMCOPY);
  if (!bRes) 
    return false;
  CSmartPtr<CMaterial> pMaterial(new CMaterial());
  bRes = pMaterial->Init(pTech, true, 0);
  if (!bRes)
    return false;
  CSmartPtr<CModel> pModel(new CModel());
  bRes = pModel->Init(pGeom, pMaterial, 0, false);
  if (!bRes) 
    return false;

  m_pTextModel = pModel;

  CMatrix<4, 4> mIdentity;
  mIdentity.SetDiagonal();
  CMatrixVar vMat(4, 4, CMatrixVar::MVF_OWNVALUES, &mIdentity(0, 0));
  m_pTextModel->SetVar(sg_mProj, vMat);
  m_pTextModel->SetVar(sg_mView, vMat);
  m_pTextModel->SetVar(sg_mWorld, vMat);
  CMatrix<3, 2> mTexIdentity;
  mTexIdentity.SetDiagonal();
  CMatrixVar vTexMat(3, 2, CMatrixVar::MVF_OWNVALUES, &mTexIdentity(0, 0));
  m_pTextModel->SetVar(sg_mTexTransform, vTexMat);
  CVar<CVector<4> > vVec4;
  vVec4.Val().Set(1, 1, 1, 1);
  m_pTextModel->SetVar(sg_cMaterialDiffuse, vVec4);

  CVar<CTexture *> vTexVar;
  vTexVar.Val() = m_pTexture;
  m_pTextModel->SetVar(sg_txDiffuse, vTexVar);

  CVar<CSampler *> vSampVar;
  vSampVar.Val() = CGraphics::Get()->GetSampler(CSampler::TDesc());
  m_pTextModel->SetVar(sg_sDiffuse, vSampVar);

  ResetModel();

  return true;
}
Example #2
0
int main(int argc, char *argv[])
{
   char *datafn, *s;
   int stream = 0;
   void Initialise(char *datafn);
   void LoadFile(char *fn);
   void CalcMeanCov(Sequence seq[], int s);
   void ClusterVecs(Sequence seq[], int s);
   void WriteVQTable(ClusterSet *cs[], char *fn);  

   if(InitShell(argc,argv,hquant_version,hquant_vc_id)<SUCCESS)
      HError(2500,"HQuant: InitShell failed");

   InitMem();   InitLabel();
   InitMath();  InitSigP();
   InitWave();  InitAudio();
   InitVQ();    InitModel();
   if(InitParm()<SUCCESS)  
      HError(2500,"HQuant: InitParm failed");
   InitTrain();

   if (!InfoPrinted() && NumArgs() == 0)
      ReportUsage();
   if (NumArgs() == 0) Exit(0);
   SetConfParms();
   InitStreamVars();

   while (NextArg() == SWITCHARG) {
      s = GetSwtArg();
      if (strlen(s)!=1) 
         HError(2519,"HQuant: Bad switch %s; must be single letter",s);
      switch(s[0]){
      case 'd':
         if ( ck != NULLC) HError(2519,"HQuant: Specify one of -d or -f, not both");
         ck = INVDIAGC;
         break;
      case 'f':
         if ( ck != NULLC) HError(2519,"HQuant: Specify one of -d or -f, not both");
         ck = FULLC;
         break;
      case 'g':
         globClustVar = TRUE;
         break;
      case 'l':
         if (NextArg() != STRINGARG)
            HError(2519,"HQuant: Segment label expected");
         segLab = GetStrArg();
         break;
      case 'n':
         if (NextArg() != INTARG)
            HError(2519,"HQuant: Stream number expected");
         stream = GetChkedInt(1,SMAX,s);
         if (NextArg() != INTARG)
            HError(2519,"HQuant: Codebook size expected");
         cbSizes[stream]= GetChkedInt(1,32768,s);
         break;
      case 's':
         if (NextArg() != INTARG)
            HError(2519,"HQuant: Number of streams expected");
         swidth[0] = GetChkedInt(1,SMAX,s);
         break;
      case 't':
         tType = binTree;
         break;
      case 'w':
         if (NextArg() != INTARG)
            HError(2519,"HQuant: Stream number expected");
         stream = GetChkedInt(1,SMAX,s);
         if(swidth[0] < stream) swidth[0] = stream;
         widthSet = TRUE;
         if (NextArg() != INTARG)
            HError(2519,"HQuant: Stream width expected");
         swidth[stream]= GetChkedInt(1,256,s);
         break;
      case 'F':
         if (NextArg() != STRINGARG)
            HError(2519,"HQuant: Data File format expected");
         if((dff = Str2Format(GetStrArg())) == ALIEN)
            HError(-2589,"HQuant: Warning ALIEN Data file format set");
         break;
      case 'G':
         if (NextArg() != STRINGARG)
            HError(2519,"HQuant: Label File format expected");
         if((lff = Str2Format(GetStrArg())) == ALIEN)
            HError(-2589,"HQuant: Warning ALIEN Label file format set");
         break;
      case 'I':
         if (NextArg() != STRINGARG)
            HError(2519,"HQuant: MLF file name expected");
         LoadMasterFile(GetStrArg());
         break;
      case 'L':
         if (NextArg()!=STRINGARG)
            HError(2519,"HQuant: Label file directory expected");
         labDir = GetStrArg();
         break;
      case 'T':
         if (NextArg() != INTARG)
            HError(2519,"HQuant: Trace value expected");
         trace = GetChkedInt(0,077,s); 
         break;
      case 'X':
         if (NextArg()!=STRINGARG)
            HError(2519,"HQuant: Label file extension expected");
         labExt = GetStrArg();
         break;
      default:
         HError(2519,"HQuant: Unknown switch %s",s);
      }
   }
   if (NextArg()!=STRINGARG)
      HError(2519,"HQuant: Output VQ table file name expected");
   vqfn = GetStrArg();

   if (NextArg()!=STRINGARG)
      HError(2519,"HQuant: Training data file name expected");
   datafn = GetStrArg();
   Initialise(datafn);
   LoadFile(datafn);
   while (NumArgs()>0) {
      if (NextArg()!=STRINGARG) 
         HError(2519,"HQuant: Training data file name expected");
      datafn = GetStrArg();
      LoadFile(datafn);
   }
   
   for (stream=1;stream<=swidth[0];stream++){
      if (trace&T_TOP)
         printf("%s-clustering data for stream %d (width %d)\n",
                (tType==linTree)?"Flat":"Tree",stream,swidth[stream]);
      CalcMeanCov(dSeq,stream);
      ClusterVecs(dSeq,stream);
   }
   WriteVQTable(cs,vqfn);

   ResetTrain();
   ResetParm();
   ResetModel();
   ResetVQ();
   ResetAudio();
   ResetWave();
   ResetSigP();
   ResetMath();
   ResetLabel();
   ResetMem();
   ResetShell();
   
   Exit(0);
   return (0);          /* never reached -- make compiler happy */
}
Example #3
0
int main(int argc, char *argv[])
{
   char *s,buf[MAXSTRLEN];
   void ListSpeech(char *src);
   
   if(InitShell(argc,argv,hlist_version,hlist_vc_id)<SUCCESS)
      HError(1100,"HList: InitShell failed");
   InitMem();
   InitMath();  InitSigP();
   InitWave();  InitAudio();
   InitVQ(); InitLabel();
   InitModel();
   if(InitParm()<SUCCESS)  
      HError(1100,"HList: InitParm failed");

   SetConfParms();
   if (GetConfStr(cParm,nParm,"SOURCEFORMAT",buf))
      ff = Str2Format(buf);

   if (!InfoPrinted() && NumArgs() == 0 && ff != HAUDIO)
      ReportUsage();
   if (NumArgs() == 0 && ff != HAUDIO)
      Exit(0);

   while (NextArg() == SWITCHARG) {
      s = GetSwtArg();
      if (strlen(s) !=1 )
         HError(1119,"HList: Bad switch %s; must be single letter",s);
      switch(s[0]){
      case 'd':
         frcDisc = TRUE; break;
      case 'e':
         gen = GetChkedLong(gst,LONG_MAX,s); break;
      case 'h':
         srcHdr = TRUE; break;
      case 'i':
         nItems = GetChkedInt(1,100,s); break;
      case 'n':
         numS = GetChkedInt(1,SMAX-1,s); break;
      case 'o':
         obsFmt = TRUE; break;
      case 'p':
         replay = TRUE; break;
      case 'r':
         rawOut = TRUE; break;
      case 's':
         gst = GetChkedLong(0,LONG_MAX,s); break;
      case 't':
         tgtHdr = TRUE; break;
      case 'z':
         prData = FALSE; break;
      case 'F':
         if (NextArg() != STRINGARG)
            HError(1119,"HList: File format expected");
         if((ff = Str2Format(GetStrArg())) == ALIEN)
            HError(-1189,"HList: Warning ALIEN src file format set");
         break;
      case 'T':
         trace = GetChkedInt(0,077,s); break;
      default:
         HError(1119,"HList: Unknown switch %s",s);
      }
   }
   if (NumArgs() == 0 ) 
      ListSpeech(NULL);
   else
      while (NumArgs() > 0 ) {
         if (NextArg() != STRINGARG)
            HError(1119,"HList: List file name expected");
         ListSpeech(GetStrArg());
      }

   ResetParm();
   ResetModel();
   ResetLabel();
   ResetVQ();
   ResetAudio();
   ResetWave();
   ResetSigP();
   ResetMath();
   ResetMem();
   ResetShell();
   
   Exit(0);
   return (0);          /* never reached -- make compiler happy */
}
Example #4
0
void SEditModelRender::LevelShutdownPostEntity()
{
	ResetModel();
}
Example #5
0
void SEditModelRender::LevelInitPostEntity()
{
	ResetModel();
}
Example #6
0
int main(int argc, char *argv[])
{
   char *datafn, *s;
   int nSeg;
   void Initialise(void);
   void LoadFile(char *fn);
   void EstimateModel(void);
   void SaveModel(char *outfn);
   
   if(InitShell(argc,argv,hinit_version,hinit_vc_id)<SUCCESS)
      HError(2100,"HInit: InitShell failed");
   InitMem();   InitLabel();
   InitMath();  InitSigP();
   InitWave();  InitAudio();
   InitVQ();    InitModel();
   if(InitParm()<SUCCESS)  
      HError(2100,"HInit: InitParm failed");
   InitTrain(); InitUtil();

   if (!InfoPrinted() && NumArgs() == 0)
      ReportUsage();
   if (NumArgs() == 0) Exit(0);
   SetConfParms();

   CreateHMMSet(&hset,&gstack,FALSE);
   while (NextArg() == SWITCHARG) {
      s = GetSwtArg();
      if (strlen(s)!=1) 
         HError(2119,"HInit: Bad switch %s; must be single letter",s);
      switch(s[0]){
      case 'e':
         epsilon = GetChkedFlt(0.0,1.0,s); break;
      case 'g':
         ignOutVec = FALSE; break;
      case 'i':
         maxIter = GetChkedInt(0,100,s); break;
      case 'l':
         if (NextArg() != STRINGARG)
            HError(2119,"HInit: Segment label expected");
         segLab = GetStrArg();
         break;
      case 'm':
         minSeg = GetChkedInt(1,1000,s); break;
      case 'n':
         newModel = FALSE; break;
      case 'o':
         outfn = GetStrArg();
         break;
      case 'u':
         SetuFlags(); break;
      case 'v':
         minVar = GetChkedFlt(0.0,10.0,s); break;
      case 'w':
         mixWeightFloor = MINMIX * GetChkedFlt(0.0,100000.0,s); 
         break;
      case 'B':
         saveBinary = TRUE;
         break;
      case 'F':
         if (NextArg() != STRINGARG)
            HError(2119,"HInit: Data File format expected");
         if((dff = Str2Format(GetStrArg())) == ALIEN)
            HError(-2189,"HInit: Warning ALIEN Data file format set");
         break;
      case 'G':
         if (NextArg() != STRINGARG)
            HError(2119,"HInit: Label File format expected");
         if((lff = Str2Format(GetStrArg())) == ALIEN)
            HError(-2189,"HInit: Warning ALIEN Label file format set");
         break;
      case 'H':
         if (NextArg() != STRINGARG)
            HError(2119,"HInit: HMM macro file name expected");
         AddMMF(&hset,GetStrArg());
         break;
      case 'I':
         if (NextArg() != STRINGARG)
            HError(2119,"HInit: MLF file name expected");
         LoadMasterFile(GetStrArg());
         break;
      case 'L':
         if (NextArg()!=STRINGARG)
            HError(2119,"HInit: Label file directory expected");
         labDir = GetStrArg(); break;
      case 'M':
         if (NextArg()!=STRINGARG)
            HError(2119,"HInit: Output macro file directory expected");
         outDir = GetStrArg();
         break;
      case 'T':
         if (NextArg() != INTARG)
            HError(2119,"HInit: Trace value expected");
         trace = GetChkedInt(0,01777,s);
         break;
      case 'X':
         if (NextArg()!=STRINGARG)
            HError(2119,"HInit: Label file extension expected");
         labExt = GetStrArg(); break;
      default:
         HError(2119,"HInit: Unknown switch %s",s);
      }
   }
   if (NextArg()!=STRINGARG)
      HError(2119,"HInit: source HMM file name expected");
   hmmfn = GetStrArg();
   Initialise();
   do {
      if (NextArg()!=STRINGARG)
         HError(2119,"HInit: training data file name expected");
      datafn = GetStrArg();
      LoadFile(datafn);
   } while (NumArgs()>0);
   nSeg = NumSegs(segStore);
   if (nSeg < minSeg)
      HError(2121,"HInit: Too Few Observation Sequences [%d]",nSeg);
   if (trace&T_TOP) {
      printf("%d Observation Sequences Loaded\n",nSeg);
      fflush(stdout);
   }
   EstimateModel();
   SaveModel(outfn);
   if (trace&T_TOP)
      printf("Output written to directory %s\n",
             outDir==NULL?"current":outDir);
   
   InitMem();   InitLabel();
   InitMath();  InitSigP();
   InitWave();  InitAudio();
   InitVQ();    InitModel();
   if(InitParm()<SUCCESS)  
      HError(2100,"HInit: InitParm failed");
   InitTrain(); InitUtil();
   
   ResetUtil();
   ResetTrain();
   ResetParm();
   ResetModel();
   ResetVQ();
   ResetAudio();
   ResetWave();
   ResetSigP();
   ResetMath();
   ResetLabel();
   ResetMem();
   ResetShell();
   
   Exit(0);
   return (0);          /* never reached -- make compiler happy */
}
Example #7
0
int main(int argc, char *argv[])
{
   char *s;
   char *labfn;
   int numUtt;

   void Initialise(void);
   void DoGeneration(char *labfn);

   if (InitShell(argc, argv, hmgens_version, hmgens_vc_id) < SUCCESS)
      HError(2300, "HMGenS: InitShell failed");
   InitMem();
   InitMath();
   InitSigP();
   InitWave();
   InitLabel();
   InitModel();
   if (InitParm() < SUCCESS)
      HError(2300, "HMGenS: InitParm failed");
   InitUtil();
   InitFB();
   InitAdapt(&xfInfo_hmm, &xfInfo_dur);
   InitMap();
   InitGen();

   if (NumArgs() == 0)
      ReportUsage();

   CreateHeap(&genStack, "genStore", MSTAK, 1, 1.0, 80000, 400000);
   CreateHeap(&uttStack, "uttStore", MSTAK, 1, 0.5, 100, 1000);
   CreateHeap(&fbInfoStack, "FBInfoStore", MSTAK, 1, 0.5, 100, 1000);
   CreateHeap(&hmmStack, "HmmStore", MSTAK, 1, 1.0, 50000, 500000);
   CreateHeap(&dmStack, "dmStore", MSTAK, 1, 1.0, 50000, 500000);
   SetConfParms();
   CreateHMMSet(&hmset, &hmmStack, TRUE);
   CreateHMMSet(&dmset, &dmStack, TRUE);

   utt = (UttInfo *) New(&uttStack, sizeof(UttInfo));
   genInfo = (GenInfo *) New(&genStack, sizeof(GenInfo));
   fbInfo = (FBInfo *) New(&fbInfoStack, sizeof(FBInfo));

   while (NextArg() == SWITCHARG) {
      s = GetSwtArg();
      if (strlen(s) != 1)
         HError(9919, "HMGenS: Bad switch %s; must be single letter", s);
      switch (s[0]) {
      case 'a':
         xfInfo_hmm.useInXForm = TRUE;
         break;
      case 'b':
         xfInfo_dur.useInXForm = TRUE;
         break;
      case 'c':
         if (NextArg() != INTARG)
            HError(2119, "HMGenS: Parameter generation algorithm type value expected");
         type = (ParmGenType) GetChkedInt(CHOLESKY, FB, s);
         break;
      case 'd':
         if (NextArg() != STRINGARG)
            HError(2319, "HMGenS: HMM definition directory expected");
         hmmDir = GetStrArg();
         break;
      case 'e':
         useAlign = TRUE;
         break;
      case 'f':
         frameRate = (HTime) GetChkedFlt(0.0, 10000000.0, s);
         break;
      case 'g':
         minFrwdP = GetChkedFlt(0.0, 1000.0, s);
         break;
      case 'h':
         if (NextArg() != STRINGARG)
            HError(1, "Speaker name pattern expected");
         xfInfo_hmm.inSpkrPat = xfInfo_dur.inSpkrPat = GetStrArg();
         if (NextArg() == STRINGARG)
            xfInfo_hmm.paSpkrPat = xfInfo_dur.paSpkrPat = GetStrArg();
         if (NextArg() != SWITCHARG)
            HError(2319, "HMGenS: cannot have -h as the last option");
         break;
      case 'm':
         modelAlign = TRUE;
         break;
      case 'n':
         if (NextArg() != STRINGARG)
            HError(2319, "HMGenS: duration model definition directory expected");
         dmDir = GetStrArg();
         break;
      case 'p':
         outPdf = TRUE;
         break;
      case 'r':
         if (NextArg() != FLOATARG)
            HError(2119, "HMGenS: Speaking rate value (float) expected");
         speakRate = GetChkedFlt(0.0, 3.0, s);
         break;
      case 's':
         stateAlign = TRUE;
         break;
      case 't':
         pruneInit = GetChkedFlt(0.0, 1.0E20, s);
         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 'v':
         MSDthresh = GetChkedFlt(0.0, 1.0, s);
         break;
      case 'x':
         if (NextArg() != STRINGARG)
            HError(2319, "HMGenS: HMM file extension expected");
         hmmExt = GetStrArg();
         break;
      case 'y':
         if (NextArg() != STRINGARG)
            HError(2319, "HMGenS: duration model file extension expected");
         dmExt = GetStrArg();
         break;
      case 'B':
         inBinary = TRUE;
         break;
      case 'E':
         if (NextArg() != STRINGARG)
            HError(2319, "HMGenS: parent transform directory expected");
         xfInfo_hmm.usePaXForm = TRUE;
         xfInfo_hmm.paXFormDir = GetStrArg();
         if (NextArg() == STRINGARG)
            xfInfo_hmm.paXFormExt = GetStrArg();
         if (NextArg() != SWITCHARG)
            HError(2319, "HMGenS: cannot have -E as the last option");
         break;
      case 'G':
         if (NextArg() != STRINGARG)
            HError(2119, "HMGenS: Label File format expected");
         if ((lff = Str2Format(GetStrArg())) == ALIEN)
            HError(-2189, "HMGenS: Warning ALIEN Label file format set");
         break;
      case 'H':
         if (NextArg() != STRINGARG)
            HError(3219, "HMGenS: HMM MMF File name expected");
         AddMMF(&hmset, GetStrArg());
         break;
      case 'I':
         if (NextArg() != STRINGARG)
            HError(2319, "HMGenS: MLF file name expected");
         LoadMasterFile(GetStrArg());
         break;
      case 'J':
         if (NextArg() != STRINGARG)
            HError(2319, "HMGenS: input transform directory expected");
         AddInXFormDir(&hmset, GetStrArg());
         if (NextArg() == STRINGARG)
            xfInfo_hmm.inXFormExt = GetStrArg();
         if (NextArg() != SWITCHARG)
            HError(2319, "HMGenS: cannot have -J as the last option");
         break;
      case 'L':
         if (NextArg() != STRINGARG)
            HError(2319, "HMGenS: Label file directory expected");
         labDir = GetStrArg();
         break;
      case 'M':
         if (NextArg() != STRINGARG)
            HError(2319, "HMGenS: Output macro file directory expected");
         genDir = GetStrArg();
         break;
      case 'N':
         if (NextArg() != STRINGARG)
            HError(3219, "HMGenS: Duration MMF File name expected");
         AddMMF(&dmset, GetStrArg());
         break;
      case 'T':
         if (NextArg() != INTARG)
            HError(2119, "HMGenS: Trace value expected");
         trace = GetChkedInt(0, 0002, s);
         break;
      case 'W':
         if (NextArg() != STRINGARG)
            HError(2319, "HMGenS: parent duration transform directory expected");
         xfInfo_dur.usePaXForm = TRUE;
         xfInfo_dur.paXFormDir = GetStrArg();
         if (NextArg() == STRINGARG)
            xfInfo_dur.paXFormExt = GetStrArg();
         if (NextArg() != SWITCHARG)
            HError(2319, "HMGenS: cannot have -W as the last option");
         break;
      case 'X':
         if (NextArg() != STRINGARG)
            HError(2319, "HMGenS: Label file extension expected");
         labExt = GetStrArg();
         break;
      case 'Y':
         if (NextArg() != STRINGARG)
            HError(2319, "HMGenS: input duration transform directory expected");
         AddInXFormDir(&dmset, GetStrArg());
         if (NextArg() == STRINGARG) {
            if (xfInfo_dur.inXFormExt == NULL)
               xfInfo_dur.inXFormExt = GetStrArg();
            else
               HError(2319, "MGenS: only one input duration transform extension may be specified");
         }
         if (NextArg() != SWITCHARG)
            HError(2319, "HMGenS: cannot have -Y as the last option");
         break;
      default:
         HError(9919, "HMGenS: Unknown switch %s", s);
      }
   }
   if (NextArg() != STRINGARG)
      HError(2319, "HMGenS: file name of vocabulary list expected");

   Initialise();
   InitUttInfo(utt, FALSE);
   numUtt = 1;

   if (trace & T_TOP)
      SetTraceGen();

   /* generate parameter sequences */
   do {
      if (NextArg() != STRINGARG)
         HError(2319, "HMGenS: data file name expected");
      labfn = GetStrArg();

      /* track speakers */
      if (UpdateSpkrStats(&hmset, &xfInfo_hmm, labfn)) {
         if (!xfInfo_hmm.useInXForm)
            xfInfo_hmm.inXForm = NULL;
      }
      if (UpdateSpkrStats(&dmset, &xfInfo_dur, labfn)) {
         if (!xfInfo_dur.useInXForm)
            xfInfo_dur.inXForm = NULL;
         else
            ResetDMMPreComps(&dmset);
      }

      fbInfo->xfinfo_hmm = &xfInfo_hmm;
      fbInfo->xfinfo_dur = &xfInfo_dur;
      fbInfo->inXForm_hmm = xfInfo_hmm.inXForm;
      fbInfo->inXForm_dur = xfInfo_dur.inXForm;
      fbInfo->al_inXForm_hmm = xfInfo_hmm.al_inXForm;
      fbInfo->al_inXForm_dur = xfInfo_dur.al_inXForm;
      fbInfo->paXForm_hmm = xfInfo_hmm.paXForm;
      fbInfo->paXForm_dur = xfInfo_dur.paXForm;

      /* generate parameters */
      DoGeneration(labfn);
      numUtt++;
   } while (NumArgs() > 0);

   if (trace & T_TOP) {
      printf("Generation complete - average log prob per frame = %e (%d frames)\n", totalPr / totalT, totalT);
   }

   /* Reset stacks */
   Dispose(&fbInfoStack, fbInfo);
   Dispose(&genStack, genInfo);
   Dispose(&uttStack, utt);
   ResetHeap(&fbInfoStack);
   ResetHeap(&uttStack);
   ResetHeap(&genStack);
   ResetHeap(&dmStack);
   ResetHeap(&hmmStack);

   /* Reset modules */
   ResetGen();
   ResetAdapt(&xfInfo_hmm, &xfInfo_dur);
   ResetFB();
   ResetUtil();
   ResetParm();
   ResetModel();
   ResetLabel();
   ResetWave();
   ResetSigP();
   ResetMath();
   ResetMem();
   ResetShell();

   Exit(0);
   return (0);                  /* never reached -- make compiler happy */
}
Example #8
0
int main(int argc, char *argv[])
{
   char *s,*lfn,*dfn;
   void  GenSentences(char *latfn, char *dicfn);
  
   if(InitShell(argc,argv,hsgen_version,hsgen_vc_id)<SUCCESS)
      HError(3400,"HSGen: InitShell failed");

   InitMem();   InitLabel();
   InitMath();  InitSigP();
   InitWave();  InitAudio();
   InitVQ();    InitModel();
   if(InitParm()<SUCCESS)
      HError(3200,"HSGen: InitParm failed");
   InitDict();
   InitNet();

   if (!InfoPrinted() && NumArgs() == 0)
      ReportUsage();
   if (NumArgs() == 0) Exit(0);

   SetConfParms();
   while (NextArg() == SWITCHARG) {
      s = GetSwtArg();
      if (strlen(s)!=1) 
         HError(3419, "Bad switch %s; must be single letter", s);
      switch(s[0]){
      case 's':
         stats = TRUE; break;
      case 'l':
         lnum = TRUE; break;
      case 'n':
         ngen = GetChkedInt(1,1000000,s); break;
      case 'q':
         quiet = TRUE; break;
      case 'T':
         trace = GetChkedInt(0,07,s); break;
      default:
         HError(3419, "Unknown switch %s", s);
      }
   }
   if (NextArg()!=STRINGARG)
      HError(3419, "lattice file name expected");
   lfn = GetStrArg(); 
   if (NextArg()!=STRINGARG)
      HError(3419, "dictionary file name expected");
   dfn = GetStrArg(); 
   GenSentences(lfn,dfn);
   
   if(InitShell(argc,argv,hsgen_version,hsgen_vc_id)<SUCCESS)
      HError(3400,"HSGen: InitShell failed");

   ResetNet();
   ResetDict();
   ResetParm();
   ResetModel();
   ResetVQ();
   ResetAudio();
   ResetWave();
   ResetSigP();
   ResetMath();
   ResetLabel();
   ResetMem();
   ResetShell();
   
   Exit(0);
   return (0);          /* never reached -- make compiler happy */
}
Example #9
0
int main(int argc, char *argv[])
{
   Source src;
   int tmpInt;
   float tmpFlt;
   char *accfn, *s;

   void Initialise(char *hmmListFn);
   void Interpolate(void);
   void UpdateModels(void);
   void MakeWtAccLists(void);
   void AttachWtAccLists(void);
   void StatReport(void);
   
   if(InitShell(argc,argv,hsmooth_version,hsmooth_vc_id)<SUCCESS)
      HError(2400,"HSmooth: InitShell failed");

   InitMem();   InitLabel();
   InitMath();  InitSigP();
   InitWave();  InitAudio();
   InitVQ();    InitModel();
   if(InitParm()<SUCCESS)  
      HError(2400,"HSmooth: InitParm failed");

   InitTrain(); InitUtil();

   if (!InfoPrinted() && NumArgs() == 0)
      ReportUsage();
   if (NumArgs() == 0) Exit(0);

   SetConfParms();
   CreateHeap(&hmmStack,"HmmStore", MSTAK, 1, 1.0, 50000, 500000);
   CreateHMMSet(&hset,&hmmStack,TRUE);
   while (NextArg() == SWITCHARG) {
      s = GetSwtArg();
      if (strlen(s)!=1) 
         HError(2419,"HSmooth: Bad switch %s; must be single letter",s);
      switch(s[0]){
      case 'b':
         epsilon = GetChkedFlt(0.0,1.0,s); break;           
      case 'c':
         maxStep = GetChkedInt(1,1000,s); break;            
      case 'd':
         if (NextArg()!=STRINGARG)
            HError(2419,"HSmooth: HMM definition directory expected");
         hmmDir = GetStrArg(); break;  
      case 'e':
         if (NextArg()!=STRINGARG)
            HError(2419,"HSmooth: HMM definition directory expected");
         newDir = GetStrArg(); break;  
      case 'm':
         minEgs = GetChkedInt(1,1000,s); break;
      case 'o':
         if (NextArg()!=STRINGARG)
            HError(2419,"HSmooth: HMM file extension expected");
         newExt = GetStrArg(); break;
      case 's':
         stats = TRUE;
         if (NextArg()!=STRINGARG)
            HError(2419,"HSmooth: Stats file name expected");
         statFN = GetStrArg(); 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;
      case 'x':
         if (NextArg()!=STRINGARG)
            HError(2419,"HSmooth: HMM file extension expected");
         hmmExt = GetStrArg(); break;
      case 'B':
         saveBinary=TRUE;
         break;
      case 'H':
         if (NextArg() != STRINGARG)
            HError(2419,"HSmooth: HMM macro file name expected");
         AddMMF(&hset,GetStrArg());
         break;
      case 'M':
         if (NextArg()!=STRINGARG)
            HError(2419,"HSmooth: Output macro file directory expected");
         newDir = GetStrArg();
         break;    
      case 'T':
         trace = GetChkedInt(0,0100000,s); break;
      default:
         HError(2419,"HSmooth: Unknown switch %s",s);
      }
   } 
   if (NextArg() != STRINGARG)
      HError(2419,"HSmooth: file name of HMM list expected");
   Initialise(GetStrArg());
   do {
      if (NextArg()!=STRINGARG)
         HError(2419,"HSmooth: accumulator file name expected");
      accfn = GetStrArg();
      src=LoadAccs(&hset,accfn,uFlags);
      ReadFloat(&src,&tmpFlt,1,ldBinary);
      totalPr += (LogDouble)tmpFlt;
      ReadInt(&src,&tmpInt,1,ldBinary);
      totalT += tmpInt;
      CloseSource(&src);      
      nBlk++;
      MakeWtAccLists();
   } while (NumArgs()>0);
   AttachWtAccLists();
   Interpolate();
   if (stats) StatReport();
   UpdateModels();
   
   ResetUtil();
   ResetTrain();
   ResetParm();
   ResetModel();
   ResetVQ();
   ResetAudio();
   ResetWave();
   ResetSigP();
   ResetMath();
   ResetLabel();
   ResetMem();
   ResetShell();
   
   Exit(0);
   return (0);          /* never reached -- make compiler happy */
}