语音识别之HTK入门(三)训练文件准备

為{幸葍}努か 提交于 2020-02-04 02:37:18


本节记录的是进行训练前的各种文件的准备,步骤稍微有些繁杂。

config文件夹下的操作

config文件夹下运行终端命令如下:

touch grammer
touch global.ded
touch mkphones_color.led
touch codetrain.scp
touch config_HCopy
touch proto
touch train.scp
touch config_color

grammer文件内容:

$color = RED | BLUE | YELLOW;
(SENT-START ($color) SENT-END)

global.ded文件内容:

AS sp
RS cmu 
MP sil sil sp

mkphones_color.led文件内容

EX
IS sil sil
DE sp

codetrain.scp文件内容

data/train/speech/s01.wav    data/train/mfc/s01.mfc
data/train/speech/s02.wav    data/train/mfc/s02.mfc
data/train/speech/s03.wav    data/train/mfc/s03.mfc
data/train/speech/s04.wav    data/train/mfc/s04.mfc
data/train/speech/s05.wav    data/train/mfc/s05.mfc
data/train/speech/s06.wav    data/train/mfc/s06.mfc
data/train/speech/s07.wav    data/train/mfc/s07.mfc
data/train/speech/s08.wav    data/train/mfc/s08.mfc
data/train/speech/s09.wav    data/train/mfc/s09.mfc
data/train/speech/s10.wav    data/train/mfc/s10.mfc

config_HCopy文件内容

# 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

proto文件内容

 ~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>

train.scp文件内容

data/train/mfc/s01.mfc
data/train/mfc/s02.mfc
data/train/mfc/s03.mfc
data/train/mfc/s04.mfc
data/train/mfc/s05.mfc
data/train/mfc/s06.mfc
data/train/mfc/s07.mfc
data/train/mfc/s08.mfc
data/train/mfc/s09.mfc
data/train/mfc/s10.mfc

config_color文件内容

# 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

lists文件夹下的操作

lists文件夹下运行终端命令如下:

touch wordlist

wordlist文件内容

BLUE
RED
SENT-END
SENT-START
YELLOW

dict文件夹操作

将字典文件的“beep”和“otherDict"置于dict下

labels文件夹操作

labels文件夹下运行终端命令如下:

touch trainprompts

trainprompts文件内容:

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 

scripts文件夹操作

脚本文件包括以下文件:
在这里插入图片描述

主目录树下的操作

注意注意,进行以下操作时需要将下载好的htk工具箱里的部分文件复制进主目录下,具体如图:
在这里插入图片描述

依次运行以下命令:

HParse ./config/grammer ./config/wordnet

config目录会生成wordnet;

HDMan -m -w ./lists/wordlist -n ./lists/monophones -g ./config/global.ded ./dict/dict_color ./dict/beep ./dict/otherDict

ists目录会生成monophones;
dict目录里会生成dict_color;

perl ./scripts/prompts2mlf ./labels/trainwords.mlf ./labels/trainprompts

labels目录会生成trainwords.mlf;

HLEd -l '*' -d ./dict/dict_color -i ./labels/phones_color.mlf ./config/mkphones_color.led ./labels/trainwords.mlf 

labels目录会生成phones_color.mlf;

HCopy -T 1 -C ./config/config_HCopy -S ./config/codetrain.scp

data/train/mfc目录会生成s01.mfc;s02.mfc……s10.mfc;

好的,到此已经对训练文件准备完成,下一节写训练模型。

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!