From 1fba22ee4cba8f1bd36b0d23eae4cab0c422c0c8 Mon Sep 17 00:00:00 2001 From: nl <3210346136@qq.com> Date: Sun, 21 Nov 2021 20:20:26 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E4=BF=AE=E5=A4=8D=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E9=A3=8E=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- evaluate_speech_model.py | 15 ++++++++------- train_speech_model.py | 15 ++++++++------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/evaluate_speech_model.py b/evaluate_speech_model.py index 5d07ebc..2093ef4 100644 --- a/evaluate_speech_model.py +++ b/evaluate_speech_model.py @@ -32,18 +32,19 @@ from speech_features import Spectrogram os.environ["CUDA_VISIBLE_DEVICES"] = "0" -audio_length = 1600 -audio_feature_length = 200 -channels = 1 +AUDIO_LENGTH = 1600 +AUDIO_FEATURE_LENGTH = 200 +CHANNELS = 1 # 默认输出的拼音的表示大小是1428,即1427个拼音+1个空白块 -output_size = 1428 +OUTPUT_SIZE = 1428 sm251 = SpeechModel251( - input_shape=(audio_length, audio_feature_length, channels), - output_size=output_size + input_shape=(AUDIO_LENGTH, AUDIO_FEATURE_LENGTH, CHANNELS), + output_size=OUTPUT_SIZE ) feat = Spectrogram() evalue_data = DataLoader('dev') ms = ModelSpeech(sm251, feat, max_label_length=64) ms.load_model('save_models/' + sm251.get_model_name() + '.h5') -ms.evaluate_model(data_loader=evalue_data, data_count=-1, out_report=True, show_ratio=True, show_per_step=100) +ms.evaluate_model(data_loader=evalue_data, data_count=-1, + out_report=True, show_ratio=True, show_per_step=100) diff --git a/train_speech_model.py b/train_speech_model.py index 8efd99e..0ac541b 100644 --- a/train_speech_model.py +++ b/train_speech_model.py @@ -34,14 +34,14 @@ from speech_features import Spectrogram os.environ["CUDA_VISIBLE_DEVICES"] = "0" -audio_length = 1600 -audio_feature_length = 200 -channels = 1 +AUDIO_LENGTH = 1600 +AUDIO_FEATURE_LENGTH = 200 +CHANNELS = 1 # 默认输出的拼音的表示大小是1428,即1427个拼音+1个空白块 -output_size = 1428 +OUTPUT_SIZE = 1428 sm251 = SpeechModel251( - input_shape=(audio_length, audio_feature_length, channels), - output_size=output_size + input_shape=(AUDIO_LENGTH, AUDIO_FEATURE_LENGTH, CHANNELS), + output_size=OUTPUT_SIZE ) feat = Spectrogram() train_data = DataLoader('train') @@ -49,5 +49,6 @@ opt = Adam(lr = 0.0001, beta_1 = 0.9, beta_2 = 0.999, decay = 0.0, epsilon = 10e ms = ModelSpeech(sm251, feat, max_label_length=64) #ms.load_model('save_models/' + sm251.get_model_name() + '.h5') -ms.train_model(optimizer=opt, data_loader=train_data, epochs=1, save_step=1, batch_size=16, last_epoch=0) +ms.train_model(optimizer=opt, data_loader=train_data, + epochs=1, save_step=1, batch_size=16, last_epoch=0) ms.save_model('save_models/' + sm251.get_model_name())