Kaldi模型信息分析

调试方便准备

在当前egs/s5目录下新建一个文件命名为path2.sh,内容比path.sh少最后一行export LC_ALL=C用于避免数据乱码

export KALDI_ROOT=`pwd`/../../..
[ -f $KALDI_ROOT/tools/env.sh ] && . $KALDI_ROOT/tools/env.sh
export PATH=$PWD/utils/:$KALDI_ROOT/tools/openfst/bin:$PWD:$PATH
[ ! -f $KALDI_ROOT/tools/config/common_path.sh ] && echo >&2 "The standard file $KALDI_ROOT/tools/config/common_path.sh is not present -> Exit!" && exit 1
. $KALDI_ROOT/tools/config/common_path.sh

然后直接执行,后面就可以愉快的玩耍命令:

. ./path2.sh

1 mono模型

1.1 gmm-info

hmm-info不需要再观察,因为和gmm-info输出的差不多

gmm-info exp/mono/final.mdl

number of phones 217
number of pdfs 206
number of transition-ids 1314
number of transition-states 653
feature dimension 39
number of gaussians 990

注意到,这里特征维度是39维,关于特征相关的分析见GMM音素对齐【底部】

1.2 hmm-info

hmm-info exp/mono/final.mdl

number of phones 217
number of pdfs 206
number of transition-ids 1314
number of transition-states 653

1.3 am-info

这个命令和hmm-info输出是差不多的。

am-info exp/mono/final.mdl

number of phones 217
number of pdfs 206
number of transition-ids 1314
number of transition-states 653

1.4 gmm-copy

# 查看gmm拓扑结构
gmm-copy --binary=false exp/mono/final.mdl -|head -n 100

# 查看pdf-id最小值为0
gmm-copy --binary=false exp/mono/final.mdl -|awk 'NF==3{print $3}' | sort -h | head -n 1

#查看pdf-id最大值为205(下标从0开始)=> 对应number of pdfs 206
gmm-copy --binary=false exp/mono/final.mdl -|awk 'NF==3{print $3}' | sort -h | tail -n 1

这方面理解可参考理解HCLG

  • 【1】分析transition-states为什么是653
    每一个transition-state上都会带有一个phone-hmm-state的信息,因此一个transition-state可以表示一个不同的hmm-state
    因此: phone-id=1是5个有效state(0,1,2,3,4因为5没有产生组合) + 其他phone-id(0,1,2因为3没有产生组合) x 216个 = 653,这样也就证明了这个单音素模型
  • 【2】下方的 <Triples> 653
    transition-states组合有653个,如1 3 3 表示
  • 【3】分析transition-id为什么1314
    如下显示结果,phone-id=1的,共5个state(0,1,2,3,4,5),(0,1,2,3)分别有4个Transition, (4)只有2个Transition,(5)没有。
    因此:( phone-id=1的4 + 4 + 4 + 4 + 2 ) + (phone-id=其他的653-phone-id=1的5个state=653-5)x2= 1314个transition-ids
# phone-id=1的5个有效hmm-state分别包含的Transition数量
state 0 --> 4 个<Transition>
state 1 --> 4 个<Transition>
state 2 --> 4 个<Transition>
state 3 --> 4 个<Transition>
state 4 --> 2 个<Transition>

