Spaces:
Running
Running
Commit
·
a4b042c
1
Parent(s):
ba2d69a
add kokoro 1.0
Browse files- model.py +43 -1
- requirements.txt +2 -2
model.py
CHANGED
@@ -123,7 +123,10 @@ def _get_vits_ljs(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
|
|
123 |
def _get_kokoro(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
|
124 |
data_dir = "/tmp/espeak-ng-data"
|
125 |
repo_id = repo_id.split("|")[0]
|
126 |
-
assert repo_id in (
|
|
|
|
|
|
|
127 |
|
128 |
model = get_file(
|
129 |
repo_id=repo_id,
|
@@ -142,6 +145,41 @@ def _get_kokoro(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
|
|
142 |
filename="voices.bin",
|
143 |
subfolder=".",
|
144 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
|
146 |
tts_config = sherpa_onnx.OfflineTtsConfig(
|
147 |
model=sherpa_onnx.OfflineTtsModelConfig(
|
@@ -151,12 +189,15 @@ def _get_kokoro(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
|
|
151 |
tokens=tokens,
|
152 |
data_dir=data_dir,
|
153 |
length_scale=1.0 / speed,
|
|
|
|
|
154 |
),
|
155 |
provider="cpu",
|
156 |
debug=True,
|
157 |
num_threads=2,
|
158 |
),
|
159 |
max_num_sentences=1,
|
|
|
160 |
)
|
161 |
|
162 |
tts = sherpa_onnx.OfflineTts(tts_config)
|
@@ -593,6 +634,7 @@ chinese_models = {
|
|
593 |
}
|
594 |
|
595 |
english_models = {
|
|
|
596 |
"csukuangfj/kokoro-en-v0_19|11 speakers": _get_kokoro,
|
597 |
"csukuangfj/vits-piper-en_US-glados|1 speaker": _get_vits_piper,
|
598 |
"csukuangfj/vits-piper-en_GB-southern_english_male-medium|8 speakers": _get_vits_piper,
|
|
|
123 |
def _get_kokoro(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
|
124 |
data_dir = "/tmp/espeak-ng-data"
|
125 |
repo_id = repo_id.split("|")[0]
|
126 |
+
assert repo_id in (
|
127 |
+
"csukuangfj/kokoro-en-v0_19",
|
128 |
+
"csukuangfj/kokoro-multi-lang-v1_0",
|
129 |
+
), repo_id
|
130 |
|
131 |
model = get_file(
|
132 |
repo_id=repo_id,
|
|
|
145 |
filename="voices.bin",
|
146 |
subfolder=".",
|
147 |
)
|
148 |
+
if repo_id == "csukuangfj/kokoro-multi-lang-v1_0":
|
149 |
+
lexicon_en = get_file(
|
150 |
+
repo_id=repo_id,
|
151 |
+
filename="lexicon-us-en.txt",
|
152 |
+
subfolder=".",
|
153 |
+
)
|
154 |
+
lexicon_zh = get_file(
|
155 |
+
repo_id=repo_id,
|
156 |
+
filename="lexicon-zh.txt",
|
157 |
+
subfolder=".",
|
158 |
+
)
|
159 |
+
lexicon = f"{lexicon_en},{lexicon_zh}"
|
160 |
+
|
161 |
+
date_zh = get_file(
|
162 |
+
repo_id=repo_id,
|
163 |
+
filename="date-zh.fst",
|
164 |
+
subfolder=".",
|
165 |
+
)
|
166 |
+
|
167 |
+
number_zh = get_file(
|
168 |
+
repo_id=repo_id,
|
169 |
+
filename="number-zh.fst",
|
170 |
+
subfolder=".",
|
171 |
+
)
|
172 |
+
phone_zh = get_file(
|
173 |
+
repo_id=repo_id,
|
174 |
+
filename="phone-zh.fst",
|
175 |
+
subfolder=".",
|
176 |
+
)
|
177 |
+
rule_fsts = f"{date_zh},{phone_zh},{number_zh}"
|
178 |
+
dict_dir = "/tmp/dict"
|
179 |
+
else:
|
180 |
+
lexicon = ""
|
181 |
+
rule_fsts = ""
|
182 |
+
dict_dir = ""
|
183 |
|
184 |
tts_config = sherpa_onnx.OfflineTtsConfig(
|
185 |
model=sherpa_onnx.OfflineTtsModelConfig(
|
|
|
189 |
tokens=tokens,
|
190 |
data_dir=data_dir,
|
191 |
length_scale=1.0 / speed,
|
192 |
+
lexicon=lexicon,
|
193 |
+
dict_dir=dict_dir,
|
194 |
),
|
195 |
provider="cpu",
|
196 |
debug=True,
|
197 |
num_threads=2,
|
198 |
),
|
199 |
max_num_sentences=1,
|
200 |
+
rule_fsts=rule_fsts,
|
201 |
)
|
202 |
|
203 |
tts = sherpa_onnx.OfflineTts(tts_config)
|
|
|
634 |
}
|
635 |
|
636 |
english_models = {
|
637 |
+
"csukuangfj/kokoro-multi-lang-v1_0|53 speakers": _get_kokoro,
|
638 |
"csukuangfj/kokoro-en-v0_19|11 speakers": _get_kokoro,
|
639 |
"csukuangfj/vits-piper-en_US-glados|1 speaker": _get_vits_piper,
|
640 |
"csukuangfj/vits-piper-en_GB-southern_english_male-medium|8 speakers": _get_vits_piper,
|
requirements.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/1.10.
|
2 |
-
#sherpa-onnx>=1.10.
|
3 |
|
4 |
soundfile
|
|
|
1 |
+
https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/1.10.42/sherpa_onnx-1.10.42-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
|
2 |
+
#sherpa-onnx>=1.10.42
|
3 |
|
4 |
soundfile
|