From 1b68d3cb4e3cc9ccc59f936739ccf4a0056afe0c Mon Sep 17 00:00:00 2001 From: Eren Golge Date: Fri, 15 Mar 2019 14:01:43 +0100 Subject: [PATCH] control synthesis lenght as an additional stop condition --- layers/tacotron2.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/layers/tacotron2.py b/layers/tacotron2.py index 7798dea9..9f582432 100644 --- a/layers/tacotron2.py +++ b/layers/tacotron2.py @@ -388,7 +388,7 @@ class Decoder(nn.Module): self.attention_layer.init_win_idx() outputs, stop_tokens, alignments, t = [], [], [], 0 - stop_flags = [False, False] + stop_flags = [False, False, False] while True: memory = self.prenet(memory) mel_output, stop_token, alignment = self.decode(memory) @@ -398,7 +398,8 @@ class Decoder(nn.Module): alignments += [alignment] stop_flags[0] = stop_flags[0] or stop_token > 0.5 - stop_flags[1] = stop_flags[1] or alignment[0, -2:].sum() > 0.5 + stop_flags[1] = stop_flags[1] or (alignment[0, -2:].sum() > 0.5 and t > inputs.shape[1]) + stop_flags[2] = t > inputs.shape[1] if all(stop_flags): break elif len(outputs) == self.max_decoder_steps: