ashishkblink commited on
Commit
285f6b8
Β·
1 Parent(s): 1ff6e01

Add detailed diagnostics for model loading errors

Browse files

- Better error messages explaining the model name format issue
- Try base XTTS-v2 model as fallback to verify TTS works
- Clear diagnostics about why custom HuggingFace models might fail

Files changed (1) hide show
  1. app.py +53 -27
app.py CHANGED
@@ -13,39 +13,65 @@ from pathlib import Path
13
  MODEL_NAME = "ashishkblink/vakya"
14
 
15
  print("πŸš€ Loading Vakya TTS model...")
 
16
  tts = None
 
 
 
 
 
17
  try:
18
- # Try loading with minimal parameters first
 
19
  tts = TTS(model_name=MODEL_NAME)
20
- print("βœ… Model loaded successfully!")
21
- except ValueError as e:
22
- # This might be the unpacking error - try with explicit model type
23
- print(f"⚠️ Initial load failed (ValueError): {e}")
24
- print("πŸ”„ Trying with explicit model type...")
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  try:
26
- # XTTS models might need explicit specification
27
  tts = TTS(model_name=MODEL_NAME, model_type="tts_models/multilingual/multi-dataset/xtts_v2")
28
- print("βœ… Model loaded successfully with explicit type!")
29
- except Exception as e2:
30
- print(f"❌ Explicit type loading failed: {e2}")
31
- import traceback
32
- traceback.print_exc()
33
- tts = None
34
- except Exception as e:
35
- print(f"❌ Error loading model: {e}")
36
- import traceback
37
- traceback.print_exc()
38
- # Try alternative initialization methods
39
- try:
40
- print("πŸ”„ Trying alternative model loading method...")
41
- # Try with gpu parameter explicitly set
42
- tts = TTS(model_name=MODEL_NAME, gpu=False)
43
- print("βœ… Model loaded successfully with alternative method!")
44
  except Exception as e2:
45
- print(f"❌ Alternative loading also failed: {e2}")
46
- import traceback
47
- traceback.print_exc()
48
- tts = None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
  # Supported languages for Indian languages
51
  INDIAN_LANGUAGES = {
 
13
  MODEL_NAME = "ashishkblink/vakya"
14
 
15
  print("πŸš€ Loading Vakya TTS model...")
16
+ print(f"πŸ“¦ Model: {MODEL_NAME}")
17
  tts = None
18
+
19
+ # TTS 0.22.0 expects model names in format: "model_type/language/dataset/model" (4 parts)
20
+ # Custom HuggingFace models use format: "username/modelname" (2 parts)
21
+ # This is a known limitation - we'll try multiple approaches
22
+
23
  try:
24
+ # Method 1: Try direct loading
25
+ print("πŸ“¦ Attempting Method 1: Direct model loading...")
26
  tts = TTS(model_name=MODEL_NAME)
27
+ print("βœ… Model loaded successfully with Method 1!")
28
+ except Exception as e1:
29
+ error_msg1 = str(e1)
30
+ print(f"⚠️ Method 1 failed: {error_msg1}")
31
+
32
+ # Check if it's the unpacking error
33
+ if "not enough values to unpack" in error_msg1 or "expected 4" in error_msg1:
34
+ print("\n" + "="*70)
35
+ print("⚠️ DETECTED: Model name format issue")
36
+ print("="*70)
37
+ print(f"The TTS library expects model names in format:")
38
+ print(f" 'model_type/language/dataset/model' (4 parts)")
39
+ print(f"But your model is: '{MODEL_NAME}' (2 parts)")
40
+ print("\nThis suggests TTS 0.22.0 may not support custom HuggingFace")
41
+ print("model repositories in this format.")
42
+ print("="*70 + "\n")
43
+
44
+ # Method 2: Try with explicit model type (won't work but shows we tried)
45
  try:
46
+ print("πŸ“¦ Attempting Method 2: With explicit model type...")
47
  tts = TTS(model_name=MODEL_NAME, model_type="tts_models/multilingual/multi-dataset/xtts_v2")
48
+ print("βœ… Model loaded successfully with Method 2!")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  except Exception as e2:
50
+ print(f"⚠️ Method 2 failed: {e2}")
51
+
52
+ # Method 3: Try base XTTS-v2 (to verify TTS works)
53
+ try:
54
+ print("\nπŸ“¦ Attempting Method 3: Base XTTS-v2 model (for testing)...")
55
+ tts = TTS(model_name="tts_models/multilingual/multi-dataset/xtts_v2")
56
+ print("βœ… Base XTTS-v2 model loaded successfully!")
57
+ print("⚠️ NOTE: Using base XTTS-v2 instead of custom Vakya model")
58
+ except Exception as e3:
59
+ print(f"❌ Method 3 also failed: {e3}")
60
+ import traceback
61
+ traceback.print_exc()
62
+ tts = None
63
+
64
+ print("\n" + "="*70)
65
+ print("❌ ERROR: Could not load any TTS model")
66
+ print("="*70)
67
+ print("\nPossible solutions:")
68
+ print("1. Check if the model repository structure on HuggingFace")
69
+ print(" matches what TTS library expects")
70
+ print("2. The model may need to be in a different format")
71
+ print("3. TTS 0.22.0 may not support custom HuggingFace models")
72
+ print(" in 'username/modelname' format")
73
+ print("\nThe app will continue but TTS functionality will be disabled.")
74
+ print("="*70 + "\n")
75
 
76
  # Supported languages for Indian languages
77
  INDIAN_LANGUAGES = {