csukuangfj commited on
Commit
16988a0
1 Parent(s): 0d7f17e

update sherpa-onnx

Browse files
Files changed (2) hide show
  1. model.py +11 -0
  2. requirements.txt +1 -1
model.py CHANGED
@@ -14,7 +14,9 @@
14
  # See the License for the specific language governing permissions and
15
  # limitations under the License.
16
 
 
17
  from functools import lru_cache
 
18
 
19
  import sherpa_onnx
20
  from huggingface_hub import hf_hub_download
@@ -233,6 +235,12 @@ def _get_vits_hf(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
233
  else:
234
  model = repo_id.split("-")[-1]
235
 
 
 
 
 
 
 
236
  model = get_file(
237
  repo_id=repo_id,
238
  filename=f"{model}.onnx",
@@ -271,12 +279,14 @@ def _get_vits_hf(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
271
  filename="rule.far",
272
  subfolder=".",
273
  )
 
274
  else:
275
  rule_fsts = get_file(
276
  repo_id=repo_id,
277
  filename="rule.fst",
278
  subfolder=".",
279
  )
 
280
 
281
  tts_config = sherpa_onnx.OfflineTtsConfig(
282
  model=sherpa_onnx.OfflineTtsModelConfig(
@@ -284,6 +294,7 @@ def _get_vits_hf(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
284
  model=model,
285
  lexicon=lexicon,
286
  tokens=tokens,
 
287
  length_scale=1.0 / speed,
288
  ),
289
  provider="cpu",
 
14
  # See the License for the specific language governing permissions and
15
  # limitations under the License.
16
 
17
+ import os
18
  from functools import lru_cache
19
+ from pathlib import Path
20
 
21
  import sherpa_onnx
22
  from huggingface_hub import hf_hub_download
 
235
  else:
236
  model = repo_id.split("-")[-1]
237
 
238
+ if not Path("/tmp/dict").is_dir():
239
+ os.system(
240
+ "cd /tmp; curl -SL -O https://github.com/csukuangfj/cppjieba/releases/download/sherpa-onnx-2024-04-19/dict.tar.bz2; tar xvf dict.tar.bz2"
241
+ )
242
+ os.system("ls -lh /tmp/dict")
243
+
244
  model = get_file(
245
  repo_id=repo_id,
246
  filename=f"{model}.onnx",
 
279
  filename="rule.far",
280
  subfolder=".",
281
  )
282
+ vits_dict_dir = "/tmp/dict"
283
  else:
284
  rule_fsts = get_file(
285
  repo_id=repo_id,
286
  filename="rule.fst",
287
  subfolder=".",
288
  )
289
+ vits_dict_dir = ""
290
 
291
  tts_config = sherpa_onnx.OfflineTtsConfig(
292
  model=sherpa_onnx.OfflineTtsModelConfig(
 
294
  model=model,
295
  lexicon=lexicon,
296
  tokens=tokens,
297
+ dict_dir=vits_dict_dir,
298
  length_scale=1.0 / speed,
299
  ),
300
  provider="cpu",
requirements.txt CHANGED
@@ -1,4 +1,4 @@
1
- https://huggingface.co/csukuangfj/sherpa-onnx-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
 
1
+ https://huggingface.co/csukuangfj/sherpa-onnx-wheels/resolve/main/sherpa_onnx-1.9.22-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
2
  #sherpa-onnx
3
 
4
  soundfile