Spaces:
Sleeping
Sleeping
Add language code fallback: try 'hi' then 'hindi' for XTTS
Browse files
backend/app/multilingual_tts.py
CHANGED
|
@@ -204,12 +204,27 @@ class MultilingualTTSService:
|
|
| 204 |
|
| 205 |
print(f"[MultilingualTTSService] Synthesizing Hindi: {text[:50]}...")
|
| 206 |
|
| 207 |
-
# XTTS
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
|
| 214 |
# Convert to float32 if needed
|
| 215 |
audio = np.asarray(audio, dtype=np.float32)
|
|
|
|
| 204 |
|
| 205 |
print(f"[MultilingualTTSService] Synthesizing Hindi: {text[:50]}...")
|
| 206 |
|
| 207 |
+
# XTTS language support check
|
| 208 |
+
# Try different language code formats
|
| 209 |
+
try:
|
| 210 |
+
audio = self._xtts_model.tts(
|
| 211 |
+
text=text,
|
| 212 |
+
speaker_wav=str(voice_sample_path),
|
| 213 |
+
language="hi" # Try ISO 639-1 code
|
| 214 |
+
)
|
| 215 |
+
except NotImplementedError:
|
| 216 |
+
print("[MultilingualTTSService] Language code 'hi' not supported, trying 'hindi'...")
|
| 217 |
+
try:
|
| 218 |
+
audio = self._xtts_model.tts(
|
| 219 |
+
text=text,
|
| 220 |
+
speaker_wav=str(voice_sample_path),
|
| 221 |
+
language="hindi" # Try full language name
|
| 222 |
+
)
|
| 223 |
+
except NotImplementedError:
|
| 224 |
+
raise RuntimeError(
|
| 225 |
+
"Hindi language not supported in this XTTS version. "
|
| 226 |
+
"XTTS-v2 may only support: en, es, fr, de, it, pt, pl, tr, ru, nl, zh-cn, zh-tw, ar, cs, el, hu, ko, ja"
|
| 227 |
+
)
|
| 228 |
|
| 229 |
# Convert to float32 if needed
|
| 230 |
audio = np.asarray(audio, dtype=np.float32)
|