HTK下yes/no的识别

孤立词识别的简单结构

data/:   data/train data/test

analysis/:

training/:

model/:

def/:

test/:

 

第一步 创建语音文件 录音

命令:HSLab any_name.sig

 

yes/no识别

yes与no都录10次 记为

yes01.sig yes02.sig…

no01.sig no02.sig…

第二步:声学分析

抽取yes和no的mfcc特征参数。保存在data/train/lab与data/train/sig下。

命令:HCopy -A -D -C analysis.conf -S targetlist.txt

 

其中  analysis.conf为抽取参数配置文件,

内容为:

#

# Example of an acoustical analysis configuration file

#

SOURCEFORMAT = HTK              # Gives the format of the speech files

TARGETKIND = MFCC_0_D_A    # Identifier of the coefficients to use       

 

# Unit = 0.1 micro-second :

WINDOWSIZE = 250000.0           # = 25 ms = length of a time fram

TARGETRATE = 100000.0        # = 10 ms = frame perioficity 

 

NUMCEPS = 12           # Number of MFCC coeffs (here from c1 to c2)

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

targetlist.txt说明抽取源文件路径和目标文件的保存路径,

内容如下:

data/train/sig/yes01.sig    data/train/mfcc/yes01.mfcc

data/train/sig/yes02.sig    data/train/mfcc/yes02.mfcc

data/train/sig/yes03.sig    data/train/mfcc/yes03.mfcc

data/train/sig/yes04.sig    data/train/mfcc/yes04.mfcc

data/train/sig/yes05.sig    data/train/mfcc/yes05.mfcc

data/train/sig/yes06.sig    data/train/mfcc/yes06.mfcc

data/train/sig/yes07.sig    data/train/mfcc/yes07.mfcc

data/train/sig/yes08.sig    data/train/mfcc/yes08.mfcc

data/train/sig/yes09.sig    data/train/mfcc/yes09.mfcc

data/train/sig/yes10.sig    data/train/mfcc/yes10.mfcc

data/train/sig/no01.sig     data/train/mfcc/no01.mfcc

data/train/sig/no02.sig     data/train/mfcc/no02.mfcc

data/train/sig/no03.sig     data/train/mfcc/no03.mfcc

data/train/sig/no04.sig     data/train/mfcc/no04.mfcc

data/train/sig/no05.sig     data/train/mfcc/no05.mfcc

data/train/sig/no06.sig     data/train/mfcc/no06.mfcc

data/train/sig/no07.sig     data/train/mfcc/no07.mfcc

data/train/sig/no08.sig     data/train/mfcc/no08.mfcc

data/train/sig/no09.sig     data/train/mfcc/no09.mfcc

data/train/sig/sil10.sig     data/train/mfcc/sil10.mfcc

data/train/sig/sil01.sig     data/train/mfcc/sil01.mfcc

data/train/sig/sil02.sig     data/train/mfcc/sil02.mfcc

data/train/sig/sil03.sig     data/train/mfcc/sil03.mfcc

data/train/sig/sil04.sig     data/train/mfcc/sil04.mfcc

data/train/sig/sil05.sig     data/train/mfcc/sil05.mfcc

data/train/sig/sil06.sig     data/train/mfcc/sil06.mfcc

data/train/sig/sil07.sig     data/train/mfcc/sil07.mfcc

data/train/sig/sil08.sig     data/train/mfcc/sil08.mfcc

data/train/sig/sil09.sig     data/train/mfcc/sil09.mfcc

data/train/sig/sil10.sig     data/train/mfcc/sil10.mfcc

 

第三步:HMM原型定义

建立文件hmm_yes、hmm_no、hmm_sil保存在model/proto下。

hmm_yes内容如下

~o <VecSize> 39 <MFCC_0_D_A>

~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_sil有着相同的内容

第四步:HMM训练

1.初始化:

 命令:

HInit -A -D -T 1 -S trainlist_yes.txt -M model/hmm0 -H model/proto/hmm_yes yes

 

