Emotion2Vec onnx? #2151
-
|
Hi all, is exporting the emotion2vec_plus models to onnx supported? Thanks a lot! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Looking for onnx as well. I made some progress but this repository deleted the related issue where I wrote the notes :( |
Beta Was this translation helpful? Give feedback.
-
|
Emotion2Vec ONNX export is available now. Support was added in #2359. I re-tested the current One current filename issue is easy to miss: the exporter writes a valid graph named from pathlib import Path
import numpy as np
import onnx
import onnxruntime as ort
from funasr import AutoModel
output_dir = Path("./emotion2vec_onnx")
model = AutoModel(
model="iic/emotion2vec_plus_large",
hub="ms",
device="cpu",
disable_update=True,
)
export_dir = Path(
model.export(
type="onnx",
quantize=False,
device="cpu",
output_dir=str(output_dir),
opset_version=14,
)
)
onnx_path = export_dir / "emotion2vec.onnx"
if not onnx_path.is_file():
raw_path = export_dir / "emotion2vec"
if not raw_path.is_file():
raise FileNotFoundError(f"No Emotion2Vec ONNX graph found in {export_dir}")
raw_path.rename(onnx_path)
graph = onnx.load(str(onnx_path), load_external_data=True)
onnx.checker.check_model(graph)
session = ort.InferenceSession(
str(onnx_path),
providers=["CPUExecutionProvider"],
)
waveform = np.random.randn(1, 16000).astype(np.float32) # 16 kHz mono, [batch, samples]
features = session.run(["output"], {"input": waveform})[0]
print(features.shape) # (1, 49, 1024)Fresh verification results:
The exported interface is the dynamic-length Emotion2Vec feature extractor. Its output is frame-level 1024-dimensional features, not the final The missing suffix is a naming bug in the current exporter, not a broken ONNX graph. |
Beta Was this translation helpful? Give feedback.
Emotion2Vec ONNX export is available now. Support was added in #2359. I re-tested the current
main(1d8080af) with the publiciic/emotion2vec_plus_largecheckpoint and ONNX Runtime CPU.One current filename issue is easy to miss: the exporter writes a valid graph named
emotion2vecwithout the.onnxsuffix. Rename that file after export; no conversion is needed.