Beispiel #1
0
#define T_TOP   0001    /* Top level tracing */

#define T_MAP   0002    /* logical/physical hmm map */

#define T_UPD   0004    /* Model updates */





/* possible values of updateMode */

#define UPMODE_DUMP 1

#define UPMODE_UPDATE 2

#define UPMODE_BOTH 3



/* Global Settings */



static char * labDir = NULL;     /* label (transcription) file directory */

static char * labExt = "lab";    /* label file extension */

static char * hmmDir = NULL;     /* directory to look for hmm def files */

static char * hmmExt = NULL;     /* hmm def file extension */

static char * newDir = NULL;     /* directory to store new hmm def files */

static char * newExt = NULL;     /* extension of new reestimated hmm files */

static char * statFN;            /* stats file, if any */

static float minVar  = 0.0;      /* minimum variance (diagonal only) */

static float mixWeightFloor=0.0; /* Floor for mixture weights */

static int minEgs    = 3;        /* min examples to train a model */

static UPDSet uFlags = (UPDSet) (UPMEANS|UPVARS|UPTRANS|UPMIXES); /* update flags */

static int parMode   = -1;       /* enable one of the // modes */

static Boolean stats = FALSE;    /* enable statistics reports */

static char * mmfFn  = NULL;     /* output MMF file, if any */
Beispiel #2
0
#include "LUtil.h"

#include "LModel.h"

#include "LPCalc.h"



#define T_TOP    0001       /* top level tracing */

#define T_FOF    0002       /* FoF table tracing */



/* -------------------------- Trace Flags ------------------------ */



static int trace = 0;



/* ---------------- Configuration Parameters --------------------- */



static ConfParam *cParm[MAXGLOBS];

static int nParm = 0;            /* total num params */


