Spaces:
Running
Running
csukuangfj
commited on
Commit
•
d5f48a5
1
Parent(s):
23e7dca
small fixes
Browse files
model.py
CHANGED
@@ -201,6 +201,54 @@ def _get_vits_zh_aishell3(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
|
|
201 |
return tts
|
202 |
|
203 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
@lru_cache(maxsize=10)
|
205 |
def get_pretrained_model(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
|
206 |
if repo_id in chinese_models:
|
@@ -219,6 +267,7 @@ def get_pretrained_model(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
|
|
219 |
|
220 |
chinese_models = {
|
221 |
"csukuangfj/vits-zh-aishell3": _get_vits_zh_aishell3,
|
|
|
222 |
# "csukuangfj/vits-piper-zh_CN-huayan-x_low": _get_vits_piper,
|
223 |
# "csukuangfj/vits-piper-zh_CN-huayan-medium": _get_vits_piper,
|
224 |
}
|
@@ -272,15 +321,15 @@ spanish_models = {
|
|
272 |
"csukuangfj/vits-piper-es_ES-davefx-medium": _get_vits_piper,
|
273 |
"csukuangfj/vits-piper-es_ES-mls_10246-low": _get_vits_piper,
|
274 |
"csukuangfj/vits-piper-es_ES-mls_9972-low": _get_vits_piper,
|
275 |
-
"csukuangfj/vits-piper-es_ES-sharvard-medium": _get_vits_piper,
|
276 |
"csukuangfj/vits-piper-es_MX-ald-medium": _get_vits_piper,
|
277 |
}
|
278 |
|
279 |
french_models = {
|
280 |
# "csukuangfj/vits-piper-fr_FR-gilles-low": _get_vits_piper,
|
281 |
# "csukuangfj/vits-piper-fr_FR-mls_1840-low": _get_vits_piper,
|
282 |
-
"csukuangfj/vits-piper-fr_FR-upmc-medium": _get_vits_piper,
|
283 |
-
"csukuangfj/vits-piper-fr_FR-siwis-low": _get_vits_piper,
|
284 |
"csukuangfj/vits-piper-fr_FR-siwis-medium": _get_vits_piper,
|
285 |
}
|
286 |
|
|
|
201 |
return tts
|
202 |
|
203 |
|
204 |
+
@lru_cache(maxsize=10)
|
205 |
+
def _get_vits_hf_fanchen(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
|
206 |
+
assert "csukuangfj/vits-zh-hf-fanchen" in repo_id, repo_id
|
207 |
+
model = repo_id.split("/")[-1]
|
208 |
+
|
209 |
+
model = get_file(
|
210 |
+
repo_id=repo_id,
|
211 |
+
filename=f"{model}.onnx",
|
212 |
+
subfolder=".",
|
213 |
+
)
|
214 |
+
|
215 |
+
lexicon = get_file(
|
216 |
+
repo_id=repo_id,
|
217 |
+
filename="lexicon.txt",
|
218 |
+
subfolder=".",
|
219 |
+
)
|
220 |
+
|
221 |
+
tokens = get_file(
|
222 |
+
repo_id=repo_id,
|
223 |
+
filename="tokens.txt",
|
224 |
+
subfolder=".",
|
225 |
+
)
|
226 |
+
|
227 |
+
rule_fst = get_file(
|
228 |
+
repo_id=repo_id,
|
229 |
+
filename="rule.fst",
|
230 |
+
subfolder=".",
|
231 |
+
)
|
232 |
+
|
233 |
+
tts_config = sherpa_onnx.OfflineTtsConfig(
|
234 |
+
model=sherpa_onnx.OfflineTtsModelConfig(
|
235 |
+
vits=sherpa_onnx.OfflineTtsVitsModelConfig(
|
236 |
+
model=model,
|
237 |
+
lexicon=lexicon,
|
238 |
+
tokens=tokens,
|
239 |
+
length_scale=1.0 / speed,
|
240 |
+
),
|
241 |
+
provider="cpu",
|
242 |
+
debug=True,
|
243 |
+
num_threads=2,
|
244 |
+
),
|
245 |
+
rule_fsts=rule_fst,
|
246 |
+
)
|
247 |
+
tts = sherpa_onnx.OfflineTts(tts_config)
|
248 |
+
|
249 |
+
return tts
|
250 |
+
|
251 |
+
|
252 |
@lru_cache(maxsize=10)
|
253 |
def get_pretrained_model(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
|
254 |
if repo_id in chinese_models:
|
|
|
267 |
|
268 |
chinese_models = {
|
269 |
"csukuangfj/vits-zh-aishell3": _get_vits_zh_aishell3,
|
270 |
+
"csukuangfj/vits-zh-hf-fanchen-wnj": _get_vits_hf_fanchen,
|
271 |
# "csukuangfj/vits-piper-zh_CN-huayan-x_low": _get_vits_piper,
|
272 |
# "csukuangfj/vits-piper-zh_CN-huayan-medium": _get_vits_piper,
|
273 |
}
|
|
|
321 |
"csukuangfj/vits-piper-es_ES-davefx-medium": _get_vits_piper,
|
322 |
"csukuangfj/vits-piper-es_ES-mls_10246-low": _get_vits_piper,
|
323 |
"csukuangfj/vits-piper-es_ES-mls_9972-low": _get_vits_piper,
|
324 |
+
"csukuangfj/vits-piper-es_ES-sharvard-medium": _get_vits_piper, # 2 speakers
|
325 |
"csukuangfj/vits-piper-es_MX-ald-medium": _get_vits_piper,
|
326 |
}
|
327 |
|
328 |
french_models = {
|
329 |
# "csukuangfj/vits-piper-fr_FR-gilles-low": _get_vits_piper,
|
330 |
# "csukuangfj/vits-piper-fr_FR-mls_1840-low": _get_vits_piper,
|
331 |
+
"csukuangfj/vits-piper-fr_FR-upmc-medium": _get_vits_piper, # 2 speakers, 0-femal, 1-male
|
332 |
+
"csukuangfj/vits-piper-fr_FR-siwis-low": _get_vits_piper, # female
|
333 |
"csukuangfj/vits-piper-fr_FR-siwis-medium": _get_vits_piper,
|
334 |
}
|
335 |
|