csukuangfj commited on
Commit
ef8e4f3
1 Parent(s): ca87d1e

add heteronym fsts

Browse files
Files changed (2) hide show
  1. model.py +40 -5
  2. requirements.txt +2 -2
model.py CHANGED
@@ -188,9 +188,21 @@ def _get_vits_zh_aishell3(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
188
  subfolder=".",
189
  )
190
 
191
- rule_fst = get_file(
 
 
 
 
 
 
 
 
 
 
 
 
192
  repo_id=repo_id,
193
- filename="rule.fst",
194
  subfolder=".",
195
  )
196
 
@@ -206,7 +218,8 @@ def _get_vits_zh_aishell3(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
206
  debug=True,
207
  num_threads=2,
208
  ),
209
- rule_fsts=rule_fst,
 
210
  )
211
  tts = sherpa_onnx.OfflineTts(tts_config)
212
 
@@ -238,12 +251,33 @@ def _get_vits_hf(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
238
  subfolder=".",
239
  )
240
 
241
- rule_fst = get_file(
242
  repo_id=repo_id,
243
  filename="rule.fst",
244
  subfolder=".",
245
  )
246
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
  tts_config = sherpa_onnx.OfflineTtsConfig(
248
  model=sherpa_onnx.OfflineTtsModelConfig(
249
  vits=sherpa_onnx.OfflineTtsVitsModelConfig(
@@ -256,7 +290,8 @@ def _get_vits_hf(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
256
  debug=True,
257
  num_threads=2,
258
  ),
259
- rule_fsts=rule_fst,
 
260
  )
261
  tts = sherpa_onnx.OfflineTts(tts_config)
262
 
 
188
  subfolder=".",
189
  )
190
 
191
+ rule_fsts = ["phone.fst", "date.fst", "number.fst", "new_heteronym.fst"]
192
+
193
+ rule_fsts = [
194
+ get_file(
195
+ repo_id=repo_id,
196
+ filename=f,
197
+ subfolder=".",
198
+ )
199
+ for f in rule_fsts
200
+ ]
201
+ rule_fsts = ",".join(rule_fsts)
202
+
203
+ rule_fars = get_file(
204
  repo_id=repo_id,
205
+ filename="rule.far",
206
  subfolder=".",
207
  )
208
 
 
218
  debug=True,
219
  num_threads=2,
220
  ),
221
+ rule_fsts=rule_fsts,
222
+ rule_fars=rule_fars,
223
  )
224
  tts = sherpa_onnx.OfflineTts(tts_config)
225
 
 
251
  subfolder=".",
252
  )
253
 
254
+ rule_fsts = get_file(
255
  repo_id=repo_id,
256
  filename="rule.fst",
257
  subfolder=".",
258
  )
259
 
260
+ rule_fars = ""
261
+
262
+ if "vits-cantonese-hf-xiaomaiiwn" not in repo_id:
263
+ rule_fsts = ["phone.fst", "date.fst", "number.fst", "new_heteronym.fst"]
264
+
265
+ rule_fsts = [
266
+ get_file(
267
+ repo_id=repo_id,
268
+ filename=f,
269
+ subfolder=".",
270
+ )
271
+ for f in rule_fsts
272
+ ]
273
+ rule_fsts = ",".join(rule_fsts)
274
+
275
+ rule_fars = get_file(
276
+ repo_id=repo_id,
277
+ filename="rule.far",
278
+ subfolder=".",
279
+ )
280
+
281
  tts_config = sherpa_onnx.OfflineTtsConfig(
282
  model=sherpa_onnx.OfflineTtsModelConfig(
283
  vits=sherpa_onnx.OfflineTtsVitsModelConfig(
 
290
  debug=True,
291
  num_threads=2,
292
  ),
293
+ rule_fsts=rule_fsts,
294
+ rule_fars=rule_fars,
295
  )
296
  tts = sherpa_onnx.OfflineTts(tts_config)
297
 
requirements.txt CHANGED
@@ -1,4 +1,4 @@
1
- #https://huggingface.co/csukuangfj/wheels/resolve/main/sherpa_onnx-1.8.11-cp38-cp38-linux_x86_64.whl
2
- sherpa-onnx
3
 
4
  soundfile
 
1
+ https://huggingface.co/csukuangfj/wheels/resolve/main/sherpa_onnx-1.9.16-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
2
+ #sherpa-onnx
3
 
4
  soundfile