modelscope / FunASR

A Fundamental End-to-End Speech Recognition Toolkit and Open Source SOTA Pretrained Models, Supporting Speech Recognition, Voice Activity Detection, Text Post-processing etc.
https://www.funasr.com
Other
5.91k stars 642 forks source link

ONNX Export of Pretrained models outputs garbage #2040

Open andreystarenky opened 2 weeks ago

andreystarenky commented 2 weeks ago

Notice: In order to resolve issues more efficiently, please raise issue following the template. (注意:为了更加高效率解决您遇到的问题,请按照模板提问,补充细节)

❓ Questions and Help

Before asking:

  1. search the issues.
  2. search the docs.

What is your question?

I tried both the funasr-export and model.export in python to export paraformer-zh or paraformer-zh-streaming into an onnx file, but the resulting onnx file does not work properly, it outputs garbage. When I use "paraformer" in AutoModel it works fine, but not "paraformer-zh" or "paraformer-zh-streaming"

My goal is to get onnx of the paraformer-zh-streaming model

Code

from funasr import AutoModel

model = AutoModel(model="paraformer", device="cpu") # this onnx model works
#model = AutoModel(model="paraformer-zh", device="cpu") # this onnx file outputs garbage
#model = AutoModel(model="paraformer-zh-streaming", device="cpu") # this onnx file outputs garbage

res = model.export(quantize=False)

I am running the model as such:

model = Paraformer(model_dir, batch_size=1, quantize=False)
result = model(wav_path)

example output::

[{'preds': ('去去inn去去inn去去去inn inn去去inn去去inn去去去去去inn去去去去去inn去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去妓妓妓妓妓妓妓妓妓妓妓 . . . 

I have also tried to run this model: https://www.modelscope.cn/models/iic/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-online-onnx/files

This is the output that I get:

[{'preds': ('去去anyanyanyinn inn去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去去妓妓妓妓妓妓妓妓妓妓妓妓妓妓妓妓妓妓妓妓妓妓妓犀妓妓妓妓妓鎉斜 . . . 

What have you tried?

I have searched the issues and docs, and have tried both the funasr-export util and the python code to export.

What's your environment?

andreystarenky commented 2 weeks ago

^ it looks like you guys have some bots in your repository as well, maybe need to ban these or add some filter lol