/* Types of node that can appear in the network */ enum { n_unused, /* Node Instance not yet assigned */ n_hmm=2, /* Node Instance represents HMM */ n_word=4, /* Node Instance represents word end (or null) */ n_tr0=4, /* Entry token reaches exit in t=0 */ n_wd0=1, /* Exit token reaches word node in t=0 */ n_wdstart=8, /* Temporary wdstart node */ n_nocontext=15, /* binary and with this to remove context ids */ n_lcontext=16, /* Multiplication factor for context id */ n_rcontext=16384 /* Multiplication factor for context id */ }; typedef int NetNodeType;
上面是NetNode的类型,其中后四个比较少见,可以暂时不考虑。
最主要的、数量最多的就是n_hmm和n_word,分别代表hmm模型节点和词节点。也决定着NetNode里的联合体info将呈现HLink还是Pron。
struct _NetNode { NetNodeType type; /* Type of this node (includes context) */ union { HLink hmm; /* HMM (physical) definition */ Pron pron; /* Word represented (may == null) */ } info; /* Extra information specific to type of node */ char *tag; /* Semantic tagging information */ int nlinks; /* Number of nodes connected to this one */ NetLink *links; /* Array[0..nlinks-1] of links to connected nodes */ NetInst *inst; /* Model Instance (if one exists, else NULL) */ NetNode *chain; int aux; };
HLink指向hmm对象,Pron指向WordPron对象。
typedef HMMDef * HLink; typedef struct { struct _HMMSet *owner; /* owner of this model */ short numStates; /* includes entry and exit states */ StateElem *svec; /* array[2..numStates-1] of StateElem */ SVector dur; /* vector of model duration params, if any */ SMatrix transP; /* transition matrix (logs) */ int tIdx; /* Transition matrix index */ int nUse; /* num logical hmm's sharing this def */ Ptr hook; /* general hook */ } HMMDef;
typedef struct _WordPron *Pron; typedef struct _WordPron{ /* storage for each pronunciation */ short pnum; /* Pronunciation number 1..nprons */ short nphones; /* Number of phones in pronuciation */ LabId *phones; /* Array[0..nphones-1] of phones */ LogFloat prob; /* Log probability of pronunciation */ LabId outSym; /* Output symbol generated when pronunciation recognised */ Word word; /* Word this is a pronuciation of */ Pron next; /* Next pronunciation of word */ void *aux; /* hook for temp info */ } WordPron;
它们在识别中起不同的作用。
除此之外,还有n_tr0表明这个节点是Tee模型,就是它对应的hmm模型的第一个入口状态可以直接跳到最后一个出口状态。
n_wd0表明token传递到词边界类型。这种情况下,首先它得是hmm模型,也是type&n_hmm不为零,然后分两个情况