一、引言
最近在使用kaldi搭建语音识别系统,想把关于语音识别的相关知识点记录下来,加深自己的记忆与理解。
在语音识别中经常会遇到.fst文件,openFst,WFST等,那FST是什么鬼呢?如何理解它们呢?
FST(finite-state transducers,有限状态机)
WFST(weighted finite-state transducers,加权有限状态机)
二、FST图的理解
首先有三个文件,text.fst、isyms.txt、osyms.txt。

text.fst文件的内容为(请无视前面的行号):

0 1 a x .5
0 1 b y 1.5
1 2 c z 2.5
2 3.5

前三行是FST中的弧(arc),格式为**[ 起点(src),终点(dest),输入标签(ilabel),输出标签(olabel) ,权重(weight)]**;弧在文件中的顺序可以交换,但是初始状态的弧必须在第一行。最后一行为最终状态的编号和最终状态的权值。这个文件描述的是FST的结构,根据这个文件可以得到下图:
在这里插入图片描述
从上图可以看出字符串ac到xz的转换的权重为0.5+2.5+3.5=6.5.

关于这个图的说明放一段openFst教程中的原话:The initial state is label 0. There can only be one initial state. The final state is 2 with final weight of 3.5. Any state with non-infinite final weight is a final state. There is an arc (or transition) from state 0 to 1 with input label a, output label x, and weight 0.5. This FST transduces, for instance, the string ac to xz with weight 6.5 (the sum of the arc and final weights). Note we have assumed the library default Weight type for this description.

isyms.txt文件内容为:

<eps> 0
a 1
b 2
c 3

osyms.txt文件内容为:

<eps> 0
x 1
y 2
z 3

isyms.txt和osyms.txt是输入标签和输出标签对应的符号。因为FST的输入标签和输出标签在内部都是用数字表示的,所以要有这么两个符号表。可以使用任意的非负整数作为符号的ID。那个为0的标签ID是为epsilon标签保存的,epsilon是一个空字符串。上面的例子中并没有用到epsilon这个标签,openFST的教程上面说以后会用到,具体干什么我也还不清楚。

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