# phone-id!=1的3个有效hmm-state分别包含的Transition数量
state 0 --> 2 个<Transition>
state 1 --> 2 个<Transition>
state 2 --> 2 个<Transition>
<TransitionModel> 
<Topology> 
<TopologyEntry> 
<ForPhones> 
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 
</ForPhones> 
<State> 0 <PdfClass> 0 <Transition> 0 0.75 <Transition> 1 0.25 </State> 
<State> 1 <PdfClass> 1 <Transition> 1 0.75 <Transition> 2 0.25 </State> 
<State> 2 <PdfClass> 2 <Transition> 2 0.75 <Transition> 3 0.25 </State> 
<State> 3 </State> 
</TopologyEntry> 
<TopologyEntry> 
<ForPhones> 
1 
</ForPhones> 
<State> 0 <PdfClass> 0 <Transition> 0 0.25 <Transition> 1 0.25 <Transition> 2 0.25 <Transition> 3 0.25 </State> 
<State> 1 <PdfClass> 1 <Transition> 1 0.25 <Transition> 2 0.25 <Transition> 3 0.25 <Transition> 4 0.25 </State> 
<State> 2 <PdfClass> 2 <Transition> 1 0.25 <Transition> 2 0.25 <Transition> 3 0.25 <Transition> 4 0.25 </State> 
<State> 3 <PdfClass> 3 <Transition> 1 0.25 <Transition> 2 0.25 <Transition> 3 0.25 <Transition> 4 0.25 </State> 
<State> 4 <PdfClass> 4 <Transition> 4 0.75 <Transition> 5 0.25 </State> 
<State> 5 </State> 
</TopologyEntry> 
</Topology> 
<Triples> 653 
1 0 0 
1 1 1 
1 2 2 
1 3 3 
1 4 4 
2 0 5 
2 1 6 
2 2 7 
3 0 5 
3 1 6 
3 2 7 
...

1.5 copy-transition-model

这个命令只能输出节点的信息(因为nnet3和chain模型只有节点是属于hmm的),如上面所示

copy-transition-model --binary=false exp/mono/final.mdl -|head -n 100

2 三音素triphone模型

gmm-info exp/tri2/final.mdl

number of phones 217
number of pdfs 1960
number of transition-ids 11550
number of transition-states 5771
feature dimension 39
number of gaussians 20029

gmm-copy --binary=false exp/tri2/final.mdl -|head -n 100

#查看pdf-id最大值为1959(下标从0开始)=> 对应number of pdfs 1960
gmm-copy --binary=false exp/mono/final.mdl -|awk 'NF==3{print $3}' | sort -h | tail -n 1

这里分析,[5771-18(phone-id=1的8条边)]x2 + 18 = 11524,还差26个,不太清楚**

  • 【分析transition-states为什么是653】
    phone-id=1是5个有效hmm-state(0,1,2,3,4因为5没有产生组合) + 其他phone-id(0,1,2因为3没有产生组合) x 216个= 653,这样也就证明了不是的单音素,是三音素模型,(5771 - 5)/3=1922个,说明静音没有放在三音素上下文中,剩下其他216个phone,构建出1922个三音素,平均每个phone有8.8个三音素,由状态决策树绑定共享
<TransitionModel> 
<Topology> 
<TopologyEntry> 
<ForPhones> 
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 
</ForPhones> 
<State> 0 <PdfClass> 0 <Transition> 0 0.75 <Transition> 1 0.25 </State> 
<State> 1 <PdfClass> 1 <Transition> 1 0.75 <Transition> 2 0.25 </State> 
<State> 2 <PdfClass> 2 <Transition> 2 0.75 <Transition> 3 0.25 </State> 
<State> 3 </State> 
</TopologyEntry> 
<TopologyEntry> 
<ForPhones> 
1 
</ForPhones> 
<State> 0 <PdfClass> 0 <Transition> 0 0.25 <Transition> 1 0.25 <Transition> 2 0.25 <Transition> 3 0.25 </State> 
<State> 1 <PdfClass> 1 <Transition> 1 0.25 <Transition> 2 0.25 <Transition> 3 0.25 <Transition> 4 0.25 </State> 
<State> 2 <PdfClass> 2 <Transition> 1 0.25 <Transition> 2 0.25 <Transition> 3 0.25 <Transition> 4 0.25 </State> 
<State> 3 <PdfClass> 3 <Transition> 1 0.25 <Transition> 2 0.25 <Transition> 3 0.25 <Transition> 4 0.25 </State> 
<State> 4 <PdfClass> 4 <Transition> 4 0.75 <Transition> 5 0.25 </State> 
<State> 5 </State> 
</TopologyEntry> 
</Topology> 
<Triples> 5771 
1 0 0 
1 1 69 
1 2 70 
1 3 71 
1 4 68 
2 0 770 
2 0 1012 
2 0 1128 
2 0 1203 
2 0 1204 
2 0 1359 

