StartRecognition代码解析

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

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

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

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

我们之前讨论过了net->chain包含了所有的词节点和HMM类型节点。这样net就包含了所有识别图网络信息(从initial到chai,最后到final),而无需其他信息(比如Lattice相关的)。但是chain指针的顺序并不是识别时token传递的顺序。

最后,调用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
};

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值