saeedabdulmuizz commited on
Commit
edd0ea2
·
verified ·
1 Parent(s): 20f1917

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -178,7 +178,18 @@ def process(text, speaker_id):
178
  # 2. Text to Sequence
179
  cleaner = "basic_cleaners"
180
  sequence, _ = text_to_sequence(text, [cleaner])
181
- x = torch.tensor(intersperse(sequence, 0), dtype=torch.long, device=DEVICE)[None]
 
 
 
 
 
 
 
 
 
 
 
182
  x_lengths = torch.tensor([x.shape[-1]], dtype=torch.long, device=DEVICE)
183
 
184
  # 3. Use the Speaker ID from the interface
 
178
  # 2. Text to Sequence
179
  cleaner = "basic_cleaners"
180
  sequence, _ = text_to_sequence(text, [cleaner])
181
+
182
+ # Filter out any non-integer values (unknown characters not in vocabulary)
183
+ # This happens when text contains characters not supported by the TTS model
184
+ filtered_sequence = [s for s in sequence if isinstance(s, int)]
185
+
186
+ if not filtered_sequence:
187
+ raise ValueError("No valid characters found in input text for TTS model.")
188
+
189
+ if len(filtered_sequence) != len(sequence):
190
+ print(f"[WARN] Filtered out {len(sequence) - len(filtered_sequence)} unknown characters from TTS input")
191
+
192
+ x = torch.tensor(intersperse(filtered_sequence, 0), dtype=torch.long, device=DEVICE)[None]
193
  x_lengths = torch.tensor([x.shape[-1]], dtype=torch.long, device=DEVICE)
194
 
195
  # 3. Use the Speaker ID from the interface