Skip to content

SOTA Open Source TTS

Fix %2

Lengyuec232a45011a3
diff --git a/fish_speech/models/vqgan/modules/models.py b/fish_speech/models/vqgan/modules/models.py
index ac67bc2..0b5f433 100644
--- a/fish_speech/models/vqgan/modules/models.py
+++ b/fish_speech/models/vqgan/modules/models.py
@@ -106,6 +106,15 @@ class SynthesizerTrn(nn.Module):
def forward(self, x, x_lengths, specs):
x = x.mT
+
+ min_length = min(x.shape[2], specs.shape[2])
+ if min_length % 2 != 0:
+ min_length -= 1
+
+ x = x[:, :, :min_length]
+ specs = specs[:, :, :min_length]
+ x_lengths = torch.clamp(x_lengths, max=min_length)
+
spec_masks = torch.unsqueeze(sequence_mask(x_lengths, specs.shape[2]), 1).to(
specs.dtype
)