Instructions to use moonbox-dev/MossFormerGAN_SE_16K-TensorRT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- TensorRT
How to use moonbox-dev/MossFormerGAN_SE_16K-TensorRT with TensorRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
MossFormerGAN TensorRT
TensorRT engines of MossFormerGAN, made by Moonbox for NVIDIA RTX GPUs. Each precision is one folder holding the
engine, trt_runner.py (a small numpy runner: TensorRT plus Polygraphy, no PyTorch) and a script that does the rest
of the pipeline. What the engine takes and returns is under How to run.
Compatibility. The engines are built hardware compatible (Ampere and newer: RTX 30, 40 and 50 series) and
version compatible (any TensorRT 10.x from 10.13 on, through its lean runtime). That costs a little speed against an
engine built for one GPU, but no rebuild is needed. Install the runtime with
pip install "tensorrt-cu12>=10.13,<11" "tensorrt-lean-cu12>=10.13,<11" polygraphy numpy.
Files
The last column is the benchmark (details under How to run).
| Precision | File | Size | sha256 | Benchmark |
|---|---|---|---|---|
| fp16 | fp16/model.engine |
253.6 MB | 5f38f1d126cc |
weakly typed: PESQ 3.342, STOI 0.9569, SI-SDR 19.77 dB; vs the ONNX fp16 build 60.6 dB mean, worst file -0.029 dB; RTF 0.085 (ONNX 0.202) |
| fp16 | fp16/trt_runner.py |
2.2 kB | efa8ba97631b |
weakly typed: PESQ 3.342, STOI 0.9569, SI-SDR 19.77 dB; vs the ONNX fp16 build 60.6 dB mean, worst file -0.029 dB; RTF 0.085 (ONNX 0.202) |
How to run
MossFormerGAN SE 16K (ClearerVoice-Studio's speech enhancement: removes noise from speech at 16 kHz; a MossFormer generator trained with a metric discriminator) as a TensorRT engine of its generator.
- Input:
spec[1, 2, T, 201], the real and imaginary parts of a 400-point STFT (hop 100, Hamming window), power-law compressed by 0.3. - Outputs:
realandimag[1, 1, T, 201]. - Length: T from 10 to 2000 frames (12.5 s; the profile is tuned for 500).
- Outside the engine: the normalization, the STFT, the compression and the inverse STFT, as in ClearerVoice's own code. ClearerVoice's decode function, with its network swapped for the engine, is the simplest correct pipeline.
import sys, numpy as np, soundfile as sf, torch
import clearvoice.utils.decode as dec # pip install clearvoice==0.1.2 (only for its decode helper)
from clearvoice.network_wrapper import network_wrapper
sys.path.insert(0, "fp16")
from trt_runner import Engine
w = network_wrapper(); w.model_name = "MossFormerGAN_SE_16K"; w.load_args_se()
args = w.args; args.network = "MossFormerGAN_SE_16K"
eng = Engine("fp16/model.engine")
class Net: # what decode() calls: net(spec) -> (real, imag)
def __call__(self, spec):
o = eng({"spec": spec.numpy().astype(np.float32)})
return [torch.from_numpy(o["real"].astype(np.float32)), torch.from_numpy(o["imag"].astype(np.float32))]
def eval(self):
return self
noisy, sr = sf.read("noisy_16k.wav", dtype="float32") # 16 kHz mono
clean = dec.decode_one_audio(Net(), torch.device("cpu"), noisy[None], args)
sf.write("enhanced.wav", np.asarray(clean, np.float32).reshape(-1)[: len(noisy)], 16000)
decode_one_audio itself processes files longer than 10 s in 10 s windows (about 1,600 frames), inside the
engine's range.
Precisions. fp16/: built from the fp16 ONNX graph, weakly typed: TensorRT chooses each layer's precision
itself, fp16 where it can. A strongly typed build has no TensorRT 10.13 kernel for the model's 64-group 1 x 2
convolutions in fp16, and forcing them to fp32 crashes TensorRT's Myelin compiler. Two parse fixes come first:
explicit Squeeze axes, the dimensions that are always 1, and the attention's EyeLike written as Range / Equal.
Both are exact in ONNX Runtime. No int8: TensorRT's int8 needs calibrated activations.
Benchmark.
- Data: the VoiceBank-DEMAND test set (824 utterances by two unseen speakers, 16 kHz), through ClearerVoice's own decode, on an RTX 3080 Laptop GPU.
- Scores: PESQ wide-band, STOI, SI-SDR against the clean speech.
- Agreement: the SI-SDR of each output against the ONNX fp16 build's output.
- Pass mark: no file's SI-SDR more than 0.5 dB below the ONNX build's.
| PESQ | STOI | SI-SDR (dB) | vs the ONNX build: mean / worst file (dB) | worst-file SI-SDR change | real-time factor | |
|---|---|---|---|---|---|---|
ONNX fp16/ (CUDA) |
3.342 | 0.9569 | 19.77 | - | - | 0.202 |
TensorRT fp16/ |
3.342 | 0.9569 | 19.77 | 60.6 / 58.0 | -0.029 | 0.085 |
The ONNX fp16 build is within 0.05 dB of the PyTorch original (clearvoice 0.1.2, fp32) on every file. The
real-time factor is for the whole pipeline (STFT on the CPU).
How these were made
From MossFormerGAN at revision dcb1b20e1e: each engine was built with TensorRT's builder from Moonbox's published
ONNX graph of the same model and precision. The network is strongly typed: every tensor keeps the precision the
ONNX graph gives it, so an fp16 engine computes what the fp16 ONNX build computes. Built on an RTX 3080 Laptop GPU,
it was benchmarked against the original before upload, and the sha256 column above is what the files must hash to.
License
Apache-2.0. These files are a derivative of the original model and carry its license: it is copied in this repository, and it governs your use of these files. The original model card follows unchanged.
Original model card
The MossFormerGAN_SE_16K model weights for 16 kHz speech enhancement in ClearerVoice-Studio repo.
This model is trained on large scale datasets inclduing open-sourced and private data.
It enhances speech audios by removing background noise.
- Downloads last month
- -
Model tree for moonbox-dev/MossFormerGAN_SE_16K-TensorRT
Base model
alibabasglab/MossFormerGAN_SE_16K