1. 程式人生 > >語音識別學習記錄 [kaldi中的openfst]

語音識別學習記錄 [kaldi中的openfst]

在Kaldi tutorial: Overview of the distribution中介紹了一個使用openfst的例子。先來介紹一下這個例子,再來說明FST(finite-state transducers,有限狀態機)如何應用到語音識別中。

首先有三個檔案,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的教程上面說以後會用到,具體幹什麼我也還不清楚。

以上內容主要來自openFst官網的FstQuickTour。