3 chain模型

3.1 hmm-info

因为是nnet3模型,肯定是用不了gmm-info了。只能用hmm-info来观察,因为final.mdl里面有TransitionModel节点

hmm-info exp/chain/tdnn_1a_sp/final.mdl

number of phones 217
number of pdfs 4064
number of transition-ids 8692
number of transition-states 4346

3.2 nnet3-am-copy

nnet3-am-copy --binary=false --prepare-for-test=true exp/chain/tdnn_1a_sp/final.mdl -|head -n 100 

这样就能输出HMM部分的信息,虽然用这个命令也可以得到一些网络信息但是较为不详细用下面的。

<TransitionModel> 
<Topology> 
<TopologyEntry> 
<ForPhones> 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 
</ForPhones> 
<State> 0 <ForwardPdfClass> 0 <SelfLoopPdfClass> 1 <Transition> 0 0.5 <Transition> 1 0.5 </State> 
<State> 1 </State> 
</TopologyEntry> 
</Topology> 
<Tuples> 4346 
1 0 0 109 
2 0 396 768 
2 0 472 540 
2 0 472 768 
2 0 498 445 
2 0 895 1685 
2 0 1135 967 
2 0 1166 2462 
2 0 1170 2505 
2 0 1589 2505 
2 0 1669 912 
2 0 1669 967 

3.3 nnet3-am-info

可观察出网络的基本信息和参数量

nnet3-am-info exp/chain/tdnn_1a_sp/final.mdl
input-dim: 40
ivector-dim: -1
num-pdfs: 4064
prior-dimension: 0
# Nnet info follows.
left-context: 18
right-context: 13
num-parameters: 1370048
modulus: 1
input-node name=input dim=40
component-node name=lda component=lda input=Append(Offset(input, -2), Offset(input, -1), input, Offset(input, 1)) input-dim=400 output-dim=400
component-node name=tdnn1.affine component=tdnn1.affine input=lda input-dim=400 output-dim=1280
component-node name=tdnn1.relu component=tdnn1.relu input=tdnn1.affine input-dim=1280 output-dim=1280
component-node name=tdnn1.batchnorm component=tdnn1.batchnorm input=tdnn1.relu input-dim=1280 output-dim=1280
component-node name=tdnn2.affine component=tdnn2.affine input=Append(Offset(tdnn1.batchnorm, -1), tdnn1.batchnorm Offset(tdnn1.batchnorm, 2)) input-dim=3840 output-dim=1280
component-node name=tdnn2.relu component=tdnn2.relu input=tdnn2.affine input-dim=1280 output-dim=1280
component-node name=tdnn2.batchnorm component=tdnn2.batchnorm input=tdnn2.relu input-dim=1280 output-dim=1280
...
component-node name=output-xent.affine component=output-xent.affine input=prefinal-xent.batchnorm input-dim=1280 output-dim=4064
component-node name=output-xent.log-softmax component=output-xent.log-softmax input=output-xent.affine input-dim=4064 output-dim=4064
...

3.4 copy-transition-model

这个命令只能输出节点的信息(因为nnet3和chain模型只有节点是属于hmm的),如上面所示

copy-transition-model --binary=false exp/chain/tdnn_1a_sp/final.mdl -|head -n 100

从结果可以看出,chain模型中HMM,所有phone都只有1个hmm-state,而且每个hmm-state都只有2个Transition

