
本文介绍 kaldi-ctc 构建 CTC[1, 2, 3, 4] 语音识别加权有限状态机(WFST)解码网络的方式。
示例相关资源 lifeiteng/codingmath/CTC-decoding-graph
构建语言模型
以 单句 “how are you are” 作为文本语料,训练 bi-gram(order=2)语言模型

生成 G.fst [data/lang_2/G.pdf],如下图

准备"发音" 词典
不同单元 phone[1, 2] / character[3, 4],都可以抽象为“发音”词典的形式,以 phone 词典为例

其中 !SIL SIL 为额外添加,作为 OOV 的替换符号使用,亦可使用其他记号 e.g. UNK NSN 。

其中 --num-sil-states 1 --num-nonsil-states 1 用于构建单状态TransitionModel(HMM)。
生成 L.fst [data/lang_2/L.pdf]

Optinal 的 SIL( SIL : / 2_1 )使得发音词典与语言模型 Composition 之后的搜索空间允许单词间停顿而不影响语言模型概率计算。
构建HCLG
像 DNN-HMM hybrid 系统一样构建HCLG[5]:

kaldi-ctc 可以方便构建CI[1] phone / CD[2] phone / character[3, 4] 的 CTC 系统,只需构建相应 CI-phone / CD-phone / character 的决策树和训练数据即可。
HCLG [exp/mono_ctc_decoding_graph/HCLG.pdf] 网络:

修改HCLG 构建CTC解码网络
修改 HCLG 的 input label(即 TransitionId)并插入 blank loop 构建CTC解码网络。
arc.ilabel++, 添加 blank loop

最终 CTC 解码网络如下: [exp/mono_ctc_decoding_graph/CTC.pdf]

解码时从解码网络获得TransitionId转为对应的PdfId做为 RNN 输出层索引获得
log_likelihood = log(RNN output[pdf_id]) - log(prior[pdf_id])
尖峰现象
以 CTC 准则训练的 RNN 模型输出概率有明显的尖峰现象[1]: [images/pink.png]

解码时跳过blank概率接近1的帧可以极大提升实时率。