mirror of https://github.com/coqui-ai/TTS.git
fix #374
This commit is contained in:
parent
9ce29d8094
commit
eabd7e6a52
|
@ -46,7 +46,7 @@ jobs:
|
||||||
python3 setup.py egg_info
|
python3 setup.py egg_info
|
||||||
- name: Lint check
|
- name: Lint check
|
||||||
run: |
|
run: |
|
||||||
cardboardlinter -n auto
|
cardboardlinter --refspec main -n auto
|
||||||
- name: Unit tests
|
- name: Unit tests
|
||||||
run: nosetests tests --nocapture --processes=0 --process-timeout=20 --process-restartworker
|
run: nosetests tests --nocapture --processes=0 --process-timeout=20 --process-restartworker
|
||||||
- name: Test scripts
|
- name: Test scripts
|
||||||
|
|
|
@ -85,7 +85,7 @@ def format_data(data):
|
||||||
text_input = data[0]
|
text_input = data[0]
|
||||||
text_lengths = data[1]
|
text_lengths = data[1]
|
||||||
speaker_names = data[2]
|
speaker_names = data[2]
|
||||||
linear_input = data[3] if c.model in ["Tacotron"] else None
|
linear_input = data[3] if c.model.lower() in ["tacotron"] else None
|
||||||
mel_input = data[4]
|
mel_input = data[4]
|
||||||
mel_lengths = data[5]
|
mel_lengths = data[5]
|
||||||
stop_targets = data[6]
|
stop_targets = data[6]
|
||||||
|
|
|
@ -297,6 +297,11 @@ class TacotronLoss(torch.nn.Module):
|
||||||
stopnet_output, stopnet_target, output_lens, decoder_b_output,
|
stopnet_output, stopnet_target, output_lens, decoder_b_output,
|
||||||
alignments, alignment_lens, alignments_backwards, input_lens):
|
alignments, alignment_lens, alignments_backwards, input_lens):
|
||||||
|
|
||||||
|
|
||||||
|
# decoder outputs linear or mel spectrograms for Tacotron and Tacotron2
|
||||||
|
# the target should be set acccordingly
|
||||||
|
postnet_target = linear_input if self.config.model.lower() in ["tacotron"] else mel_input
|
||||||
|
|
||||||
return_dict = {}
|
return_dict = {}
|
||||||
# remove lengths if no masking is applied
|
# remove lengths if no masking is applied
|
||||||
if not self.config.loss_masking:
|
if not self.config.loss_masking:
|
||||||
|
@ -307,20 +312,13 @@ class TacotronLoss(torch.nn.Module):
|
||||||
decoder_loss = self.criterion(decoder_output, mel_input,
|
decoder_loss = self.criterion(decoder_output, mel_input,
|
||||||
output_lens)
|
output_lens)
|
||||||
if self.postnet_alpha > 0:
|
if self.postnet_alpha > 0:
|
||||||
if self.config.model in ["Tacotron", "TacotronGST"]:
|
postnet_loss = self.criterion(postnet_output, postnet_target,
|
||||||
postnet_loss = self.criterion(postnet_output, linear_input,
|
output_lens)
|
||||||
output_lens)
|
|
||||||
else:
|
|
||||||
postnet_loss = self.criterion(postnet_output, mel_input,
|
|
||||||
output_lens)
|
|
||||||
else:
|
else:
|
||||||
if self.decoder_alpha > 0:
|
if self.decoder_alpha > 0:
|
||||||
decoder_loss = self.criterion(decoder_output, mel_input)
|
decoder_loss = self.criterion(decoder_output, mel_input)
|
||||||
if self.postnet_alpha > 0:
|
if self.postnet_alpha > 0:
|
||||||
if self.config.model in ["Tacotron", "TacotronGST"]:
|
postnet_loss = self.criterion(postnet_output, postnet_target)
|
||||||
postnet_loss = self.criterion(postnet_output, linear_input)
|
|
||||||
else:
|
|
||||||
postnet_loss = self.criterion(postnet_output, mel_input)
|
|
||||||
loss = self.decoder_alpha * decoder_loss + self.postnet_alpha * postnet_loss
|
loss = self.decoder_alpha * decoder_loss + self.postnet_alpha * postnet_loss
|
||||||
return_dict['decoder_loss'] = decoder_loss
|
return_dict['decoder_loss'] = decoder_loss
|
||||||
return_dict['postnet_loss'] = postnet_loss
|
return_dict['postnet_loss'] = postnet_loss
|
||||||
|
@ -373,7 +371,7 @@ class TacotronLoss(torch.nn.Module):
|
||||||
|
|
||||||
# postnet differential spectral loss
|
# postnet differential spectral loss
|
||||||
if self.config.postnet_diff_spec_alpha > 0:
|
if self.config.postnet_diff_spec_alpha > 0:
|
||||||
postnet_diff_spec_loss = self.criterion_diff_spec(postnet_output, mel_input, output_lens)
|
postnet_diff_spec_loss = self.criterion_diff_spec(postnet_output, postnet_target, output_lens)
|
||||||
loss += postnet_diff_spec_loss * self.postnet_diff_spec_alpha
|
loss += postnet_diff_spec_loss * self.postnet_diff_spec_alpha
|
||||||
return_dict['postnet_diff_spec_loss'] = postnet_diff_spec_loss
|
return_dict['postnet_diff_spec_loss'] = postnet_diff_spec_loss
|
||||||
|
|
||||||
|
@ -385,7 +383,7 @@ class TacotronLoss(torch.nn.Module):
|
||||||
|
|
||||||
# postnet ssim loss
|
# postnet ssim loss
|
||||||
if self.config.postnet_ssim_alpha > 0:
|
if self.config.postnet_ssim_alpha > 0:
|
||||||
postnet_ssim_loss = self.criterion_ssim(postnet_output, mel_input, output_lens)
|
postnet_ssim_loss = self.criterion_ssim(postnet_output, postnet_target, output_lens)
|
||||||
loss += postnet_ssim_loss * self.postnet_ssim_alpha
|
loss += postnet_ssim_loss * self.postnet_ssim_alpha
|
||||||
return_dict['postnet_ssim_loss'] = postnet_ssim_loss
|
return_dict['postnet_ssim_loss'] = postnet_ssim_loss
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ set -xe
|
||||||
BASEDIR=$(dirname "$0")
|
BASEDIR=$(dirname "$0")
|
||||||
echo "$BASEDIR"
|
echo "$BASEDIR"
|
||||||
# run training
|
# run training
|
||||||
CUDA_VISIBLE_DEVICES="" python TTS/bin/train_tacotron.py --config_path $BASEDIR/inputs/test_train_config.json
|
CUDA_VISIBLE_DEVICES="" python TTS/bin/train_tacotron.py --config_path $BASEDIR/inputs/test_tacotron_config.json
|
||||||
# find the training folder
|
# find the training folder
|
||||||
LATEST_FOLDER=$(ls $BASEDIR/train_outputs/| sort | tail -1)
|
LATEST_FOLDER=$(ls $BASEDIR/train_outputs/| sort | tail -1)
|
||||||
echo $LATEST_FOLDER
|
echo $LATEST_FOLDER
|
||||||
|
@ -11,3 +11,15 @@ echo $LATEST_FOLDER
|
||||||
CUDA_VISIBLE_DEVICES="" python TTS/bin/train_tacotron.py --continue_path $BASEDIR/train_outputs/$LATEST_FOLDER
|
CUDA_VISIBLE_DEVICES="" python TTS/bin/train_tacotron.py --continue_path $BASEDIR/train_outputs/$LATEST_FOLDER
|
||||||
# remove all the outputs
|
# remove all the outputs
|
||||||
rm -rf $BASEDIR/train_outputs/
|
rm -rf $BASEDIR/train_outputs/
|
||||||
|
|
||||||
|
# Tacotron2
|
||||||
|
# run training
|
||||||
|
CUDA_VISIBLE_DEVICES="" python TTS/bin/train_tacotron.py --config_path $BASEDIR/inputs/test_tacotron2_config.json
|
||||||
|
# find the training folder
|
||||||
|
LATEST_FOLDER=$(ls $BASEDIR/train_outputs/| sort | tail -1)
|
||||||
|
echo $LATEST_FOLDER
|
||||||
|
# continue the previous training
|
||||||
|
CUDA_VISIBLE_DEVICES="" python TTS/bin/train_tacotron.py --continue_path $BASEDIR/train_outputs/$LATEST_FOLDER
|
||||||
|
# remove all the outputs
|
||||||
|
rm -rf $BASEDIR/train_outputs/
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue