monophone training is completed.
This commit is contained in:
parent
41d4fa5ff9
commit
fa81b70b27
Binary file not shown.
@ -26,9 +26,8 @@ make_mlf = 0
|
|||||||
extract_features = 0
|
extract_features = 0
|
||||||
flat_start = 0
|
flat_start = 0
|
||||||
train_model_without_sp = 0
|
train_model_without_sp = 0
|
||||||
add_sp = 1
|
add_sp = 0
|
||||||
train_model_with_sp = 0
|
train_model_with_re_aligned_mlf = 1
|
||||||
train_model_with_sp_align_mlf = 0
|
|
||||||
train_triphone = 0
|
train_triphone = 0
|
||||||
|
|
||||||
|
|
||||||
@ -36,7 +35,7 @@ train_triphone = 0
|
|||||||
# pre-defined values.
|
# pre-defined values.
|
||||||
dataset_list = ['devel', 'test', 'train']
|
dataset_list = ['devel', 'test', 'train']
|
||||||
feature_size = 39
|
feature_size = 39
|
||||||
improvement_threshold = 0.5
|
improvement_threshold = 0.3
|
||||||
|
|
||||||
hmmdefs_name = 'hmmdefs'
|
hmmdefs_name = 'hmmdefs'
|
||||||
proto_name = 'proto'
|
proto_name = 'proto'
|
||||||
@ -53,6 +52,7 @@ model_dir = os.path.join(default.htk_dir, 'model')
|
|||||||
model0_dir = os.path.join(model_dir, 'hmm0')
|
model0_dir = os.path.join(model_dir, 'hmm0')
|
||||||
model1_dir = os.path.join(model_dir, 'hmm1')
|
model1_dir = os.path.join(model_dir, 'hmm1')
|
||||||
model1sp_dir = os.path.join(model_dir, 'hmm1sp')
|
model1sp_dir = os.path.join(model_dir, 'hmm1sp')
|
||||||
|
model1sp2_dir = os.path.join(model_dir, 'hmm1sp2')
|
||||||
|
|
||||||
# directories / files to be made.
|
# directories / files to be made.
|
||||||
lexicon_dir = os.path.join(default.htk_dir, 'lexicon')
|
lexicon_dir = os.path.join(default.htk_dir, 'lexicon')
|
||||||
@ -68,7 +68,6 @@ label_dir = os.path.join(default.htk_dir, 'label')
|
|||||||
fh.make_new_directory(label_dir, existing_dir='leave')
|
fh.make_new_directory(label_dir, existing_dir='leave')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## training
|
## training
|
||||||
hcompv_scp_train = os.path.join(tmp_dir, 'train.scp')
|
hcompv_scp_train = os.path.join(tmp_dir, 'train.scp')
|
||||||
mlf_file_train = os.path.join(label_dir, 'train_phone.mlf')
|
mlf_file_train = os.path.join(label_dir, 'train_phone.mlf')
|
||||||
@ -78,10 +77,6 @@ mlf_file_train_aligned = os.path.join(label_dir, 'train_phone_aligned.mlf')
|
|||||||
htk_stimmen_dir = os.path.join(default.htk_dir, 'stimmen')
|
htk_stimmen_dir = os.path.join(default.htk_dir, 'stimmen')
|
||||||
|
|
||||||
|
|
||||||
## train without sp
|
|
||||||
niter_max = 10
|
|
||||||
|
|
||||||
|
|
||||||
## ======================= make lexicon for HTK =======================
|
## ======================= make lexicon for HTK =======================
|
||||||
if make_lexicon:
|
if make_lexicon:
|
||||||
timer_start = time.time()
|
timer_start = time.time()
|
||||||
@ -273,64 +268,64 @@ if add_sp:
|
|||||||
print('==== adding sp to the model ====')
|
print('==== adding sp to the model ====')
|
||||||
# reference:
|
# reference:
|
||||||
# http://www.f.waseda.jp/yusukekondo/htk.html#flat_start_estimation
|
# http://www.f.waseda.jp/yusukekondo/htk.html#flat_start_estimation
|
||||||
|
timer_start = time.time()
|
||||||
|
|
||||||
# make model with sp.
|
# make model with sp.
|
||||||
niter = 7
|
|
||||||
print('>>> adding sp state to the last model in the previous step...')
|
print('>>> adding sp state to the last model in the previous step...')
|
||||||
fh.make_new_directory(model1sp_dir, existing_dir='leave')
|
fh.make_new_directory(model1sp_dir, existing_dir='leave')
|
||||||
|
niter = chtk.get_niter_max(model1_dir)
|
||||||
modeln_dir_pre = os.path.join(model1_dir, 'iter'+str(niter))
|
modeln_dir_pre = os.path.join(model1_dir, 'iter'+str(niter))
|
||||||
|
|
||||||
## update hmmdefs and macros.
|
|
||||||
print('>>> adding sp to the model...')
|
|
||||||
modeln_dir = os.path.join(model1sp_dir, 'iter0')
|
modeln_dir = os.path.join(model1sp_dir, 'iter0')
|
||||||
chtk.add_sp(modeln_dir_pre, modeln_dir)
|
chtk.add_sp(modeln_dir_pre, modeln_dir)
|
||||||
|
print("elapsed time: {}".format(time.time() - timer_start))
|
||||||
|
|
||||||
|
niter = chtk.re_estimation_until_saturated(
|
||||||
## ======================= train model with short pause =======================
|
model1sp_dir, modeln_dir, improvement_threshold, hcompv_scp_train,
|
||||||
if train_model_with_sp:
|
os.path.join(htk_stimmen_dir, 'mfc'),
|
||||||
print('==== train model with sp ====')
|
'mfc',
|
||||||
for niter in range(20, 50):
|
os.path.join(htk_stimmen_dir, 'word_lattice.ltc'),
|
||||||
timer_start = time.time()
|
|
||||||
hmm_n = 'iter' + str(niter)
|
|
||||||
hmm_n_pre = 'iter' + str(niter-1)
|
|
||||||
modeln_dir = os.path.join(model1_dir, hmm_n)
|
|
||||||
modeln_dir_pre = os.path.join(model1_dir, hmm_n_pre)
|
|
||||||
|
|
||||||
# re-estimation
|
|
||||||
fh.make_new_directory(modeln_dir)
|
|
||||||
pyhtk.re_estimation(
|
|
||||||
config_train,
|
|
||||||
os.path.join(modeln_dir_pre, hmmdefs_name),
|
|
||||||
modeln_dir,
|
|
||||||
hcompv_scp_train, phonelist_txt,
|
|
||||||
mlf_file=mlf_file_train,
|
mlf_file=mlf_file_train,
|
||||||
macros=os.path.join(modeln_dir_pre, 'macros'))
|
lexicon_file=os.path.join(htk_stimmen_dir, 'lexicon_recognition.dic'),
|
||||||
print("elapsed time: {}".format(time.time() - timer_start))
|
model_type='monophone_with_sp'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
## ======================= train model with short pause =======================
|
## ======================= train model with re-aligned mlf =======================
|
||||||
if train_model_with_sp_align_mlf:
|
if train_model_with_re_aligned_mlf:
|
||||||
print('==== train model with sp with align.mlf ====')
|
print('==== traina model with re-aligned mlf ====')
|
||||||
for niter in range(50, 60):
|
|
||||||
|
print('>>> re-aligning the training data... ')
|
||||||
timer_start = time.time()
|
timer_start = time.time()
|
||||||
hmm_n = 'iter' + str(niter)
|
niter = chtk.get_niter_max(model1sp_dir)
|
||||||
hmm_n_pre = 'iter' + str(niter-1)
|
modeln_dir = os.path.join(model1sp_dir, 'iter'+str(niter))
|
||||||
modeln_dir = os.path.join(model1_dir, hmm_n)
|
chtk.make_aligned_label(
|
||||||
modeln_dir_pre = os.path.join(model1_dir, hmm_n_pre)
|
os.path.join(modeln_dir, 'macros'),
|
||||||
|
os.path.join(modeln_dir, 'hmmdefs'),
|
||||||
|
mlf_file_train_aligned,
|
||||||
|
os.path.join(label_dir, 'train_word.mlf'),
|
||||||
|
hcompv_scp_train)
|
||||||
|
print("elapsed time: {}".format(time.time() - timer_start))
|
||||||
|
|
||||||
# re-estimation
|
print('>>> re-estimation... ')
|
||||||
fh.make_new_directory(modeln_dir)
|
timer_start = time.time()
|
||||||
pyhtk.re_estimation(
|
fh.make_new_directory(model1sp2_dir, existing_dir='leave')
|
||||||
config_train,
|
niter = chtk.get_niter_max(model1sp_dir)
|
||||||
os.path.join(modeln_dir_pre, hmmdefs_name),
|
niter = chtk.re_estimation_until_saturated(
|
||||||
modeln_dir,
|
model1sp2_dir,
|
||||||
hcompv_scp_train, phonelist_txt,
|
os.path.join(model1sp_dir, 'iter'+str(niter)),
|
||||||
mlf_file=mlf_file_train_aligned,
|
improvement_threshold,
|
||||||
macros=os.path.join(modeln_dir_pre, 'macros'))
|
hcompv_scp_train,
|
||||||
|
os.path.join(htk_stimmen_dir, 'mfc'),
|
||||||
|
'mfc',
|
||||||
|
os.path.join(htk_stimmen_dir, 'word_lattice.ltc'),
|
||||||
|
mlf_file=mlf_file_train,
|
||||||
|
lexicon_file=os.path.join(htk_stimmen_dir, 'lexicon_recognition.dic'),
|
||||||
|
model_type='monophone_with_sp'
|
||||||
|
)
|
||||||
print("elapsed time: {}".format(time.time() - timer_start))
|
print("elapsed time: {}".format(time.time() - timer_start))
|
||||||
|
|
||||||
|
|
||||||
# train triphone.
|
## ======================= train triphone =======================
|
||||||
if train_triphone:
|
if train_triphone:
|
||||||
triphone_mlf = os.path.join(default.htk_dir, 'label', 'train_triphone.mlf')
|
triphone_mlf = os.path.join(default.htk_dir, 'label', 'train_triphone.mlf')
|
||||||
macros = os.path.join(model_dir, 'hmm1_tri', 'iter0', 'macros')
|
macros = os.path.join(model_dir, 'hmm1_tri', 'iter0', 'macros')
|
||||||
|
Loading…
Reference in New Issue
Block a user