Upload eduport_tts_mal.py with huggingface_hub
Browse files- eduport_tts_mal.py +4 -4
eduport_tts_mal.py
CHANGED
@@ -51,10 +51,10 @@ class SpeechDataset(Dataset):
|
|
51 |
input_values = self.processor(waveform, sampling_rate=self.target_sampling_rate, return_tensors="pt").input_values.squeeze(0)
|
52 |
|
53 |
# Pad or truncate the audio to ensure fixed length (the longest audio length)
|
54 |
-
if input_values.size(
|
55 |
-
padding_length = self.max_audio_length - input_values.size(
|
56 |
# Create a zero tensor with the same batch size (1) and the padding length along dimension 1
|
57 |
-
padding = torch.
|
58 |
input_values = torch.cat([input_values, padding], dim=1)
|
59 |
else:
|
60 |
input_values = input_values[:, :self.max_audio_length] # Truncate to max_audio_length
|
@@ -289,4 +289,4 @@ def train_model(num_epochs=10, accumulation_steps=16):
|
|
289 |
}, 'metadata.pth')
|
290 |
|
291 |
# Run the training
|
292 |
-
train_model()
|
|
|
51 |
input_values = self.processor(waveform, sampling_rate=self.target_sampling_rate, return_tensors="pt").input_values.squeeze(0)
|
52 |
|
53 |
# Pad or truncate the audio to ensure fixed length (the longest audio length)
|
54 |
+
if input_values.size(1) < self.max_audio_length:
|
55 |
+
padding_length = self.max_audio_length - input_values.size(1)
|
56 |
# Create a zero tensor with the same batch size (1) and the padding length along dimension 1
|
57 |
+
padding = torch.zeros_like(input_values[:, :padding_length])
|
58 |
input_values = torch.cat([input_values, padding], dim=1)
|
59 |
else:
|
60 |
input_values = input_values[:, :self.max_audio_length] # Truncate to max_audio_length
|
|
|
289 |
}, 'metadata.pth')
|
290 |
|
291 |
# Run the training
|
292 |
+
train_model()
|