Example #1
0
// Forward stored markers before t, all if t -ve
void ARec::OutMarkers(HTime t)
{
   if (markers.size() == 0 ) return;
   APacket p = markers.front();
   HTime pktTime = p.GetStartTime();
   while (t<0 || pktTime < t){
      markers.pop_front();
      out->PutPacket(p);
      if (markers.size() == 0) return;
      p = markers.front();
      pktTime = p.GetStartTime();
   }
}
Example #2
0
// Recognise a single observation
Boolean ARec::RecObservation()
{
   APacket pkt;
   AStringData *sd;
   AObsData *od;
   PacketKind kind;
   Boolean stopDetected = FALSE;

   if (runmode&STOP_IMMED) // stop immediately
      return TRUE;

   while (in->NumPackets()>0){
      pkt = in->GetPacket(); kind = pkt.GetKind();
      if (kind==StringPacket) {
         // check if stop marker
         sd = (AStringData *)pkt.GetData();
         if ((runmode&STOP_ATMARK) && (sd->data.find("STOP") != string::npos))
            stopDetected = TRUE;
         StoreMarker(pkt);
      }
      if (kind != StringPacket || stopDetected){
         if (stTime<0) {  // just entered runmode
            stTime = pkt.GetStartTime(); enTime = stTime;
            score = -1e6;
            trbak = "";  trbakCount = 0;
            if (runmode&RESULT_ALL)
               OutPacket(Start_PT, "", fname, 0,0,0.0,0.0,0.0,-1.0,0.0,stTime,stTime);
         }
         if (stopDetected) return TRUE;
         if (kind==ObservationPacket){
            od = (AObsData *)pkt.GetData();
            if ((runmode&STOP_ATSIL) && !od->data.vq[0])  // stop if silence
               return TRUE;
            if (trace&T_OBS) PrintObservation(frameCount,&(od->data),13);
            // recognise observation
            ProcessObservation(pri,&(od->data),-1,hset->curXForm);

            if (trace & T_FRS) {
               char *p;  MLink m;
               NetNode *node = pri->genMaxNode;
               printf("Frame %-4d ",pri->frame);
               if ( node == NULL){
                  printf("null\n");
               }else{
                  char *qm="?";
                  p = (node->wordset==NULL)?qm:node->wordset->name;
                  m=FindMacroStruct(hset,'h',node->info.hmm);
                  printf("HMM: %s (%s)  %d %5.3f\n",m->id->name,p,
                     pri->nact,pri->genMaxTok.like/pri->frame);
               }
            }
            ++frameCount; tact+=pri->nact;
            enTime += sampPeriod;
            if ((showRD || (runmode&(RESULT_IMMED|RESULT_ASAP)))
               && (++trbakCount == trbakFreq)) {
                  TraceBackRecogniser(); trbakCount = 0;
               }
         }
      }
   }
   return FALSE;
}
Example #3
0
void ShowTime(APacket p)
{
   printf("[%7.3f -> %7.3f]\n ",p.GetStartTime()/1e7,p.GetEndTime()/1e7);
}