<TransitionModel> 
<Topology> 
<TopologyEntry> 
<ForPhones> 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 
</ForPhones> 
<State> 0 <ForwardPdfClass> 0 <SelfLoopPdfClass> 1 <Transition> 0 0.5 <Transition> 1 0.5 </State> 
<State> 1 </State> 
</TopologyEntry> 
</Topology> 
<Tuples> 4346 
1 0 0 109 
2 0 396 768 
2 0 472 540 
2 0 472 768 
2 0 498 445 
2 0 895 1685 

4 mono的tree分析

4.1 tree-info

tree-info exp/mono/tree

num-pdfs 206
context-width 1
central-position 0

tree-info exp/tri1/tree
num-pdfs 1952
context-width 3
central-position 1

tree-info exp/chain/tdnn_1a_sp/tree
num-pdfs 4064
context-width 2
central-position 1

【特别注意】从这里可以看出来chain模型用到的音素上下文确实是bi-context-phone的,因为context-width=2

4.2 copy-tree

以txt形式查看树的结构,在了解结构之后,可以尝试缩减pdf-id的个数,以降低模型大小,提高nnet3容量

copy-tree --binary=false exp/mono/tree - | head -n 100

【特别注意】

  • 【1】SE(SplitEventMap)表示分裂节点(即 phone=? \text{phone=?} phone=?),后面紧跟的数字可为{-1,0,1,2},-1表示将都达到pdf-class的编号分叉,{0,1,2}分别表示{左上下文音素, 中心音素, 右上下文音素}
  • 【2】TE(TableEventMap)表示叶子节点查找表(即 pdf-Class=? \text{pdf-Class=?} pdf-Class=?),即叶子节点的父亲,后面第1个数字和SE一样,第2个数字表示其即将划分的叶子节点个数(即hmm-state的个数),其分支上的值一般会为0、1、2(静音会有3、4、5)
  • 【3】CE(ConstantEventMap)表示叶子节点,即hmm-state对应的pdf-Class(带一个pdf-id编号 两个圆形框)


    这里就只展示和下面展示的tree图表达意思相同的几个节点值:
  • 【1】下文tree第1个图分析结果
SE 0 [ 175 176 177 178 179 180 181 182 183 ]
{ SE 0 [ 175 176 177 178 ]
{ TE -1 3 ( CE 167 CE 168 CE 169 ) 
TE -1 3 ( CE 170 CE 171 CE 172 ) 
} 
SE 0 [ 184 185 186 187 188 ]
{ TE -1 3 ( CE 173 CE 174 CE 175 ) 
TE -1 3 ( CE 176 CE 177 CE 178 ) 
} 
}
  • 【2】下文tree第2个图分析结果,这里面包含静音sil
{ SE 0 [ 1 ]
{ TE -1 5 ( CE 0 CE 1 CE 2 CE 3 CE 4 ) 
TE -1 3 ( CE 5 CE 6 CE 7 ) 
} 
SE 0 [ 7 ]
{ TE -1 3 ( CE 8 CE 9 CE 10 ) 
TE -1 3 ( CE 11 CE 12 CE 13 ) 
} 
}
  • 【3】下文tree第3个图分析结果
{ SE 0 [ 209 210 211 212 213 ]
{ TE -1 3 ( CE 191 CE 192 CE 193 ) 
TE -1 3 ( CE 194 CE 195 CE 196 ) 
} 
TE 0 218 ( NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL TE -1 3 ( CE 197 CE 198 CE 199 ) 
TE -1 3 ( CE 200 CE 201 CE 202 ) 
TE -1 3 ( CE 203 CE 204 CE 205 ) 
) 
}

4.3 draw-tree

这部分可参考kaldi的WFST、决策树可视化理解【tree可视化】,这里只展示了部分tree图,phone-id=1是(0,1,2,3,4)共5个有效hmm-state状态,其他都是(0,1,2)三个hmm-state有效状态

draw-tree phones.txt tree|dot -Tpdf >tree.pdf

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述


5 总结一下