Beispiel #3
0
/* EXPORT->LOpen: Load transcription in fname and return it */
Transcription *LOpen(MemHeap *x, char * fname, FileFormat fmt)
{
   FILE *f;
   Source source;
   char buf[MAXSTRLEN];
   Transcription *t;
   Boolean isMLF;
   int i;

   if (fmt == UNDEFF){
      if (GetConfStr(cParm,numParm,"SOURCELABEL",buf))
         fmt = Str2Format(buf);
      else
         fmt = HTK;
   }
   if ((f=OpenLabFile(fname, &isMLF)) == NULL)
      HError(6510,"LOpen: Unable to open label file %s",fname);
   AttachSource(f,&source);
   strcpy(source.name,fname);
   t = CreateTranscription(x);
   switch (fmt) {
   case TIMIT:    LoadTIMITLabels(x,t,&source); break;
   case HTK:      LoadHTKLabels(x,t,&source); break;
   case SCRIBE:   LoadSCRIBELabels(x,t,&source); break;
   case ESPS:     LoadESPSLabels(x,t,&source); break;
   default:
      HError(6572,"LOpen: Illegal label file format [%d]",fmt);
   }
   if (!isMLF) 
      i=fclose(f);
   if (transLev > 0) FilterLevel(t,transLev-1);
   return t;
}
Beispiel #4
0
/* EXPORT->InitLabel: initialise module */
void InitLabel(void)
{
   int i;
   Boolean b;
   double d;
   char str[MAXSTRLEN];

   Register(hlabel_version,hlabel_vc_id);
   CreateHeap(&namecellHeap,"namecellHeap",MSTAK,1,0.5,5000,20000);
   for (i=0;i<HASHSIZE;i++)
      hashtab[i] = NULL;
   CreateHeap(&mlfHeap,"mlfHeap",MSTAK,1,0.5,10000,50000);
   numParm = GetConfig("HLABEL", TRUE, cParm, MAXGLOBS);
   if (numParm>0){
      if (GetConfInt(cParm,numParm,"TRACE",&i)) trace = i;
      if (GetConfBool(cParm,numParm,"STRIPTRIPHONES",&b)) 
         stripTriPhones = b;
      if (GetConfBool(cParm,numParm,"V1COMPAT",&b))  compatMode = b;
      if (GetConfStr(cParm,numParm,"LABELSQUOTE",str))
         labelQuote=str[0];
      if (GetConfInt(cParm,numParm,"TRANSALT",&i)) transAlt = i;
      if (GetConfInt(cParm,numParm,"TRANSLEV",&i)) transLev = i;
      if (GetConfFlt(cParm,numParm,"HTKLABELTIMESCALE",&d)) htkLabelTimeScale = d;
   }
}
Beispiel #5
0
/* SetConfParms: set conf parms relevant to this tool */
void SetConfParms(void)
{
   int i;
   static char b[100];

   nParm = GetConfig("LPLEX", TRUE, cParm, MAXGLOBS);
   if (nParm>0){
      if (GetConfInt(cParm,nParm,"TRACE",&i)) trace = i;
     if (GetConfStr(cParm,nParm,"STARTWORD",b))   sstId = GetLabId(b, TRUE);
      if (GetConfStr(cParm,nParm,"ENDWORD",b))     senId = GetLabId(b, TRUE);
      if (GetConfStr(cParm,nParm,"UNKNOWNNAME",b)) unkId = GetLabId(b, TRUE);
   }

   if (!sstId) sstId = GetLabId(DEF_STARTWORD,TRUE);
   if (!senId) senId = GetLabId(DEF_ENDWORD,TRUE);
   if (!unkId) unkId = GetLabId(DEF_UNKNOWNNAME,TRUE);

}
Beispiel #6
0
void SetConfParms(void)
{
   int s, i;
   char *c, buf[MAXSTRLEN], tmp[MAXSTRLEN];
   Boolean b;

   for (s = 1; s < SMAX; s++)
      winFn[s] = NULL;

   nParm = GetConfig("HMGENS", TRUE, cParm, MAXGLOBS);
   if (nParm > 0) {
      if (GetConfInt(cParm, nParm, "TRACE", &i))
         trace = i;
      if (GetConfBool(cParm, nParm, "SAVEBINARY", &b))
         inBinary = b;
      if (GetConfBool(cParm, nParm, "OUTPDF", &b))
         outPdf = b;
      if (GetConfInt(cParm, nParm, "PARMGENTYPE", &i))
         type = (ParmGenType) i;
      if (GetConfBool(cParm, nParm, "MODELALIGN", &b))
         modelAlign = b;
      if (GetConfBool(cParm, nParm, "STATEALIGN", &b))
         stateAlign = b;
      if (GetConfBool(cParm, nParm, "USEALIGN", &b))
         useAlign = b;
      if (GetConfBool(cParm, nParm, "USEHMMFB", &b))
         useHMMFB = b;
      if (GetConfStr(cParm, nParm, "INXFORMMASK", buf))
         xfInfo_hmm.inSpkrPat = xfInfo_dur.inSpkrPat = CopyString(&genStack, buf);
      if (GetConfStr(cParm, nParm, "PAXFORMMASK", buf))
         xfInfo_hmm.paSpkrPat = xfInfo_dur.paSpkrPat = CopyString(&genStack, buf);

      if (GetConfStr(cParm, nParm, "PDFSTRSIZE", buf))
         nPdfStr = ParseConfIntVec(&gstack, buf, TRUE);
      if (GetConfStr(cParm, nParm, "PDFSTRORDER", buf))
         pdfStrOrder = ParseConfIntVec(&gstack, buf, TRUE);
      if (GetConfStr(cParm, nParm, "PDFSTREXT", buf))
         pdfStrExt = ParseConfStrVec(&gstack, buf, TRUE);
      if (GetConfStr(cParm, nParm, "WINEXT", buf))
         winExt = CopyString(&gstack, buf);
      if (GetConfStr(cParm, nParm, "WINDIR", buf))
         winDir = CopyString(&gstack, buf);
      if (GetConfStr(cParm, nParm, "WINFN", buf)) {
         for (s = 1, c = buf; s < SMAX && c != NULL; s++) {
            winFn[s] = ParseConfStrVec(&gstack, c, FALSE);
            for (i = 1; i <= winFn[s][0][0] + 2; i++)   /* "StrVec" + "n" + # of file names */
               c = ParseString(c, tmp);
            if (ParseString(c, tmp) == NULL)
               break;
         }
      }
   }
}
Beispiel #7
0
// ARec constructor
ARec::ARec(const string & name, ABuffer *inb, ABuffer *outb,
           ARMan *armgr, int nnToks) : AComponent(name,(HasRealConsole()?2:ARECPRBUFSIZE))
{
   ConfParam *cParm[MAXGLOBS];       /* config parameters */
   int numParm;
   int i; double f;
   Boolean b;
   char buf[100];

   in = inb; out = outb; rmgr = armgr;
   strcpy(buf,name.c_str());
   for (i=0; i<int(strlen(buf)); i++) buf[i] = toupper(buf[i]);
   numParm = GetConfig(buf, TRUE, cParm, MAXGLOBS);
   trace=0;
   width = 400; height=120; showRD = FALSE;
   sampPeriod = 100000.0; stTime = 0.0;
   rdx0 = 420;  rdy0 =280;
   runmode = RunMode(CONTINUOUS_MODE+FLUSH_TOMARK+STOP_ATMARK+RESULT_ATEND);
   runstate = WAIT_STATE; laststate = RunState(-1);
   nToks = nnToks;
   wordPen = 0.0; lmScale = 1.0; ngScale=0.0; prScale = 1.0;
   genBeam = nBeam = 225.0; wordBeam = 200.0; maxActive = 0;
   grpName = "";  trbakFreq = 5; outseqnum = 0; inlevel = -1;
   trbakFrame = 0; trbakAc = 0.0; trbakCount = 0; trbakLastWidth=0;
   nBest=0;
   if (numParm>0){
      if (GetConfBool(cParm,numParm,"DISPSHOW",&b)) showRD = b;
      if (GetConfInt(cParm,numParm,"DISPXORIGIN",&i)) rdx0 = i;
      if (GetConfInt(cParm,numParm,"DISPYORIGIN",&i)) rdy0 = i;
      if (GetConfInt(cParm,numParm,"DISPWIDTH",&i)) width = i;
      if (GetConfInt(cParm,numParm,"DISPHEIGHT",&i)) height = i;
      if (GetConfInt(cParm,numParm,"RUNMODE",&i)) runmode = RunMode(i);
      if (GetConfInt(cParm,numParm,"NTOKS",&i)) nToks = i;
      if (GetConfFlt(cParm,numParm,"WORDPEN",&f)) wordPen = float(f);
      if (GetConfFlt(cParm,numParm,"LMSCALE",&f)) lmScale = float(f);
      if (GetConfFlt(cParm,numParm,"NGSCALE",&f)) ngScale = float(f);
      if (GetConfFlt(cParm,numParm,"PRSCALE",&f)) prScale = float(f);
      if (GetConfFlt(cParm,numParm,"GENBEAM",&f)) genBeam = float(f);
      if (GetConfFlt(cParm,numParm,"WORDBEAM",&f)) wordBeam = float(f);
      if (GetConfFlt(cParm,numParm,"NBEAM",&f)) nBeam = float(f);
      if (GetConfInt(cParm,numParm,"MAXBEAM",&i)) maxActive = i;
      if (GetConfStr(cParm,numParm,"GRPNAME",buf)) grpName=string(buf);
      if (GetConfInt(cParm,numParm,"TRBAKFREQ",&i)) trbakFreq = i;
      if (GetConfFlt(cParm,numParm,"TARGETRATE",&f)) sampPeriod = float(f);
      if (GetConfInt(cParm,numParm,"TRACE",&i)) trace = i;
      if (GetConfInt(cParm,numParm,"NBEST",&i)) nBest = i;
   }
   if (nBeam < genBeam) nBeam = genBeam;
   if ((runmode&RESULT_ASAP) || (runmode&RESULT_IMMED))
      runmode = RunMode(runmode|RESULT_ATEND);
   if(nBest>0){
      CreateHeap(&ansHeap,"Lattice heap",MSTAK,1,0.0,4000,4000);
      CreateHeap(&altHeap,"Lattice heap",MSTAK,1,0.0,4000,4000);
   }
}
Beispiel #8
0
/* SetConfParms: set conf parms relevant to this tool */
void SetConfParms(void)
{
   int i;
   Boolean b;
   char buf[MAXSTRLEN];

   nParm = GetConfig("HVITE", TRUE, cParm, MAXGLOBS);
   if (nParm>0){
      if (GetConfInt(cParm,nParm,"TRACE",&i)) trace = i;
      if (GetConfStr(cParm,nParm,"RECOUTPREFIX",buf))
         roPrefix=CopyString(&gstack,buf);
      if (GetConfStr(cParm,nParm,"RECOUTSUFFIX",buf))
         roSuffix=CopyString(&gstack,buf);
      if (GetConfBool(cParm,nParm,"SAVEBINARY",&b)) 
         saveBinary = b;
      if (GetConfStr(cParm,nParm,"LABFILEMASK",buf)) {
         labFileMask = CopyString(&gstack, buf);
      }
   }
}
Beispiel #9
0
/* SetConfParms: set conf parms relevant to this tool */
void SetConfParms(void)
{
   int i;
   char s[256];
   
   nParm = GetConfig("LADAPT", TRUE, cParm, MAXGLOBS);
   if (nParm>0){
      if (GetConfInt(cParm,nParm, "TRACE",&i))      trace = i;
      if (GetConfStr(cParm,nParm, "UNKNOWNNAME",s)) strcpy(unkStr,s);
   }
   
}
Beispiel #10
0
char *lpcalc_vc_id = "$Id: LPCalc.c,v 1.1.1.1 2006/10/11 09:54:43 jal58 Exp $";



