Spaces:
Sleeping
Sleeping
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
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 |
-
#
|
|
|
|
| 19 |
tts = TTS(model_name=MODEL_NAME)
|
| 20 |
-
print("β
Model loaded successfully!")
|
| 21 |
-
except
|
| 22 |
-
|
| 23 |
-
print(f"β οΈ
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
try:
|
| 26 |
-
|
| 27 |
tts = TTS(model_name=MODEL_NAME, model_type="tts_models/multilingual/multi-dataset/xtts_v2")
|
| 28 |
-
print("β
Model loaded successfully with
|
| 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"
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 = {
|