在看下面这些之前,可以去看一下理解HCLG比如什么是transition-state

5.1 数量关系表

这里的phone-id是独立phone,不包含上下文音素的总数。

模型phone-id数量pdf-id数量transition-id数量transition-state数量context-widthcontext-position
mono217206131465310
tri1217195211312565231
tri2217196011550577131
tri3a217204011832591231
tri4a217207212074603331
tri5a217292016442821731
nnet3-tdnn217304811518575531
chain-tdnn21740648692434621

从这里可以看出,chain模型的音素上下文是取 [左上下文+中心音素] = biphone \text{[左上下文+中心音素]}=\text{biphone} [左上下文+中心音素]=biphone,而比如tri2用的 [左上下文+中心音素-右上下文] = triphone \text{[左上下文+中心音素-右上下文]}=\text{triphone} [左上下文+中心音素-右上下文]=triphone

train_set=train_sp
ali_dir=exp/tri5a_sp_ali
lang=data/lang_chain
#5000是build-tree程序中的--max-leaves(Maximum number of leaves to be used in tree-buliding)
treedir=exp/chain/tri6_7d_tree_sp
steps/nnet3/chain/build_tree.sh --frame-subsampling-factor 3 \
--context-opts "--context-width=2 --central-position=1" \
--cmd "$train_cmd" 5000 data/$train_set $lang $ali_dir $treedir

因为mono模型是没有用状态决策树绑定的,delta模型有,会发现:

# 这里的2500其实是里面的build-tree --verbose=1 --max-leaves=$numleaves参数
steps/train_deltas.sh --cmd "$train_cmd" 2500 20000 data/train data/lang exp/mono_ali exp/tri1

5.2 transition-state和hmm-state关系

transition-state-num = hmm-state-num a l l - p h o n e = hmm-state-num sil × 5 + hmm-state-num o t h e r - p h o n e × 3 ≈ hmm-state-num × 3 ≥ pdf-id-num  × 3 \begin{aligned} \text{transition-state-num}&=\text{hmm-state-num}_{all\text{-}phone} \\ &=\text{hmm-state-num}_{\text{sil}}\times 5+\text{hmm-state-num}_{other\text{-}phone}\times 3 \\ &\approx\text{hmm-state-num} \times 3 \\ &\ge \text{pdf-id-num} \ \times 3 \end{aligned} transition-state-num=hmm-state-numall-phone=hmm-state-numsil×5+hmm-state-numother-phone×3hmm-state-num×3pdf-id-num ×3

  • 【1】sil表示静音,静音有5个hmm-state,ohter-phone表示非静音一般有3个hmm-state
  • 【2】phone可以表示单音素(如ii) 或 上下文相关的三音素(如a1+ii-van4)
  • 【3】会发现 transition-sate-num 约是 hmm-state-num 的 3 倍

5.3 transition-id和hmm-state关系

transition-id-num = hmm-stateToTransition-num a l l - p h o n e = hmm-stateToTransition-num sil + hmm-state-num o t h e r - p h o n e × 3 × 2 = { 4 × 4 + 2 } + hmm-state-num o t h e r - p h o n e × 3 × 2 \begin{aligned} \text{transition-id-num}&=\text{hmm-stateToTransition-num}_{all\text{-}phone} \\ &=\text{hmm-stateToTransition-num}_{\text{sil}}+\text{hmm-state-num}_{other\text{-}phone}\times 3 \times 2 \\ &= \left\{ 4 \times 4 + 2 \right\}+\text{hmm-state-num}_{other\text{-}phone}\times 3 \times 2 \\ \end{aligned} transition-id-num=hmm-stateToTransition-numall-phone=hmm-stateToTransition-numsil+hmm-state-numother-phone×3×2={4×4+2}+hmm-state-numother-phone×3×2

  • 【1】静音phone有5个hmm-state,其中 hmm-state 0 − 3 \text{hmm-state}_{0-3} hmm-state03存在4个Transition, hmm-state 4 \text{hmm-state}_4 hmm-state4有2个Transition,因此 { 4 × 4 + 2 } \left\{ 4 \times 4 + 2 \right\} {4×4+2}
  • 【2】非静音phone都有3个hmm-state,每个hmm-state存在2个Transition(两条边)