#include "HShell.h"     /* HMM ToolKit Modules */

#include "HMem.h"

#include "HMath.h"

#include "HWave.h"

#include "HLabel.h"

#include "LWMap.h"      
Beispiel #11
0
/* SetConfParms: set conf parms relevant to this tool */
void SetConfParmsHCopy(void)
{
   int i;
   Boolean b;
   char buf[MAXSTRLEN];

   nParm = GetConfig("HCOPY", TRUE, cParm, MAXGLOBS);
   if (nParm>0){
      if (GetConfInt(cParm,nParm,"TRACE",&i)) trace = i;
      if (GetConfBool(cParm,nParm,"SAVEASVQ",&b)) saveAsVQ = b;
      if (GetConfInt(cParm,nParm,"NSTREAMS",&i)) swidth0 = i;
      if (GetConfStr(cParm,nParm,"SOURCEFORMAT",buf))
         srcFF = Str2Format(buf);
      if (GetConfStr(cParm,nParm,"TARGETFORMAT",buf))
         tgtFF = Str2Format(buf);
      if (GetConfStr(cParm,nParm,"SOURCEKIND",buf))
         srcPK = Str2ParmKind(buf);
      if (GetConfStr(cParm,nParm,"TARGETKIND",buf)) {
         tgtPK = Str2ParmKind(buf);
         if (tgtPK&HASNULLE) 
            HError(1019, "SetConfParms: incompatible TARGETKIND=%s for coding", buf);
      }
   }
}
Beispiel #12
0
         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)
