Spaces:
Runtime error
Runtime error
csukuangfj
commited on
Commit
•
3344c9b
1
Parent(s):
f364871
add German
Browse files
model.py
CHANGED
@@ -111,6 +111,45 @@ def _get_vits_ljs(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
|
|
111 |
|
112 |
return tts
|
113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
@lru_cache(maxsize=10)
|
115 |
def _get_vits_piper_en_US_lessac_medium(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
|
116 |
assert repo_id == "csukuangfj/vits-piper-en_US-lessac-medium"
|
@@ -197,6 +236,8 @@ def get_pretrained_model(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
|
|
197 |
return chinese_models[repo_id](repo_id, speed)
|
198 |
elif repo_id in english_models:
|
199 |
return english_models[repo_id](repo_id, speed)
|
|
|
|
|
200 |
else:
|
201 |
raise ValueError(f"Unsupported repo_id: {repo_id}")
|
202 |
|
@@ -211,8 +252,13 @@ english_models = {
|
|
211 |
"csukuangfj/vits-ljs": _get_vits_ljs,
|
212 |
}
|
213 |
|
|
|
|
|
|
|
|
|
214 |
|
215 |
language_to_models = {
|
216 |
"Chinese": list(chinese_models.keys()),
|
217 |
"English": list(english_models.keys()),
|
|
|
218 |
}
|
|
|
111 |
|
112 |
return tts
|
113 |
|
114 |
+
@lru_cache(maxsize=10)
|
115 |
+
def _get_vits_piper_de_DE_thorsten_medium(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
|
116 |
+
assert repo_id == "csukuangfj/vits-piper-de_DE-thorsten-medium"
|
117 |
+
|
118 |
+
model = get_file(
|
119 |
+
repo_id=repo_id,
|
120 |
+
filename="de_DE-thorsten-medium.onnx",
|
121 |
+
subfolder=".",
|
122 |
+
)
|
123 |
+
|
124 |
+
lexicon = get_file(
|
125 |
+
repo_id=repo_id,
|
126 |
+
filename="lexicon.txt",
|
127 |
+
subfolder=".",
|
128 |
+
)
|
129 |
+
|
130 |
+
tokens = get_file(
|
131 |
+
repo_id=repo_id,
|
132 |
+
filename="tokens.txt",
|
133 |
+
subfolder=".",
|
134 |
+
)
|
135 |
+
|
136 |
+
tts_config = sherpa_onnx.OfflineTtsConfig(
|
137 |
+
model=sherpa_onnx.OfflineTtsModelConfig(
|
138 |
+
vits=sherpa_onnx.OfflineTtsVitsModelConfig(
|
139 |
+
model=model,
|
140 |
+
lexicon=lexicon,
|
141 |
+
tokens=tokens,
|
142 |
+
length_scale=1.0 / speed,
|
143 |
+
),
|
144 |
+
provider="cpu",
|
145 |
+
debug=True,
|
146 |
+
num_threads=2,
|
147 |
+
)
|
148 |
+
)
|
149 |
+
tts = sherpa_onnx.OfflineTts(tts_config)
|
150 |
+
|
151 |
+
return tts
|
152 |
+
|
153 |
@lru_cache(maxsize=10)
|
154 |
def _get_vits_piper_en_US_lessac_medium(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
|
155 |
assert repo_id == "csukuangfj/vits-piper-en_US-lessac-medium"
|
|
|
236 |
return chinese_models[repo_id](repo_id, speed)
|
237 |
elif repo_id in english_models:
|
238 |
return english_models[repo_id](repo_id, speed)
|
239 |
+
elif repo_id in german_models:
|
240 |
+
return german_models[repo_id](repo_id, speed)
|
241 |
else:
|
242 |
raise ValueError(f"Unsupported repo_id: {repo_id}")
|
243 |
|
|
|
252 |
"csukuangfj/vits-ljs": _get_vits_ljs,
|
253 |
}
|
254 |
|
255 |
+
german_models = {
|
256 |
+
"csukuangfj/vits-piper-de_DE-thorsten-medium": _get_vits_piper_de_DE_thorsten_medium,
|
257 |
+
}
|
258 |
+
|
259 |
|
260 |
language_to_models = {
|
261 |
"Chinese": list(chinese_models.keys()),
|
262 |
"English": list(english_models.keys()),
|
263 |
+
"German": list(german_models.keys()),
|
264 |
}
|