Skip to content

Open-source speech recognition toolkit for training, inference, streaming ASR, VAD, punctuation, speaker diarization pipelines, and OpenAI-compatible/MCP serving.

funasr-onnx 0.2.2

游雁14c6299c24e7
diff --git a/funasr/runtime/python/onnxruntime/funasr_onnx/paraformer_bin.py b/funasr/runtime/python/onnxruntime/funasr_onnx/paraformer_bin.py
index c9940363e..884def935 100644
--- a/funasr/runtime/python/onnxruntime/funasr_onnx/paraformer_bin.py
+++ b/funasr/runtime/python/onnxruntime/funasr_onnx/paraformer_bin.py
@@ -38,7 +38,13 @@ class Paraformer():
):
if not Path(model_dir).exists():
- from modelscope.hub.snapshot_download import snapshot_download
+ try:
+ from modelscope.hub.snapshot_download import snapshot_download
+ except:
+ raise "You are exporting model from modelscope, please install modelscope and try it again. To install modelscope, you could:\n" \
+ "\npip3 install -U modelscope\n" \
+ "For the users in China, you could install with the command:\n" \
+ "\npip3 install -U modelscope -i https://mirror.sjtu.edu.cn/pypi/web/simple"
try:
model_dir = snapshot_download(model_dir, cache_dir=cache_dir)
except:
@@ -49,7 +55,13 @@ class Paraformer():
model_file = os.path.join(model_dir, 'model_quant.onnx')
if not os.path.exists(model_file):
print(".onnx is not exist, begin to export onnx")
- from funasr.export.export_model import ModelExport
+ try:
+ from funasr.export.export_model import ModelExport
+ except:
+ raise "You are exporting onnx, please install funasr and try it again. To install funasr, you could:\n" \
+ "\npip3 install -U funasr\n" \
+ "For the users in China, you could install with the command:\n" \
+ "\npip3 install -U funasr -i https://mirror.sjtu.edu.cn/pypi/web/simple"
export_model = ModelExport(
cache_dir=cache_dir,
onnx=True,
@@ -229,7 +241,14 @@ class ContextualParaformer(Paraformer):
):
if not Path(model_dir).exists():
- from modelscope.hub.snapshot_download import snapshot_download
+ try:
+ from modelscope.hub.snapshot_download import snapshot_download
+ except:
+ raise "You are exporting model from modelscope, please install modelscope and try it again. To install modelscope, you could:\n" \
+ "\npip3 install -U modelscope\n" \
+ "For the users in China, you could install with the command:\n" \
+ "\npip3 install -U modelscope -i https://mirror.sjtu.edu.cn/pypi/web/simple"
+
try:
model_dir = snapshot_download(model_dir, cache_dir=cache_dir)
except:
diff --git a/funasr/runtime/python/onnxruntime/funasr_onnx/paraformer_online_bin.py b/funasr/runtime/python/onnxruntime/funasr_onnx/paraformer_online_bin.py
index 1e0611ee3..b39e2f59c 100644
--- a/funasr/runtime/python/onnxruntime/funasr_onnx/paraformer_online_bin.py
+++ b/funasr/runtime/python/onnxruntime/funasr_onnx/paraformer_online_bin.py
@@ -28,7 +28,13 @@ class Paraformer():
):
if not Path(model_dir).exists():
- from modelscope.hub.snapshot_download import snapshot_download
+ try:
+ from modelscope.hub.snapshot_download import snapshot_download
+ except:
+ raise "You are exporting model from modelscope, please install modelscope and try it again. To install modelscope, you could:\n" \
+ "\npip3 install -U modelscope\n" \
+ "For the users in China, you could install with the command:\n" \
+ "\npip3 install -U modelscope -i https://mirror.sjtu.edu.cn/pypi/web/simple"
try:
model_dir = snapshot_download(model_dir, cache_dir=cache_dir)
except:
@@ -41,7 +47,13 @@ class Paraformer():
decoder_model_file = os.path.join(model_dir, 'decoder_quant.onnx')
if not os.path.exists(encoder_model_file) or not os.path.exists(decoder_model_file):
print(".onnx is not exist, begin to export onnx")
- from funasr.export.export_model import ModelExport
+ try:
+ from funasr.export.export_model import ModelExport
+ except:
+ raise "You are exporting onnx, please install funasr and try it again. To install funasr, you could:\n" \
+ "\npip3 install -U funasr\n" \
+ "For the users in China, you could install with the command:\n" \
+ "\npip3 install -U funasr -i https://mirror.sjtu.edu.cn/pypi/web/simple"
export_model = ModelExport(
cache_dir=cache_dir,
onnx=True,
diff --git a/funasr/runtime/python/onnxruntime/funasr_onnx/punc_bin.py b/funasr/runtime/python/onnxruntime/funasr_onnx/punc_bin.py
index cc5daa861..6e289f695 100644
--- a/funasr/runtime/python/onnxruntime/funasr_onnx/punc_bin.py
+++ b/funasr/runtime/python/onnxruntime/funasr_onnx/punc_bin.py
@@ -29,7 +29,13 @@ class CT_Transformer():
):
if not Path(model_dir).exists():
- from modelscope.hub.snapshot_download import snapshot_download
+ try:
+ from modelscope.hub.snapshot_download import snapshot_download
+ except:
+ raise "You are exporting model from modelscope, please install modelscope and try it again. To install modelscope, you could:\n" \
+ "\npip3 install -U modelscope\n" \
+ "For the users in China, you could install with the command:\n" \
+ "\npip3 install -U modelscope -i https://mirror.sjtu.edu.cn/pypi/web/simple"
try:
model_dir = snapshot_download(model_dir, cache_dir=cache_dir)
except:
@@ -41,7 +47,13 @@ class CT_Transformer():
model_file = os.path.join(model_dir, 'model_quant.onnx')
if not os.path.exists(model_file):
print(".onnx is not exist, begin to export onnx")
- from funasr.export.export_model import ModelExport
+ try:
+ from funasr.export.export_model import ModelExport
+ except:
+ raise "You are exporting onnx, please install funasr and try it again. To install funasr, you could:\n" \
+ "\npip3 install -U funasr\n" \
+ "For the users in China, you could install with the command:\n" \
+ "\npip3 install -U funasr -i https://mirror.sjtu.edu.cn/pypi/web/simple"
export_model = ModelExport(
cache_dir=cache_dir,
onnx=True,
diff --git a/funasr/runtime/python/onnxruntime/funasr_onnx/vad_bin.py b/funasr/runtime/python/onnxruntime/funasr_onnx/vad_bin.py
index 244dd757a..589299579 100644
--- a/funasr/runtime/python/onnxruntime/funasr_onnx/vad_bin.py
+++ b/funasr/runtime/python/onnxruntime/funasr_onnx/vad_bin.py
@@ -35,7 +35,13 @@ class Fsmn_vad():
):
if not Path(model_dir).exists():
- from modelscope.hub.snapshot_download import snapshot_download
+ try:
+ from modelscope.hub.snapshot_download import snapshot_download
+ except:
+ raise "You are exporting model from modelscope, please install modelscope and try it again. To install modelscope, you could:\n" \
+ "\npip3 install -U modelscope\n" \
+ "For the users in China, you could install with the command:\n" \
+ "\npip3 install -U modelscope -i https://mirror.sjtu.edu.cn/pypi/web/simple"
try:
model_dir = snapshot_download(model_dir, cache_dir=cache_dir)
except:
@@ -47,7 +53,13 @@ class Fsmn_vad():
model_file = os.path.join(model_dir, 'model_quant.onnx')
if not os.path.exists(model_file):
print(".onnx is not exist, begin to export onnx")
- from funasr.export.export_model import ModelExport
+ try:
+ from funasr.export.export_model import ModelExport
+ except:
+ raise "You are exporting onnx, please install funasr and try it again. To install funasr, you could:\n" \
+ "\npip3 install -U funasr\n" \
+ "For the users in China, you could install with the command:\n" \
+ "\npip3 install -U funasr -i https://mirror.sjtu.edu.cn/pypi/web/simple"
export_model = ModelExport(
cache_dir=cache_dir,
onnx=True,
@@ -191,7 +203,13 @@ class Fsmn_vad_online():
cache_dir: str = None
):
if not Path(model_dir).exists():
- from modelscope.hub.snapshot_download import snapshot_download
+ try:
+ from modelscope.hub.snapshot_download import snapshot_download
+ except:
+ raise "You are exporting model from modelscope, please install modelscope and try it again. To install modelscope, you could:\n" \
+ "\npip3 install -U modelscope\n" \
+ "For the users in China, you could install with the command:\n" \
+ "\npip3 install -U modelscope -i https://mirror.sjtu.edu.cn/pypi/web/simple"
try:
model_dir = snapshot_download(model_dir, cache_dir=cache_dir)
except:
@@ -203,7 +221,13 @@ class Fsmn_vad_online():
model_file = os.path.join(model_dir, 'model_quant.onnx')
if not os.path.exists(model_file):
print(".onnx is not exist, begin to export onnx")
- from funasr.export.export_model import ModelExport
+ try:
+ from funasr.export.export_model import ModelExport
+ except:
+ raise "You are exporting onnx, please install funasr and try it again. To install funasr, you could:\n" \
+ "\npip3 install -U funasr\n" \
+ "For the users in China, you could install with the command:\n" \
+ "\npip3 install -U funasr -i https://mirror.sjtu.edu.cn/pypi/web/simple"
export_model = ModelExport(
cache_dir=cache_dir,
onnx=True,
diff --git a/funasr/runtime/python/onnxruntime/setup.py b/funasr/runtime/python/onnxruntime/setup.py
index b7f615602..a475f1dec 100644
--- a/funasr/runtime/python/onnxruntime/setup.py
+++ b/funasr/runtime/python/onnxruntime/setup.py
@@ -13,7 +13,7 @@ def get_readme():
MODULE_NAME = 'funasr_onnx'
-VERSION_NUM = '0.2.1'
+VERSION_NUM = '0.2.2'
setuptools.setup(
name=MODULE_NAME,
@@ -33,8 +33,6 @@ setuptools.setup(
"numpy>=1.19.3",
"kaldi-native-fbank",
"PyYAML>=5.1.2",
- "funasr",
- "modelscope",
"onnx"
],
packages=[MODULE_NAME, f'{MODULE_NAME}.utils'],