<ForPhones>非静音phone</ForPhones> 
<State> 0 <PdfClass> 0 <Transition> 0 0.75 <Transition> 1 0.25 </State> 
<State> 1 <PdfClass> 1 <Transition> 1 0.75 <Transition> 2 0.25 </State> 
<State> 2 <PdfClass> 2 <Transition> 2 0.75 <Transition> 3 0.25 </State> 
<State> 3 </State> 
</TopologyEntry> 
<TopologyEntry> 
<ForPhones> 1 </ForPhones> 
<State> 0 <PdfClass> 0 <Transition> 0 0.25 <Transition> 1 0.25 <Transition> 2 0.25 <Transition> 3 0.25 </State> 
<State> 1 <PdfClass> 1 <Transition> 1 0.25 <Transition> 2 0.25 <Transition> 3 0.25 <Transition> 4 0.25 </State> 
<State> 2 <PdfClass> 2 <Transition> 1 0.25 <Transition> 2 0.25 <Transition> 3 0.25 <Transition> 4 0.25 </State> 
<State> 3 <PdfClass> 3 <Transition> 1 0.25 <Transition> 2 0.25 <Transition> 3 0.25 <Transition> 4 0.25 </State> 
<State> 4 <PdfClass> 4 <Transition> 4 0.75 <Transition> 5 0.25 </State> 
<State> 5 </State> 

5.4 pdf-id和hmm-state关系

一个hmm-state是对应一个pdf-id,但是考虑到状态决策树绑定,有一些hmm-state会共享同一个pdf-id,实际实际的hmm-state数量会远远大于pdf-id数量。
hmm-state-num ≥ pdf-id-num \begin{aligned} \text{hmm-state-num} \ge \text{pdf-id-num} \end{aligned} hmm-state-numpdf-id-num

5.5 chain模型的这些关系

transition-state-num = hmm-state-num a l l - p h o n e = hmm-state-num all-phone × 1 transition-id-num = hmm-state-num a l l - p h o n e = hmm-state-num all-phone × 2 \begin{aligned} \text{transition-state-num}&=\text{hmm-state-num}_{all\text{-}phone} \\ &=\text{hmm-state-num}_{\text{all\text{-}phone}}\times 1 \\ \\ \text{transition-id-num}&=\text{hmm-state-num}_{all\text{-}phone} \\ &=\text{hmm-state-num}_{\text{all\text{-}phone}}\times 2 \\ \end{aligned} transition-state-numtransition-id-num=hmm-state-numall-phone=hmm-state-numall-phone×1=hmm-state-numall-phone=hmm-state-numall-phone×2

copy-transition-model --binary=false exp/chain/tdnn_1a_sp/final.mdl -|head -n 100
  • 【1】从结果可以看出,chain模型中HMM,所有phone都只有1个有效hmm-state,因此导致对应一个transition-state
  • 【2】每个有效hmm-state都只有2个Transition,因此对应2个transition-id(两条边)
<TransitionModel> 
<Topology> 
<TopologyEntry> 
<ForPhones> 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 
</ForPhones> 
<State> 0 <ForwardPdfClass> 0 <SelfLoopPdfClass> 1 <Transition> 0 0.5 <Transition> 1 0.5 </State> 
<State> 1 </State> 
</TopologyEntry> 
</Topology> 
<Tuples> 4346 
1 0 0 109 
2 0 396 768 
2 0 472 540 
2 0 472 768 
2 0 498 445 
2 0 895 1685 

各种模型配置可以见aishell1的egs

References

kaldi声学模型中hmm-info 结果分析

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值