yukee1992 commited on
Commit
1c6d9ce
Β·
verified Β·
1 Parent(s): 041c542

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -21
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 with retry logic and proper error handling"""
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 XTTS model...")
249
 
250
- # Try to load XTTS model
251
- tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(DEVICE)
 
 
 
 
 
 
 
 
 
 
252
 
253
  model_loaded = True
254
- current_model = "xtts_v2"
255
- voice_cloning_supported = True
256
- print("βœ… XTTS model loaded successfully")
257
  return True
258
 
259
  except Exception as e:
260
- print(f"❌ XTTS model loading failed: {e}")
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