Jeffrey Guan
2025-07-23 8316fc41973b89267a70681a7afe4e947e0ba251
docs(readme): update onnx example import path and cache location (#2607)

The example code in README files was updated to use the correct import path for Paraformer from the runtime package instead of the top-level module. The wav path was also modified to use Path.home() for cross-platform compatibility and to include the missing 'models' directory in the cache path. These changes ensure the examples work correctly with the current package structure.
2个文件已修改
18 ■■■■ 已修改文件
README.md 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
README_zh.md 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
README.md
@@ -315,11 +315,16 @@
### Test ONNX
```python
# pip3 install -U funasr-onnx
from funasr_onnx import Paraformer
from pathlib import Path
from runtime.python.onnxruntime.funasr_onnx.paraformer_bin import Paraformer
home_dir = Path.home()
model_dir = "damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch"
model = Paraformer(model_dir, batch_size=1, quantize=True)
wav_path = ['~/.cache/modelscope/hub/damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/example/asr_example.wav']
wav_path = [f"{home_dir}/.cache/modelscope/hub/models/damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/example/asr_example.wav"]
result = model(wav_path)
print(result)
README_zh.md
@@ -315,11 +315,16 @@
### 测试ONNX
```python
# pip3 install -U funasr-onnx
from funasr_onnx import Paraformer
from pathlib import Path
from runtime.python.onnxruntime.funasr_onnx.paraformer_bin import Paraformer
home_dir = Path.home()
model_dir = "damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch"
model = Paraformer(model_dir, batch_size=1, quantize=True)
wav_path = ['~/.cache/modelscope/hub/damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/example/asr_example.wav']
wav_path = [f"{home_dir}/.cache/modelscope/hub/models/damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/example/asr_example.wav"]
result = model(wav_path)
print(result)