StartRecognition代码解析

在此之前的十几篇Blog都是在介绍HTK的词典、词格网络、识别Phone网络、HMM参数训练过程等,都是为了在识别时有据可循。

现在开始讲解,如何一步一步的将观察序列幻化为人可理解的文本。StartRecognition函数是这个过程的开端。

首先说这个函数是为了完成识别器的初始化工作,获取pri,即为私有识别信息,它是vri的一项数据,而vri又是从哪来的呢?它包含哪些数据呢?可以看出在StartRecognition函数之前还有些初始化工作,否则就得建立vri和pri等。这些信息暂且不表。

然后就是各种设置初始值。net->chain的所有节点的inst都为NULL;其中pri->psi涉及的计算值都为-1.

最后,调用AttachInst函数,完成net初始化。

1)new一个NetInst,加入到net->initial的NetInst数据项;

2)将该Inst追加到pri的tail后面;

3)并且重新组织Inst,表示下一步要传递的节点。

/* The instances actually store tokens and links etc */
/* Instances are stored in creation/token propagation order to allow */
/* null/word/tee instances to be connected together and still do propagation */
/* in one pass.  Only HMMs need extra tokens, others are 1 state */
struct _NetInst
{
   struct _NetInst *link; /* Doubly linked list of instances, forward */
   struct _NetInst *knil; /* Doubly linked list of instances, backward */

   NetNode *node;       /* Position of instance within network */

   int flags;           /* Flags, active ... */
   TokenSet *state;     /* TokenSet[0..N-2] in state [1..N-1] for hmm */
   TokenSet *exit;      /* TokenSet in exit state */

   LogFloat wdlk;       /* Max likelihood of t=0 path to word end node */
   LogFloat max;        /* Likelihood for pruning of instance */

   Boolean pxd;         /* External propagation done this frame */
   Boolean ooo;         /* Instance potentially out of order */

#ifdef SANITY
   int ipos;
#endif
};

 

上一篇:你写的单例真的安全吗?


下一篇:Modify AWS EC2 Reserved Instances