Update app.py
Browse files
app.py
CHANGED
|
@@ -224,7 +224,7 @@ def save_wav(audio, file_path):
|
|
| 224 |
return False
|
| 225 |
|
| 226 |
def load_tts_model():
|
| 227 |
-
"""Load TTS model
|
| 228 |
global tts, model_loaded, current_model, voice_cloning_supported, model_loading, model_load_attempts
|
| 229 |
|
| 230 |
if model_loading:
|
|
@@ -245,32 +245,30 @@ def load_tts_model():
|
|
| 245 |
sys.stdin = StringIO('y\n')
|
| 246 |
|
| 247 |
try:
|
| 248 |
-
print("π Loading
|
| 249 |
|
| 250 |
-
#
|
| 251 |
-
tts = TTS("tts_models/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
|
| 253 |
model_loaded = True
|
| 254 |
-
current_model = "
|
| 255 |
-
voice_cloning_supported =
|
| 256 |
-
print("β
|
| 257 |
return True
|
| 258 |
|
| 259 |
except Exception as e:
|
| 260 |
-
print(f"β
|
| 261 |
-
|
| 262 |
-
# Try fallback model
|
| 263 |
-
try:
|
| 264 |
-
print("π Trying fallback model...")
|
| 265 |
-
tts = TTS("tts_models/en/ljspeech/tacotron2-DDC").to(DEVICE)
|
| 266 |
-
model_loaded = True
|
| 267 |
-
current_model = "tacotron2-DDC"
|
| 268 |
-
voice_cloning_supported = False
|
| 269 |
-
print("β
Fallback model loaded successfully")
|
| 270 |
-
return True
|
| 271 |
-
except Exception as fallback_error:
|
| 272 |
-
print(f"β Fallback model also failed: {fallback_error}")
|
| 273 |
-
return False
|
| 274 |
|
| 275 |
finally:
|
| 276 |
sys.stdin = old_stdin
|
|
|
|
| 224 |
return False
|
| 225 |
|
| 226 |
def load_tts_model():
|
| 227 |
+
"""Load TTS model - Force Tacotron2 for reliability"""
|
| 228 |
global tts, model_loaded, current_model, voice_cloning_supported, model_loading, model_load_attempts
|
| 229 |
|
| 230 |
if model_loading:
|
|
|
|
| 245 |
sys.stdin = StringIO('y\n')
|
| 246 |
|
| 247 |
try:
|
| 248 |
+
print("π Loading Tacotron2 model (most reliable)...")
|
| 249 |
|
| 250 |
+
# Force Tacotron2 - it's the most reliable model
|
| 251 |
+
tts = TTS("tts_models/en/ljspeech/tacotron2-DDC").to(DEVICE)
|
| 252 |
+
|
| 253 |
+
# Test the model
|
| 254 |
+
test_path = "/tmp/test_output.wav"
|
| 255 |
+
tts.tts_to_file(text="Test", file_path=test_path)
|
| 256 |
+
|
| 257 |
+
if os.path.exists(test_path):
|
| 258 |
+
os.remove(test_path)
|
| 259 |
+
print("β
Tacotron2 model tested and working!")
|
| 260 |
+
else:
|
| 261 |
+
raise Exception("Test failed - no file created")
|
| 262 |
|
| 263 |
model_loaded = True
|
| 264 |
+
current_model = "tts_models/en/ljspeech/tacotron2-DDC"
|
| 265 |
+
voice_cloning_supported = False # Tacotron2 doesn't support voice cloning
|
| 266 |
+
print("β
Tacotron2 model loaded successfully!")
|
| 267 |
return True
|
| 268 |
|
| 269 |
except Exception as e:
|
| 270 |
+
print(f"β Tacotron2 model failed: {e}")
|
| 271 |
+
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 272 |
|
| 273 |
finally:
|
| 274 |
sys.stdin = old_stdin
|