Views
No views yet
| Spec | |
|---|---|
| Architecture | Conv-TasNet (encoder + temporal-conv mask network + decoder) |
| Input | mono waveform, (batch, time) float32, 16 kHz |
| Output | 2 separated source streams, (batch, 2, time) float32 |
| File size | 19 MB (FP32) |
| Trained on | Libri2Mix sepclean (16 kHz, 2-speaker mixtures) |
| Authors | Joris Cosentino et al. |
1import numpy as np
2import onnxruntime as ort
3import soundfile as sf
4from huggingface_hub import hf_hub_download
5
6# 1. Load model
7model_path = hf_hub_download("welcomyou/convtasnet-libri2mix-16k-onnx",
8 "convtasnet_16k.onnx")
9opts = ort.SessionOptions()
10opts.intra_op_num_threads = 4
11sess = ort.InferenceSession(model_path, opts, providers=["CPUExecutionProvider"])
12
13# 2. Load 16 kHz mono mixture
14audio, sr = sf.read("mixture.wav", dtype="float32") # must be 16 kHz mono
15assert sr == 16000 and audio.ndim == 1
16
17# 3. Separate
18x = audio[np.newaxis] # (1, T)
19sources = sess.run(None, {"mixture": x})[0] # (1, 2, T)
20spk_a, spk_b = sources[0, 0], sources[0, 1]
21
22# 4. Save (matching mixture length — Conv-TasNet may pad output by a few samples)
23T = len(audio)
24sf.write("source_a.wav", spk_a[:T], 16000)
25sf.write("source_b.wav", spk_b[:T], 16000)| Audio length | PyTorch | ONNX FP32 | Speedup |
|---|---|---|---|
| 3 s | 661 ms | 449 ms | 1.5× |
| 5 s | 1054 ms | 961 ms | 1.1× |
| 10 s | 2034 ms | 2056 ms | 1.0× |
1pip install torch asteroid asteroid_filterbanks onnxruntime numpy
2python convert_onnx/export_convtasnet_onnx.py \
3 --output convtasnet_16k.onnx \
4 --verifyconvert_onnx/export_convtasnet_onnx.py — wraps torch.onnx.export with dynamic axes (time axis dynamic; supports any input length).