WEB开发网
开发学院软件开发VC 在vc++6.0/2003/2005/2008中调用HTK 阅读

在vc++6.0/2003/2005/2008中调用HTK

 2009-04-27 20:06:39 来源:WEB开发网   
核心提示: int error = sudxCalcBuffer( pFileBuf, segSize, &pOut, &outSize, &pTail, &tailSize, last_result);if ( error > 0 ){sprintf(gcaMsg , "Af sud

  int error = sudxCalcBuffer( pFileBuf, segSize, &pOut, &outSize, &pTail, &tailSize, last_result);
  if ( error > 0 )
  {
  sprintf(gcaMsg , "Af sudxCalcBuffer...%sn", VoiceName);
  printf( gcaMsg );
  fflush(stdout);
  if ( outSize > (64 + 1 ))
  {
  old_clock = clock();
  int compare_turn = outSize - 64 - 1;
  for(int i=0; i<COMPARE_TURN; { int i++) for(int [%s]n?, file if(tailSize tailSize="compare_turn+64-300-i;" sampleSetList[j].name); (i+1)*128, %d, pos sample at Match printf(?Quick ) FALSE) &(sampleSetList[j].tags[1]), sudxCompare(pOut+1+i, if( j++) j<vector_count; j="0;" iMatchCount)++; (*>300)
  {
  if(sudxCompare(pOut+1+i, sampleSetList[j].tags+1, TRUE))
  {
  (* iMatchCount) ++;
  printf("精确匹配位置 %d, file[%s]n", (i+1)*128, sampleSetList[j].name);
  }
  else
  {
  // printf("!!Slow Not Match at sample pos %d, file[%s]n", (i+1)*128, sampleSetList[j].name);
  }
  }
  }
  }
  }
  int time_passed = clock()-old_clock;
  printf("计算结束, 耗时%d ms Match Count =%dn", time_passed,(* iMatchCount) );
  printf("比较速度为每秒钟可查找%f秒音乐n", double(compare_turn)*128.0/8000.0/(double(time_passed)/1000.0));
  fflush( stdout );
  }
  else
  {
  printf("输入的声音过短,不能比较n");
  return -2;
  }
  }
  else
  {
  sprintf(gcaMsg , "Now Fail ...%sn return -1", "CalcBuffer");
  printf( gcaMsg );
  fflush(stdout);
  return -1;
  }
  }
  catch ( ... )
  {
  sprintf(gcaMsg , "Now Fail ...%sn return -3", "Catch");
  printf( gcaMsg );
  fflush(stdout);
  return -3;
  }
  return 0;
  }
  char * asds_version="!HVER!ASDS: 1.6.0 [SJY 01/06/07]";
  #include "AMonitor.h"
  #include "AIO.h"
  // ---------------- Globals To Define the Recognition System -----------------
  class QA;
  // Information Channel - connects to AIO output
  static ABuffer *inChan; // input channel from AIO
  // Active components (threads)
  // NB: AIO will start-up its own ASource,ASyn,ACode & ARec
  static AIO *aio; // the AIO subsystem
  static AMonitor *amon; // system monitor
  // Global resources - these will be passed to AIO on creation
  arman *rman; // resource manager for dict, grammars and HMMSet
  AHmms *hset; // HMM set is global since it never changes
  ADict *dict; // ditto dictionary (though it can be edited if desired)
  AGram *ggrm; // global grammar, always active
  QA *qty, *top; // question/answer instances
  // ------------------ Simple Question/Answer Class ----------------------
  // the status of each slot determines the dialogue flow. each slot
  // starts as unknown. When an answer is provided with high confidence
  // (>minconf), the slot is immediately grounded. Otherwise the slot
  // status moves to unconfirmed ready for explicit checking.
  typedef enum { unknown, unconfirmed, grounded, cancelled } SlotStatus;
  // the system listens to the user in QA.listen, this implements a simple
  // state machine where the states are:
  typedef enum { aActive,aInProcess,aTimeout,aDone,aTerminated} ASRStatus;
  typedef enum { sActive, sDone, sInt } SynStatus;
  static Boolean terminated = FALSE;
  static const float minconf = 0.5;
  class QA {
  public:
  QA(const string& aname, // name of qa object
  const string& aprompt, // query prompt
  const string& gramfile, // name of grammar file
  const string& ahelp); // help message
  ASRStatus Listen(string prompt, string rgroup, SynStatus& ss);
  // output prompt and listen using given res group and update slot value
  void Ask(); // ask question, record answer and set status
  void Check(); // check answer and set status
  void GetSlot(); // get a value for the slot by asking and checking
  string GetValue(); // strip tag and return actual value
  void Show(); // show current slot status
  void Reset();
  SlotStatus status; // slot status
  string value; // slot value
  float curconf; // current input
  string curtag;
  string curwords;
  private:
  string name; // name of slot (also name of semantic tag)
  string prompt; // question
  string help; // help string
  ResourceGroup *ask;
  ResourceGroup *chk;
  };
  // construct a QA object with given prompt and grammar
  QA::QA(const string& aname, const string& aprompt,
  const string& gramfile, const string& ahelp)
  {
  // save the prompts
  prompt = aprompt; help = ahelp; name = aname;
  // create grammar specific to this question

上一页  1 2 3 4 5  下一页

Tags:vc 调用 HTK

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接