csukuangfj commited on
Commit
684c796
1 Parent(s): bea2895

add a min nan model from mms

Browse files
Files changed (2) hide show
  1. app.py +20 -0
  2. model.py +14 -2
app.py CHANGED
@@ -60,6 +60,10 @@ css = """
60
  .result_item_error {background-color:#ff7070;color:white;align-self:start}
61
  """
62
 
 
 
 
 
63
 
64
  def update_model_dropdown(language: str):
65
  if language in language_to_models:
@@ -176,6 +180,22 @@ with demo:
176
 
177
  output_info = gr.HTML(label="Info")
178
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  input_button.click(
180
  process,
181
  inputs=[
 
60
  .result_item_error {background-color:#ff7070;color:white;align-self:start}
61
  """
62
 
63
+ examples = [
64
+ ["Min-nan (闽南话)", "csukuangfj/vits-mms-nan", "ài piaǸ chiah ē iaN̂", 0, 1.0],
65
+ ]
66
+
67
 
68
  def update_model_dropdown(language: str):
69
  if language in language_to_models:
 
180
 
181
  output_info = gr.HTML(label="Info")
182
 
183
+ gr.Examples(
184
+ examples=examples,
185
+ fn=process,
186
+ inputs=[
187
+ language_radio,
188
+ model_dropdown,
189
+ input_text,
190
+ input_sid,
191
+ input_speed,
192
+ ],
193
+ outputs=[
194
+ output_audio,
195
+ output_info,
196
+ ],
197
+ )
198
+
199
  input_button.click(
200
  process,
201
  inputs=[
model.py CHANGED
@@ -116,13 +116,13 @@ def _get_vits_ljs(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
116
  @lru_cache(maxsize=10)
117
  def _get_vits_piper(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
118
  data_dir = "/tmp/espeak-ng-data"
119
- if "coqui" in repo_id:
120
  name = "model"
121
  else:
122
  n = len("vits-piper-")
123
  name = repo_id.split("/")[1][n:]
124
 
125
- if "vits-coqui-uk-mai" in repo_id:
126
  data_dir = ""
127
 
128
  model = get_file(
@@ -156,6 +156,11 @@ def _get_vits_piper(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
156
  return tts
157
 
158
 
 
 
 
 
 
159
  @lru_cache(maxsize=10)
160
  def _get_vits_zh_aishell3(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
161
  assert repo_id == "csukuangfj/vits-zh-aishell3"
@@ -337,6 +342,8 @@ def get_pretrained_model(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
337
  return slovenian_models[repo_id](repo_id, speed)
338
  elif repo_id in bangla_models:
339
  return bangla_models[repo_id](repo_id, speed)
 
 
340
  else:
341
  raise ValueError(f"Unsupported repo_id: {repo_id}")
342
 
@@ -621,11 +628,16 @@ bangla_models = {
621
  "csukuangfj/vits-coqui-bn-custom_female": _get_vits_piper,
622
  }
623
 
 
 
 
 
624
 
625
  language_to_models = {
626
  "English": list(english_models.keys()),
627
  "Chinese (Mandarin, 普通话)": list(chinese_models.keys()),
628
  "Cantonese (粤语)": list(cantonese_models.keys()),
 
629
  "Arabic": list(arabic_models.keys()),
630
  "Bangla": list(bangla_models.keys()),
631
  "Bulgarian": list(bulgarian_models.keys()),
 
116
  @lru_cache(maxsize=10)
117
  def _get_vits_piper(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
118
  data_dir = "/tmp/espeak-ng-data"
119
+ if "coqui" in repo_id or "vits-mms" in repo_id:
120
  name = "model"
121
  else:
122
  n = len("vits-piper-")
123
  name = repo_id.split("/")[1][n:]
124
 
125
+ if "vits-coqui-uk-mai" in repo_id or "vits-mms" in repo_id:
126
  data_dir = ""
127
 
128
  model = get_file(
 
156
  return tts
157
 
158
 
159
+ @lru_cache(maxsize=10)
160
+ def _get_vits_mms(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
161
+ return _get_vits_piper(repo_id, speed)
162
+
163
+
164
  @lru_cache(maxsize=10)
165
  def _get_vits_zh_aishell3(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
166
  assert repo_id == "csukuangfj/vits-zh-aishell3"
 
342
  return slovenian_models[repo_id](repo_id, speed)
343
  elif repo_id in bangla_models:
344
  return bangla_models[repo_id](repo_id, speed)
345
+ elif repo_id in min_nan_models:
346
+ return min_nan_models[repo_id](repo_id, speed)
347
  else:
348
  raise ValueError(f"Unsupported repo_id: {repo_id}")
349
 
 
628
  "csukuangfj/vits-coqui-bn-custom_female": _get_vits_piper,
629
  }
630
 
631
+ min_nan_models = {
632
+ "csukuangfj/vits-mms-nan": _get_vits_mms,
633
+ }
634
+
635
 
636
  language_to_models = {
637
  "English": list(english_models.keys()),
638
  "Chinese (Mandarin, 普通话)": list(chinese_models.keys()),
639
  "Cantonese (粤语)": list(cantonese_models.keys()),
640
+ "Min-nan (闽南话)": list(min_nan_models.keys()),
641
  "Arabic": list(arabic_models.keys()),
642
  "Bangla": list(bangla_models.keys()),
643
  "Bulgarian": list(bulgarian_models.keys()),