trainlist_yes.txt内容为:

data/train/mfcc/yes01.mfcc

data/train/mfcc/yes02.mfcc

data/train/mfcc/yes03.mfcc

data/train/mfcc/yes04.mfcc

data/train/mfcc/yes05.mfcc

data/train/mfcc/yes06.mfcc

data/train/mfcc/yes07.mfcc

data/train/mfcc/yes08.mfcc

data/train/mfcc/yes09.mfcc

data/train/mfcc/yes10.mfcc

no、sil类似地初始化。

HInit -A -D -T 1 -S trainlist_no.txt -M model/hmm0 -H model/proto/hmm_no no

HInit -A -D -T 1 -S trainlist_sil.txt -M model/hmm0 -H model/proto/hmm_sil sil

 

2.训练

命令: HRest -A -D -T 1 -S trainlist_yes.txt -M model/proto -H model/hmm0/hmm_yes yes

 no、sil类似地训练。

HRest -A -D -T 1 -S trainlist_no.txt -M model/proto -H model/hmm0/hmm_no no

HRest -A -D -T 1 -S trainlist_sil.txt -M model/proto -H model/hmm0/hmm_sil sil

 

第五步:任务定义

1.     建立语法规则和字典

建立语法规则文件gram.txt(在YesNoSystem文件夹下),内容为:

/*

* Task grammar

*/

$WORD = YES | NO;

( { SIL } [ $WORD ] { SIL } )

建立字典文件dict.txt(在YesNoSystem文件夹下),内容为:

YES [yes] yes

NO [no] no

SIL [sil] sil

 

不要忘记在文件的末尾添加新行(如果不添加,那么最后一个入口将被忽略)。

2.     建立任务网络

命令:HParse -A -D -T 1 gram.txt net.slf

      HSGen -A -D -s net.slf dict.txt

 

第六步:识别

1. 建立文件hmmlist.txt(在YesNoSystem文件夹下)文件,内容为:

yes

 

no

 

sil

注意每一列最后留一个空格。每个元素通过新行字符隔开,不要忘记在最后一个元素后面插入新行。

2. 待识别信号并抽取mfcc参数(文件test.mfcc)

      HCopy -A -D -C analysis.conf -S targetlist_test.txt

targetlist_test.txt说明抽取源文件路径和目标文件的保存路径,

内容如下:

data/test/sig/yestest01.sig    data/test/mfcc/yestest01.mfcc

data/test/sig/yestest02.sig    data/test/mfcc/yestest02.mfcc

data/test/sig/yestest03.sig    data/test/mfcc/yestest03.mfcc

data/test/sig/notest01.sig    data/test/mfcc/notest01.mfcc

data/test/sig/notest02.sig    data/test/mfcc/notest02.mfcc

data/test/sig/notest03.sig    data/test/mfcc/notest03.mfcc

data/test/sig/siltest01.sig    data/test/mfcc/siltest01.mfcc

data/test/sig/siltest02.sig    data/test/mfcc/siltest02.mfcc

data/test/sig/siltest03.sig    data/test/mfcc/siltest03.mfcc

 

3.     命令:

Hvite -H model/proto/hmm_yes -H model/proto/hmm_no -H model/proto/hmm_sil -i result/reco_yestest01.mlf -w net.slf dict.txt hmmlist.txt data/test/mfcc/yestest01.mfcc

Hvite -H model/proto/hmm_yes -H model/proto/hmm_no -H model/proto/hmm_sil -i result/reco_yestest02.mlf -w net.slf dict.txt hmmlist.txt data/test/mfcc/yestest02.mfcc

Hvite -H model/proto/hmm_yes -H model/proto/hmm_no -H model/proto/hmm_sil -i result/reco_yestest03.mlf -w net.slf dict.txt hmmlist.txt data/test/mfcc/yestest03.mfcc

