Skip to content

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

fix export error if using cpu device; fix model path (#2265)

Thomas Young46721dc84a6b
diff --git a/export.py b/export.py
index 3307e96e1..2ea6dea28 100644
--- a/export.py
+++ b/export.py
@@ -2,7 +2,7 @@
from funasr import AutoModel
model = AutoModel(
- model="/raid/t3cv/wangch/WORK_SAPCE/ASR/models/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch"
+ model="iic/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch"
)
res = model.export(type="onnx", quantize=False, opset_version=13, device='cuda') # fp32 onnx-gpu
diff --git a/funasr/utils/export_utils.py b/funasr/utils/export_utils.py
index 667418ccb..dbec50426 100644
--- a/funasr/utils/export_utils.py
+++ b/funasr/utils/export_utils.py
@@ -65,8 +65,9 @@ def _onnx(
**kwargs,
):
+ device = kwargs.get("device", "cpu")
dummy_input = model.export_dummy_inputs()
- dummy_input = (dummy_input[0].to("cuda"), dummy_input[1].to("cuda"))
+ dummy_input = (dummy_input[0].to(device), dummy_input[1].to(device))
verbose = kwargs.get("verbose", False)