Beispiel #13
0
// Constructor: builds a Grammar from name:info in the config file
AGram::AGram(const string& name):AResource(name)
{
   ConfParam *cParm[MAXGLOBS];       /* config parameters */
   int numParm,i;
   char buf[100],buf1[100],gramFN[100];

   main = NULL; isOpen = TRUE; gramFN[0] = '\0';
   // Read configuration file
   strcpy(buf,name.c_str());
   for (i=0; i<int(strlen(buf)); i++) buf[i] = toupper(buf[i]);
   numParm = GetConfig(buf, TRUE, cParm, MAXGLOBS);
   if (numParm>0){
      if (GetConfInt(cParm,numParm,"TRACE",&i)) trace = i;
      if (GetConfStr(cParm,numParm,"GRAMFILE",buf1)) strcpy(gramFN,buf1);
   }
   if (gramFN[0] != '\0') InitFromFile(gramFN);
   isOpen = FALSE;
}
Beispiel #14
0
/* EXPORT->LSave: Save transcription in fname */
ReturnStatus LSave(char *fname, Transcription *t, FileFormat fmt)
{
   FILE *f;
   char buf[MAXSTRLEN];

   if (fmt == UNDEFF){
      if (GetConfStr(cParm,numParm,"TARGETLABEL",buf))
         fmt = Str2Format(buf);
      else
         fmt = HTK;
   }
   if (outMLF != NULL) {
      if (fmt != HTK){
         HRError(6572,"LSave: cant save to MLF in %s format",Format2Str(fmt));
         return(FAIL);
      }
      f = outMLF;                      /* save to MLF file */
      fprintf(f,"\"%s\"\n",fname);
   } else                              /* else open new one */
      if ((f=fopen(fname,"wb")) == NULL){
         HRError(6511,"LSave: Unable to create label file %s",fname);
         return(FAIL);
      }
   if (trace&T_SAV)
      printf("HLabel: Saving transcription to %s in format %s\n",
             fname,Format2Str(fmt));
   switch (fmt) {
   case HTK:    SaveHTKLabels( f, t);   break;
   case ESPS:   SaveESPSLabels(f, t);   break;
   default: HRError(6572,"LSave: Illegal label file format."); 
      fclose(f);
      return(FAIL);
      break;
   }
   if (outMLF != NULL && fmt==HTK){
      fprintf(f,".\n");  fflush(f);
   }else
      fclose(f);
   return(SUCCESS);
}
Beispiel #15
0
static void SetConfParms(void)
{
   int s, i, nParm;
   char *c, buf[MAXSTRLEN], tmp[MAXSTRLEN];
   Boolean b;

   for (s = 1; s < SMAX; s++)
      winFn[s] = NULL;

   nParm = GetConfig("HMGETOOL", TRUE, cParm, MAXGLOBS);
   if (nParm > 0) {
      if (GetConfInt(cParm, nParm, "TRACE", &i))
         trace = i;
      if (GetConfBool(cParm, nParm, "SAVEBINARY", &b))
         inBinary = b;

      if (GetConfStr(cParm, nParm, "PDFSTRSIZE", buf))
         nPdfStr = ParseConfIntVec(&gstack, buf, TRUE);
      if (GetConfStr(cParm, nParm, "PDFSTRORDER", buf))
         pdfStrOrder = ParseConfIntVec(&gstack, buf, TRUE);

      if (GetConfStr(cParm, nParm, "MGETRNFLAG", buf))
         pbMTrn = ParseConfIntVec(&gstack, buf, TRUE);
      if (GetConfStr(cParm, nParm, "GVTRNFLAG", buf))
         pbGVTrn = ParseConfIntVec(&gstack, buf, TRUE);
      if (GetConfStr(cParm, nParm, "ACCERRFLAG", buf))
         pbAccErr = ParseConfIntVec(&gstack, buf, TRUE);
      if (GetConfStr(cParm, nParm, "INVQUASIZE", buf))
         pnInvQuaSize = ParseConfIntVec(&gstack, buf, TRUE);
      if (GetConfStr(cParm, nParm, "VARWINSIZE", buf))
         pnVarWin = ParseConfIntVec(&gstack, buf, TRUE);
      if (GetConfStr(cParm, nParm, "GVDISTWGHT", buf))
         pfGVWght = ParseConfVector(&gstack, buf, TRUE);
      if (GetConfStr(cParm, nParm, "GAINWTFLAG", buf))
         pbGainWght = ParseConfIntVec(&gstack, buf, TRUE);

      if (GetConfStr(cParm, nParm, "WINEXT", buf))
         winExt = CopyString(&gstack, buf);
      if (GetConfStr(cParm, nParm, "WINDIR", buf))
         winDir = CopyString(&gstack, buf);
      if (GetConfStr(cParm, nParm, "WINFN", buf)) {
         for (s = 1, c = buf; s < SMAX && c != NULL; s++) {
            winFn[s] = ParseConfStrVec(&gstack, c, FALSE);
            for (i = 1; i <= winFn[s][0][0] + 2; i++)   /* "StrVec" + "n" + # of file names */
               c = ParseString(c, tmp);
            if (ParseString(c, tmp) == NULL)
               break;
         }
      }
   }
}
Beispiel #16
0
static Boolean tgtHdr  = FALSE;  /* print target header info */