Hvite -H model/proto/hmm_yes -H model/proto/hmm_no -H model/proto/hmm_sil -i result/reco_notest01.mlf -w net.slf dict.txt hmmlist.txt data/test/mfcc/notest01.mfcc

Hvite -H model/proto/hmm_yes -H model/proto/hmm_no -H model/proto/hmm_sil -i result/reco_notest02.mlf -w net.slf dict.txt hmmlist.txt data/test/mfcc/notest02.mfcc

Hvite -H model/proto/hmm_yes -H model/proto/hmm_no -H model/proto/hmm_sil -i result/reco_notest03.mlf -w net.slf dict.txt hmmlist.txt data/test/mfcc/notest03.mfcc

Hvite -H model/proto/hmm_yes -H model/proto/hmm_no -H model/proto/hmm_sil -i result/reco_siltest01.mlf -w net.slf dict.txt hmmlist.txt data/test/mfcc/siltest01.mfcc

Hvite -H model/proto/hmm_yes -H model/proto/hmm_no -H model/proto/hmm_sil -i result/reco_siltest02.mlf -w net.slf dict.txt hmmlist.txt data/test/mfcc/siltest02.mfcc

Hvite -H model/proto/hmm_yes -H model/proto/hmm_no -H model/proto/hmm_sil -i result/reco_siltest03.mlf -w net.slf dict.txt hmmlist.txt data/test/mfcc/siltest03.mfcc

识别结果自动存放在文件reco.mlf

#!MLF!#

"yes01.rec"

0 34300000 yes -17771.425781

性能测试

创建主标签文件:

手动创建ref.mlf,记作包含整个测试集的正确副本,即通过手工标注的副本。内容如下

#!MLF!#

"*/yestest01.lab"

1605625 3667500 sil

3667500 9288125 yes

9288125 11770000 sil

.

"*/yestest02.lab"

3958125 6583125 sil

6583125 11748125 yes

11748125 13906875 sil

.

"*/yestest03.lab"

1058125 4381250 sil

4381250 10816250 yes

10816250 13631875 sil

.

"*/notest01.lab"

2096875 3846250 sil

3846250 6489375 no

6489375 8164375 sil

.

"*/notest02.lab"

3767500 7471875 sil

7471875 10964375 no

10964375 12975625 sil

.

"*/notest03.lab"

2023125 4628750 sil

4628750 8384375 no

8384375 10131875 sil

.

"*/siltest01.lab"

0 2452500 sil

2452500 7587500 sil

.

"*/siltest02.lab"

0 1451250 sil

1451250 4706250 sil

.

"*/siltest03.lab"

0 1414375 sil

1414375 6018125 sil

.

然后用Hvite工具得到rec.mlf,记作包含整个测试集的识别副本,即识别器产生的假设副本。其中testlist.txt内容如下

data\test\mfcc\yestest01.mfcc

data\test\mfcc\yestest02.mfcc

data\test\mfcc\yestest03.mfcc

data\test\mfcc\notest01.mfcc

data\test\mfcc\notest02.mfcc

data\test\mfcc\notest03.mfcc

data\test\mfcc\siltest01.mfcc

data\test\mfcc\siltest02.mfcc

data\test\mfcc\siltest03.mfcc

 

Hvite -Stestlist.txt -H model/proto/hmm_yes -H model/proto/hmm_no -H model/proto/hmm_sil -i rec.mlf -w net.slf dict.txt hmmlist.txt

 

错误率

HResults -A -D -T 1 -e ??? sil -I ref.mlf labellist.txt rec.mlf > results.txt

其中labellist.txt内容如下

data\test\lab\yestest01.lab

data\test\lab\yestest02.lab

data\test\lab\yestest03.lab

data\test\lab\notest01.lab

data\test\lab\notest02.lab

data\test\lab\notest03.lab

data\test\lab\siltest01.lab

data\test\lab\siltest02.lab

data\test\lab\siltest03.lab

这里>results.txt表示将输出结果保存在results.txt文件中。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值