Spaces:
Running
on
Zero
Running
on
Zero
Enhance voice loading process in TTSModel with error handling and initialization checks
Browse files- tts_model.py +11 -3
tts_model.py
CHANGED
@@ -55,9 +55,13 @@ class TTSModel:
|
|
55 |
# Download voice files
|
56 |
download_voice_files(self.model_repo, "voices", self.voices_dir)
|
57 |
|
58 |
-
#
|
59 |
available_voices = self.list_voices()
|
60 |
-
|
|
|
|
|
|
|
|
|
61 |
print("Model initialization complete")
|
62 |
return True
|
63 |
|
@@ -208,7 +212,11 @@ class TTSModel:
|
|
208 |
else:
|
209 |
voice_name = voice_names[0]
|
210 |
voice_path = os.path.join(self.voices_dir, "voices", f"{voice_name}.pt")
|
211 |
-
|
|
|
|
|
|
|
|
|
212 |
|
213 |
# Count tokens and normalize text
|
214 |
total_tokens = count_tokens(text)
|
|
|
55 |
# Download voice files
|
56 |
download_voice_files(self.model_repo, "voices", self.voices_dir)
|
57 |
|
58 |
+
# Verify voices were downloaded successfully
|
59 |
available_voices = self.list_voices()
|
60 |
+
if not available_voices:
|
61 |
+
print("Warning: No voices found after initialization")
|
62 |
+
else:
|
63 |
+
print(f"Found {len(available_voices)} voices")
|
64 |
+
|
65 |
print("Model initialization complete")
|
66 |
return True
|
67 |
|
|
|
212 |
else:
|
213 |
voice_name = voice_names[0]
|
214 |
voice_path = os.path.join(self.voices_dir, "voices", f"{voice_name}.pt")
|
215 |
+
try:
|
216 |
+
voicepack = torch.load(voice_path, weights_only=True)
|
217 |
+
except Exception as e:
|
218 |
+
print(f"Warning: weights_only load failed, attempting full load: {str(e)}")
|
219 |
+
voicepack = torch.load(voice_path, weights_only=False)
|
220 |
|
221 |
# Count tokens and normalize text
|
222 |
total_tokens = count_tokens(text)
|