static Boolean obsFmt  = FALSE;  /* print observation format */

static Boolean prData  = TRUE;   /* print data */

static Boolean rawOut = FALSE;   /* raw output i.e no numbering */

static Boolean replay = FALSE;   /* replay audio */

static Boolean frcDisc = FALSE;  /* List VQ symbols from cont file */

static FileFormat ff = UNDEFF;   /* Source File format */

static long gst = -1;             /* start sample to list */

static long gen = -1;             /* end sample to list */

static int numS = 1;             /* number of streams */

static int nItems  = 10;         /* num items per line */

static int barwidth;             /* width of printed bars */

static char barc = '-';          /* bar character */



/* ---------------- Configuration Parameters --------------------- */



static ConfParam *cParm[MAXGLOBS];

static int nParm = 0;            /* total num params */

static HTime sampPeriod;         /* raw audio input only */

static int audSignal;



/* ---------------- Process Command Line ------------------------- */



/* SetConfParms: set conf parms relevant to this tool */

void SetConfParms(void)

{

   int i;

   double d;



   sampPeriod = 0.0; audSignal = NULLSIG;

   nParm = GetConfig("HLIST", TRUE, cParm, MAXGLOBS);

   if (nParm>0){

      if (GetConfInt(cParm,nParm,"AUDIOSIG",&i)) audSignal = i;

      if (GetConfInt(cParm,nParm,"TRACE",&i)) trace = i;

      if (GetConfFlt(cParm,nParm,"SOURCERATE",&d)) sampPeriod = d;

   }

}
int cTumkwsaSink::setupATK()
{
  try {

  // ------- load HTK config......
  int argc=3;
  const char* argv[3] = {"ASR","-C",NULL};
  if (configfile != NULL)
    argv[2]=configfile;
  else
    argv[2]="asr.cfg";

  if (InitHTK(argc,(char**)argv,version,TRUE)<SUCCESS){
    COMP_ERR("failed to initialise ASR subsystem!");
  }

  ConfParam *cParm[MAXGLOBS];       /* config parameters */
  int numParm,i;
  char ngramFN[100],buf[100];
  ngramFN[0] = '\0';

  // Read configuration parms for ANGRAM to see if NGram used
  numParm = GetConfig((char *)"ANGRAM", TRUE, cParm, MAXGLOBS);
  if (numParm>0){
    if (GetConfStr(cParm,numParm,(char *)"NGRAMFILE",buf)) strcpy(ngramFN,buf);
  }

  // Create Buffers
  feChan = new ABuffer("feChan");
  ansChan = new ABuffer("ansChan");

  // create a resource manager
  rman = new ARMan();

  arec = new ARec("ARec",feChan,ansChan,rman,0);

  // create global resources
  hset = new AHmms("HmmSet"); // load info in config
  dict = new ADict("ADict");
  gram = new AGram("AGram");
  rman->StoreHMMs(hset);
  rman->StoreDict(dict);
  rman->StoreGram(gram);

  ResourceGroup *main = rman->NewGroup("main");
  main->AddHMMs(hset);
  main->AddDict(dict);
  main->AddGram(gram);

  if (strlen(ngramFN)>0){
    ANGram * ngram  = new ANGram("ANGram");
    rman->StoreNGram(ngram);
    main->AddNGram(ngram);
  }

  arec->Start();
  arec->SendMessage("usegrp(main)");
  arec->SendMessage("start()");

  terminated = FALSE;

  }
  catch (ATK_Error e){ ReportErrors((char*)"ATK",e.i); return 0;}
  catch (HTK_Error e){ ReportErrors((char*)"HTK",e.i); return 0;}

  HThread t = HCreateThread("resultThread", 0, HPRIO_NORM, ATKresultThreadRunner, this);
  ATKresThread = t->thread;
  //smileThreadCreate( ATKresThread, ATKresultThreadRunner, this );

  atkIsSetup=1;
  
  return 1;
}
Beispiel #18
0
                       printf("Loading alignment HMM set %s\n",q);

                   }

                   AddMMF(&al_hset,q);

                   if (eos)

                       break;

                   q=p+1;

               }

               p++;

           }

       }

       if (strlen(al_hmmLst) > 0 ) 

           MakeHMMSet(&al_hset, al_hmmLst );

       else /* use same hmmList */

           MakeHMMSet(&al_hset, hmmListFn );

       if (strlen(al_hmmDir) > 0 )

           LoadHMMSet(&al_hset,al_hmmDir,al_hmmExt);

       else

           LoadHMMSet(&al_hset,NULL,NULL);



       /* switch model set */

       UseAlignHMMSet(fbInfo,x,&al_hset);

       if (parMode != 0) {

	  ConvDiagC(&al_hset,TRUE);

	  ConvLogWt(&al_hset);

       }



       /* and echo status */

       if (trace&T_TOP) { 

           if (strlen(al_hmmDir) > 0 )

               printf(" HMM Dir %s",al_hmmDir);

           if (strlen(al_hmmExt) > 0 )

               printf(" Ext %s",al_hmmExt);
Beispiel #19
0
int main(int argc, char *argv[])
{
   APacket p;

   try {

      // if (NCInitHTK("TRec.cfg",version)<SUCCESS){
      if (InitHTK(argc,argv,version)<SUCCESS){
         ReportErrors("Main",0); exit(-1);
      }
      printf("TRec: Basic Recogniser Test\n");
      ConfParam *cParm[MAXGLOBS];       /* config parameters */
      int numParm,i;
      char ngramFN[100],buf[100];
      ngramFN[0] = '\0';
      // Read configuration parms for ANGRAM to see if NGram used
      numParm = GetConfig("ANGRAM", TRUE, cParm, MAXGLOBS);
      if (numParm>0){
         if (GetConfStr(cParm,numParm,"NGRAMFILE",buf)) strcpy(ngramFN,buf);
      }
      printf("TRec: HTK initialised: %s\n",ngramFN);
      // Create Buffers
      ABuffer auChan("auChan");
      ABuffer feChan("feChan");
      ABuffer ansChan("ansChan");
      printf("TRec: Buffers initialised\n");
      // create a resource manager
      ARMan rman;

      // Create Audio Source and Coder
      ASource ain("AIn",&auChan);
      ACode acode("ACode",&auChan,&feChan);
      ARec  arec("ARec",&feChan,&ansChan,&rman,0);
      printf("TRec: Components initialised\n");

      // create global resources
      AHmms hset("HmmSet"); // load info in config
      ADict dict("ADict");
      AGram gram("AGram");
      rman.StoreHMMs(&hset);
      rman.StoreDict(&dict);
      rman.StoreGram(&gram);

      ResourceGroup *main = rman.NewGroup("main");
      main->AddHMMs(&hset);
      main->AddDict(&dict);
      main->AddGram(&gram);

      if (strlen(ngramFN)>0){
         ANGram * ngram  = new ANGram("ANGram");
         rman.StoreNGram(ngram);
         main->AddNGram(ngram);
      }

#ifdef WITHMON
      // Create Monitor and Start it
      AMonitor amon;
      amon.AddComponent(&ain);
      amon.AddComponent(&acode);
      amon.AddComponent(&arec);
      amon.Start();
#endif

      // Start components executing
      ain.Start();
      acode.Start();
      arec.Start();
      arec.SendMessage("usegrp(main)");
      arec.SendMessage("start()");

      Boolean terminated = FALSE;
      while (!terminated) {
         APacket p = ansChan.GetPacket();
         if (p.GetKind() == StringPacket){
            AStringData * sd = (AStringData *)p.GetData();
            if (sd->data.find("TERMINATED") != string::npos) {
               terminated = TRUE;
            }
         }
         p.Show();
      }
      // Shutdown
      printf("Waiting for ain\n");
      ain.Join();
      printf("Waiting for acode\n");
      acode.Join();
      printf("Waiting for arec\n");
      arec.Join();
#ifdef WITHMON
      printf("Waiting for monitor\n");
      amon.Terminate();
      HJoinMonitor();
#endif
      return 0;
   }
   catch (ATK_Error e){ ReportErrors("ATK",e.i); return 0;}
   catch (HTK_Error e){ ReportErrors("HTK",e.i); return 0;}
}