yes/no识别
预先建立yn文件夹
第一步:创建训练文件
DOS下打开yn文件夹,命令:HSLab yes.sig 创建10个yes音,10个no音,10个sil(静音)。保存在yn/sig下。
第二步:声学分析
抽取yes和no的mfcc特征参数。保存在yn/mfcc下。
命令:HCopy –C extract.conf –S iofile.txt
其中 extract.conf(在yn文件夹下)为抽取参数配置文件,
内容为:
#
# Example of an acoustical analysis configuration file
#
SOURCEFORMAT = HTK # Gives the format of the speech files
TARGETKIND = MFCC_D_A_0 # Identifier of the coefficients to use
# Unit = 0.1 micro-second :
WINDOWSIZE = 250000.0 # = 25 ms = length of a time frame
TARGETRATE = 100000.0 # = 10 ms = frame periodicity
NUMCEPS = 12 # Number of MFCC coeffs (here from c1 to c12)
USEHAMMING = T # Use of Hamming function for windowing frames
PREEMCOEF = 0.97 # Pre-emphasis coefficient
NUMCHANS = 26 # Number of filterbank channels
CEPLIFTER = 22 # Length of cepstral liftering
# The End
iofile.txt(在yn文件夹下)说明抽取源文件路径和目标文件的保存路径,
内容如下:
sig/yes0.sig mfcc/yes0.mfcc
sig/yes1.sig mfcc/yes1.mfcc
sig/yes2.sig mfcc/yes2.mfcc
sig/yes3.sig mfcc/yes3.mfcc
sig/yes4.sig mfcc/yes4.mfcc
sig/yes5.sig mfcc/yes5.mfcc
sig/yes6.sig mfcc/yes6.mfcc
sig/yes7.sig mfcc/yes7.mfcc
sig/yes8.sig mfcc/yes8.mfcc
sig/yes9.sig mfcc/yes9.mfcc
sig/no0.sig mfcc/no0.mfcc
sig/no1.sig mfcc/no1.mfcc
sig/no2.sig mfcc/no2.mfcc
sig/no3.sig mfcc/no3.mfcc
sig/no4.sig mfcc/no4.mfcc
sig/no5.sig mfcc/no5.mfcc
sig/no6.sig mfcc/no6.mfcc
sig/no7.sig mfcc/no7.mfcc
sig/no8.sig mfcc/no8.mfcc
sig/no9.sig mfcc/no9.mfcc
sig/sil0.sig mfcc/sil0.mfcc
sig/sil1.sig mfcc/sil1.mfcc
sig/sil2.sig mfcc/sil2.mfcc
sig/sil3.sig mfcc/sil3.mfcc
sig/sil4.sig mfcc/sil4.mfcc
sig/sil5.sig mfcc/sil5.mfcc
sig/sil6.sig mfcc/sil6.mfcc
sig/sil7.sig mfcc/sil7.mfcc
sig/sil8.sig mfcc/sil8.mfcc
sig/sil9.sig mfcc/sil9.mfcc
第三步:HMM原型定义
建立文件hmm_yes.hmm、hmm_no.hmm、hmm_sil.hmm保存在yn/model/proto下。
hmm_yes.hmm内容如下:
~o <VecSize> 39 <MFCC_D_A_0>
~h "yes"
<BeginHMM>
<NumStates> 6
<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
<State> 5
<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> 6
0.0 0.5 0.5 0.0 0.0 0.0
0.0 0.4 0.3 0.3 0.0 0.0
0.0 0.0 0.4 0.3 0.3 0.0
0.0 0.0 0.0 0.4 0.3 0.3
0.0 0.0 0.0 0.0 0.5 0.5
0.0 0.0 0.0 0.0 0.0 0.0
<EndHMM>
hmm_no.hmm、hmm_sil.hmm有着相同的内容
第四步:HMM训练
1.初始化:(建立文件夹yn/train/init)
命令: HInit -S trainlist_yes -M train -H model/proto/hmm_yes.hmm yes
trainlist_yes(在yn文件夹下)内容为:
mfcc/yes0.mfcc
mfcc/yes1.mfcc
mfcc/yes2.mfcc
mfcc/yes3.mfcc
mfcc/yes4.mfcc
mfcc/yes5.mfcc
mfcc/yes6.mfcc
mfcc/yes7.mfcc
mfcc/yes8.mfcc
mfcc/yes9.mfcc
no、sil类似地初始化。
2.训练
命令:HRest -H train/init/hmm_yes.hmm -S trainlist_yes -M train yes
no、sil类似地训练。
第五步:任务定义
1. 建立语法规则和字典
建立语法规则文件gram.txt(在yn文件夹下),内容为:
/*
* Task grammar
*/
$WORD = YES | NO;
( { SIL } [ $WORD ] { SIL } )
建立字典文件dict.txt(在yn文件夹下),内容为:
YES [yes] yes
NO [no] no
SIL [sil] sil
2. 建立任务网络
命令:HParse gram.txt net.slf
HSGen -s net.slf dict.txt
第六步:识别
1. 建立文件hmmlist.txt(在yn文件夹下)文件,内容为:
yes
no
sil
注意每一列最后留一个空格。
2. 创建待识别信号并抽取mfcc参数(文件为test.mfcc)保存在mfcc文件夹下。
3. 命令:HVite -H train/hmm_yes.hmm -H train/hmm_no.hmm -H train/hmm_sil -i reco.mlf -w net.slf dict.txt hmmlist.txt mfcc/test.mfcc
识别结果自动存放在文件reco.mlf。