gorkemgoknar commited on
Commit
386d2a7
1 Parent(s): 42c9a4a

add japanese support

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -53,6 +53,12 @@ model_path = os.path.join(
53
  )
54
  config = XttsConfig()
55
  config.load_json(os.path.join(model_path, "config.json"))
 
 
 
 
 
 
56
  model = Xtts.init_from_config(config)
57
  model.load_checkpoint(
58
  config,
@@ -178,7 +184,7 @@ def wave_header_chunk(frame_input=b"", channels=1, sample_width=2, sample_rate=2
178
  wav_buf.seek(0)
179
  return wav_buf.read()
180
 
181
- xtts_supported_languages=["en","es","fr","de","it","pt","pl","tr","ru","nl","cs","ar","zh-cn"]
182
  def detect_language(prompt):
183
  # Fast language autodetection
184
  if len(prompt)>15:
@@ -186,6 +192,10 @@ def detect_language(prompt):
186
  if language_predicted == "zh":
187
  #we use zh-cn on xtts
188
  language_predicted = "zh-cn"
 
 
 
 
189
  if language_predicted not in xtts_supported_languages:
190
  print(f"Detected a language not supported by xtts :{language_predicted}, switching to english for now")
191
  gr.Warning(f"Language detected '{language_predicted}' can not be spoken properly 'yet' ")
 
53
  )
54
  config = XttsConfig()
55
  config.load_json(os.path.join(model_path, "config.json"))
56
+
57
+ if "ja-jp" not in config.languages:
58
+ #fix to have JP before next TTS update
59
+ config.languages.append("ja-jp")
60
+
61
+
62
  model = Xtts.init_from_config(config)
63
  model.load_checkpoint(
64
  config,
 
184
  wav_buf.seek(0)
185
  return wav_buf.read()
186
 
187
+ xtts_supported_languages=["en","es","fr","de","it","pt","pl","tr","ru","nl","cs","ar","zh-cn","ja-jp"]
188
  def detect_language(prompt):
189
  # Fast language autodetection
190
  if len(prompt)>15:
 
192
  if language_predicted == "zh":
193
  #we use zh-cn on xtts
194
  language_predicted = "zh-cn"
195
+ if language_predicted == "ja":
196
+ #we use zh-cn
197
+ language_predicted = "ja-jp"
198
+
199
  if language_predicted not in xtts_supported_languages:
200
  print(f"Detected a language not supported by xtts :{language_predicted}, switching to english for now")
201
  gr.Warning(f"Language detected '{language_predicted}' can not be spoken properly 'yet' ")