对于想尽快上手的新人来说,这部分内容是又累又没劲,可是又不得不做,没办法……硬着头皮上吧。
1、编写grammer,生成wordnet
(1)手动编辑grammer文件,并置于config目录下,内容如下:
$color = RED | BLUE | YELLOW;
(SENT-START ($color) SENT-END)
(2)生成wordnet:
HParse ./config/grammer ./config/wordnet
此时,config目录会生成wordnet;
2、生成字典:
(1)手动编辑wordlist文件,并置于lists目录下,wordlist内容如下(内容是经过字典排序的,请不要改动):
BLUE RED SENT-END SENT-START YELLOW
(2)手动编辑global.ded文件,并置于config目录下,global.ded内容如下
AS sp RS cmu MP sil sil sp
(3)生成monophones和dict_color:
将字典文件的“beep”和“otherDict"置于dict目录下,然后执行:
HDMan -m -w ./lists/wordlist -n ./lists/monophones -g ./config/global.ded ./dict/dict_color ./dict/beep ./dict/otherDict
此时,lists目录会生成monophones;dict目录里会生成dict_color;
3、”wav文件清单“转"mlf文件清单:
(1)手动编辑labels目录下“trainprompts”文件(还记得“(一)准备训练语音文件”中的那份清单吗?),具体方式为:
BLUE ===》 s01 SENT-START BLUE SENT-END
在原“单词”(此处为"BLUE")
前缀 "SENT-START",后缀“SENT-END”,并在行首追加录音文件的文件名"s01"(s01.wav除去扩展名)
修改结果如下如下:
s01 SENT-START BLUE SENT-END s02 SENT-START RED SENT-END s03 SENT-START BLUE SENT-END s04 SENT-START BLUE SENT-END s05 SENT-START BLUE SENT-END s06 SENT-START YELLOW SENT-END s07 SENT-START RED SENT-END s08 SENT-START BLUE SENT-END s09 SENT-START BLUE SENT-END s10 SENT-START RED SENT-END s11 SENT-START YELLOW SENT-END (……省略!省略!节省版面!……) s49 SENT-START BLUE SENT-END s50 SENT-START YELLOW SENT-END
(2)”wav文件清单“转"mlf文件清单“:
使用脚本文件prompts2mlf
perl ./scripts/prompts2mlf ./labels/trainwords.mlf ./labels/trainprompts
此时,labels目录会生成trainwords.mlf;
4、生成phones_color.led文件:
(1)手动编辑“mkphones_color.led”文件,并置于config目录下,内容如下
EX
IS sil sil
DE sp
(2)生成phones_color.led文件:
HLEd -l '*' -d ./dict/dict_color -i ./labels/phones_color.mlf ./config/mkphones_color.led ./labels/trainwords.mlf
此时,labels目录会生成phones_color.mlf;
5、wav文件转换成mlf文件:
(1)手动编辑“转换清单”codetrain.scp,并置于config目录下,内容如下(只能做参考噢,至少红色字体部分肯定是不一样的)
/home/ansersion/htk_color/data/train/speech/s01.wav /home/ansersion/htk_color/data/train/mfc/s01.mfc /home/ansersion/htk_color/data/train/speech/s02.wav /home/ansersion/htk_color/data/train/mfc/s02.mfc /home/ansersion/htk_color/data/train/speech/s03.wav /home/ansersion/htk_color/data/train/mfc/s03.mfc /home/ansersion/htk_color/data/train/speech/s04.wav /home/ansersion/htk_color/data/train/mfc/s04.mfc /home/ansersion/htk_color/data/train/speech/s05.wav /home/ansersion/htk_color/data/train/mfc/s05.mfc /home/ansersion/htk_color/data/train/speech/s06.wav /home/ansersion/htk_color/data/train/mfc/s06.mfc /home/ansersion/htk_color/data/train/speech/s07.wav /home/ansersion/htk_color/data/train/mfc/s07.mfc /home/ansersion/htk_color/data/train/speech/s08.wav /home/ansersion/htk_color/data/train/mfc/s08.mfc /home/ansersion/htk_color/data/train/speech/s09.wav /home/ansersion/htk_color/data/train/mfc/s09.mfc /home/ansersion/htk_color/data/train/speech/s10.wav /home/ansersion/htk_color/data/train/mfc/s10.mfc /home/ansersion/htk_color/data/train/speech/s11.wav /home/ansersion/htk_color/data/train/mfc/s11.mfc (……省略!省略!节省版面!……)/home/ansersion/htk_color/data/train/speech/s49.wav /home/ansersion/htk_color/data/train/mfc/s49.mfc /home/ansersion/htk_color/data/train/speech/s50.wav /home/ansersion/htk_color/data/train/mfc/s50.mfc
(2)手动编辑config_HCopy,并置于config目录下,内容如下
# Coding parameters TARGETKIND = MFCC_0_D_A TARGETRATE = 100000.0 SAVECOMPRESSED = T SAVEWITHCRC = T WINDOWSIZE = 250000.0 USEHAMMING = T PREEMCOEF = 0.97 NUMCHANS = 26 CEPLIFTER = 22 NUMCEPS = 12 ENORMALISE = F SOURCEFORMAT = WAV
(3)wav文件转换成mlf文件:
HCopy -T 1 -C ./config/config_HCopy -S ./config/codetrain.scp
此后,data/train/mfc目录会生成s01.mfc;s02.mfc……s49.mfc;s50.mfc;
6、生成初始hmm——“hmm0”:
(1)手动编辑proto,并置于config目录下,内容如下
~o <VecSize> 39 <MFCC_0_D_A> ~h "proto" <BeginHMM> <NumStates> 5 <State> 2 <Mean> 39 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 <Variance> 39 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 <State> 3 <Mean> 39 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 <Variance> 39 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 <State> 4 <Mean> 39 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 <Variance> 39 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 <TransP> 5 0.0 1.0 0.0 0.0 0.0 0.0 0.6 0.4 0.0 0.0 0.0 0.0 0.6 0.4 0.0 0.0 0.0 0.0 0.7 0.3 0.0 0.0 0.0 0.0 0.0 <EndHMM>
(2)手动编辑train.scp,并置于config目录下,内容如下(其实就是codetrain.scp的“右半边内容”):
/home/ansersion/htk_color/data/train/mfc/s01.mfc /home/ansersion/htk_color/data/train/mfc/s02.mfc /home/ansersion/htk_color/data/train/mfc/s03.mfc /home/ansersion/htk_color/data/train/mfc/s04.mfc /home/ansersion/htk_color/data/train/mfc/s05.mfc /home/ansersion/htk_color/data/train/mfc/s06.mfc /home/ansersion/htk_color/data/train/mfc/s07.mfc /home/ansersion/htk_color/data/train/mfc/s08.mfc /home/ansersion/htk_color/data/train/mfc/s09.mfc /home/ansersion/htk_color/data/train/mfc/s10.mfc /home/ansersion/htk_color/data/train/mfc/s11.mfc (……省略!省略!节省版面!……)/home/ansersion/htk_color/data/train/mfc/s49.mfc /home/ansersion/htk_color/data/train/mfc/s50.mfc
(3)手动编辑config_color文件,并置于config目录下,内容变为(即”config_HCopy“文件删除“SOURCEFORMAT = WAV”那行):
# Coding parameters TARGETKIND = MFCC_0_D_A TARGETRATE = 100000.0 SAVECOMPRESSED = T SAVEWITHCRC = T WINDOWSIZE = 250000.0 USEHAMMING = T PREEMCOEF = 0.97 NUMCHANS = 26 CEPLIFTER = 22 NUMCEPS = 12 ENORMALISE = F
(4)生成初始hmm0的内容:
HCompV -C ./config/config_color -f 0.01 -m -S ./config/train.scp -M ./hmm0 ./config/proto
此时,hmm0目录下会生成proto和vFloors;
7、生成macros、hmmdefs和monoOffSP:
(1)生成macros:
perl scripts/makeMacros hmm0/vFloors hmm0/macros
此时,hmm0目录下会生成macros;
(2)生成hmmdefs:
perl scripts/makeHmmdefs hmm0/proto lists/monophones hmm0/hmmdefs
此时,hmm0目录下会生成hmmdefs;
(3)生成monoOffSP:
perl scripts/makeMonoOffsp ./lists/monophones ./lists/monoOffSP
此时,lists目录下会生成monoOffSP;
好了,终于可以去训练hmm模型了。
HTK Book涉及内容:
Chapter 3: 3.1.1 Step 1 - the Task Grammar
Chapter 3: 3.1.2 Step 2 - the Dictionary
Chapter 3: 3.1.4 Step 4 - Creating the Transcription Files
Chapter 3: 3.1.5 Step 5 - Coding the Data
Chapter 3: 3.2.1 Step 6 - Creating Flat Start Monophones