TGPro1 commited on
Commit
d48ea61
·
verified ·
1 Parent(s): 4258912

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +18 -6
app.py CHANGED
@@ -59,8 +59,8 @@ if not hasattr(torchaudio, "info"):
59
 
60
  from df.enhance import enhance, init_df, load_audio, save_audio
61
 
62
- # FORCE BUILD TRIGGER: 07:18:00 Jan 21 2026
63
- # v77: High-Speed GPU Pipeline (STT + TTS on GPU)
64
 
65
  # 🛠️ Monkeypatch torchaudio.load
66
  try:
@@ -147,10 +147,22 @@ def _tts_logic(text, lang, speaker_wav_b64):
147
  if not text or not text.strip():
148
  return {"error": "TTS Error: Input text is empty"}
149
 
150
- if lang:
151
- lang = lang.strip().lower()
152
- if '-' in lang: lang = lang.split('-')[0]
153
-
 
 
 
 
 
 
 
 
 
 
 
 
154
  speaker_wav_path = None
155
  if speaker_wav_b64:
156
  sb = base64.b64decode(speaker_wav_b64)
 
59
 
60
  from df.enhance import enhance, init_df, load_audio, save_audio
61
 
62
+ # FORCE BUILD TRIGGER: 08:21:00 Jan 21 2026
63
+ # v78: Fixed XTTS Language Mappings (Chinese zh-cn fix)
64
 
65
  # 🛠️ Monkeypatch torchaudio.load
66
  try:
 
147
  if not text or not text.strip():
148
  return {"error": "TTS Error: Input text is empty"}
149
 
150
+ # 🌍 XTTS-v2 EXPLICIT LANGUAGE MAPPING
151
+ # XTTS is very picky. 'zh' won't work, it must be 'zh-cn'.
152
+ XTTS_MAP = {
153
+ "en": "en", "en-us": "en", "en-gb": "en",
154
+ "de": "de", "fr": "fr", "es": "es", "it": "it",
155
+ "pl": "pl", "pt": "pt", "tr": "tr", "ru": "ru",
156
+ "nl": "nl", "cs": "cs", "ar": "ar", "hu": "hu",
157
+ "ko": "ko", "hi": "hi",
158
+ "zh": "zh-cn", "zh-cn": "zh-cn", "zh-tw": "zh-cn" # XTTS only supports Simplified (zh-cn)
159
+ }
160
+
161
+ if lang:
162
+ lang_key = lang.strip().lower()
163
+ # Try exact match first, then base match (e.g. 'en-US' -> 'en')
164
+ lang = XTTS_MAP.get(lang_key) or XTTS_MAP.get(lang_key.split('-')[0]) or lang_key
165
+
166
  speaker_wav_path = None
167
  if speaker_wav_b64:
168
  sb = base64.b64decode(speaker_wav_b64)