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

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +23 -10
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: 08:21:00 Jan 21 2026
63
- # v78: Fixed XTTS Language Mappings (Chinese zh-cn fix)
64
 
65
  # 🛠️ Monkeypatch torchaudio.load
66
  try:
@@ -147,22 +147,35 @@ 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
- # 🌍 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)
 
59
 
60
  from df.enhance import enhance, init_df, load_audio, save_audio
61
 
62
+ # FORCE BUILD TRIGGER: 08:26:00 Jan 21 2026
63
+ # v79: Full 16-Language XTTS Mapping Support
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 COMPLETE 16-LANGUAGE MAPPING (v79)
151
+ # This dictionary ensures every officially supported XTTS language code is correctly matched.
152
  XTTS_MAP = {
153
  "en": "en", "en-us": "en", "en-gb": "en",
154
+ "de": "de", "de-de": "de",
155
+ "fr": "fr", "fr-fr": "fr",
156
+ "es": "es", "es-es": "es",
157
+ "it": "it", "it-it": "it",
158
+ "pl": "pl", "pl-pl": "pl",
159
+ "pt": "pt", "pt-pt": "pt", "pt-br": "pt",
160
+ "tr": "tr", "tr-tr": "tr",
161
+ "ru": "ru", "ru-ru": "ru",
162
+ "nl": "nl", "nl-nl": "nl",
163
+ "cs": "cs", "cs-cz": "cs",
164
+ "ar": "ar", "ar-sa": "ar", "ar-eg": "ar",
165
+ "hu": "hu", "hu-hu": "hu",
166
+ "ko": "ko", "ko-kr": "ko",
167
+ "hi": "hi", "hi-in": "hi",
168
+ "zh": "zh-cn", "zh-cn": "zh-cn", "zh-tw": "zh-cn"
169
  }
170
 
171
  if lang:
172
  lang_key = lang.strip().lower()
173
+ # 1. Try exact match (e.g. 'zh-cn')
174
+ # 2. Try the sub-code split match (e.g. 'en-US' -> 'en')
175
+ # 3. Fallback to the original key if not in map
176
  lang = XTTS_MAP.get(lang_key) or XTTS_MAP.get(lang_key.split('-')[0]) or lang_key
177
 
178
+ print(f"[v79] TTS mapped language: {lang}")
179
  speaker_wav_path = None
180
  if speaker_wav_b64:
181
  sb = base64.b64decode(speaker_wav_b64)