Model card and the original license
Browse files
README.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: alibabasglab/FRCRN_SE_16K
|
| 3 |
+
base_model_relation: quantized
|
| 4 |
+
license: apache-2.0
|
| 5 |
+
pipeline_tag: audio-to-audio
|
| 6 |
+
library_name: onnx
|
| 7 |
+
tags:
|
| 8 |
+
- onnx
|
| 9 |
+
- moonbox
|
| 10 |
+
- onnxruntime
|
| 11 |
+
- frcrn
|
| 12 |
+
- clearervoice
|
| 13 |
+
- speech-enhancement
|
| 14 |
+
- denoising
|
| 15 |
+
- noise-suppression
|
| 16 |
+
- 16khz
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
# FRCRN ONNX
|
| 20 |
+
|
| 21 |
+
ONNX builds of [FRCRN](https://huggingface.co/alibabasglab/FRCRN_SE_16K), made by Moonbox for on-device use with ONNX Runtime (CPU, CUDA, DirectML). Each
|
| 22 |
+
precision is one folder; what the graphs take and return, and the signal processing that goes around them, is
|
| 23 |
+
under *How to run*.
|
| 24 |
+
|
| 25 |
+
## Files
|
| 26 |
+
|
| 27 |
+
The last column is the benchmark on the VoiceBank-DEMAND test set (824 noisy utterances; details under *How to
|
| 28 |
+
run*): each precision's speech-quality scores, and how far its output is from the original PyTorch model's.
|
| 29 |
+
|
| 30 |
+
| Precision | File | Size | sha256 | Benchmark |
|
| 31 |
+
|---|---|---|---|---|
|
| 32 |
+
| fp16 | [`fp16/model.onnx`](https://huggingface.co/moonbox-dev/FRCRN_SE_16K-ONNX/blob/main/fp16/model.onnx) | 29.4 MB | `b726166d44ce` | fp16 storage, fp32 math: PESQ 3.033, STOI 0.9530, SI-SDR 18.68 dB; vs fp32 66.6 / 41.0 dB; worst file -0.09 dB (CUDA) |
|
| 33 |
+
|
| 34 |
+
## How to run
|
| 35 |
+
|
| 36 |
+
FRCRN SE 16K (ClearerVoice-Studio's speech enhancement: removes noise from speech at 16 kHz; a complex-valued
|
| 37 |
+
convolutional recurrent network on the STFT) as one ONNX graph: input `wave` [1, N] (16 kHz mono, float), output
|
| 38 |
+
`enhanced` [1, N]. The STFT, the complex mask and the inverse STFT are inside the graph (FRCRN computes its STFT with
|
| 39 |
+
convolutions), so the graph is the whole denoiser; N is free. Around it, ClearerVoice brings the input to a fixed
|
| 40 |
+
loudness (`audio_norm`, -25 dBFS) and scales the output back, and its decode function pads clips shorter than 1 s and
|
| 41 |
+
runs anything up to 120 s in one call. Both are kept here, as in the benchmark:
|
| 42 |
+
|
| 43 |
+
```python
|
| 44 |
+
import numpy as np, onnxruntime as ort, soundfile as sf, torch
|
| 45 |
+
import clearvoice.utils.decode as dec # pip install clearvoice==0.1.2 (only for its helpers)
|
| 46 |
+
from clearvoice.dataloader.dataloader import audio_norm
|
| 47 |
+
from clearvoice.network_wrapper import network_wrapper
|
| 48 |
+
|
| 49 |
+
w = network_wrapper(); w.model_name = "FRCRN_SE_16K"; w.load_args_se()
|
| 50 |
+
args = w.args; args.network = "FRCRN_SE_16K"
|
| 51 |
+
sess = ort.InferenceSession("fp16/model.onnx", providers=["CUDAExecutionProvider", "CPUExecutionProvider"])
|
| 52 |
+
|
| 53 |
+
class Net: # what decode() calls
|
| 54 |
+
def inference(self, x):
|
| 55 |
+
return torch.from_numpy(sess.run(None, {"wave": x.numpy().astype(np.float32)})[0])
|
| 56 |
+
|
| 57 |
+
noisy, sr = sf.read("noisy_16k.wav", dtype="float32") # 16 kHz mono
|
| 58 |
+
x, scale = audio_norm(noisy.astype(np.float64))
|
| 59 |
+
clean = dec.decode_one_audio(Net(), torch.device("cpu"), x[None].astype(np.float32), args)
|
| 60 |
+
sf.write("enhanced.wav", np.asarray(clean, np.float32).reshape(-1)[: len(noisy)] * scale, 16000)
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
Without ClearerVoice: scale the waveform to about -25 dBFS RMS, pad it with zeros to at least 1 s, run the graph
|
| 64 |
+
once, cut the output back to the input's length and undo the scaling.
|
| 65 |
+
|
| 66 |
+
**Precision.** Only `fp16/`: the weights stored in fp16 and cast to fp32 where they are read, so the math is fp32's
|
| 67 |
+
(a true fp16 graph loses a lot: PESQ 2.24 instead of 3.29 on our first test clips). Use a GPU provider: on ONNX
|
| 68 |
+
Runtime's CPU provider the graph runs about 8 times slower than real time on a laptop CPU (as does the PyTorch
|
| 69 |
+
original). **No int8 or int4**: both fail. Weight-only int8 puts 583 of the 824 test files more than 0.5 dB below
|
| 70 |
+
the original (mean -4.6 dB, worst 29 dB). Int4 (MatMulNBits) all but undoes the enhancement (PESQ 2.02, against 1.97
|
| 71 |
+
for the noisy input). The model is sensitive to weight rounding in every layer type we tried. No bf16 (no bf16
|
| 72 |
+
convolution in ONNX Runtime).
|
| 73 |
+
|
| 74 |
+
**Benchmark.** VoiceBank-DEMAND test set (Valentini et al.: 824 utterances by two unseen speakers), resampled to 16
|
| 75 |
+
kHz, enhanced with ClearerVoice's own loudness normalization and decode code. PESQ is wide-band (ITU-T P.862.2), STOI
|
| 76 |
+
and SI-SDR against the clean speech. The PyTorch original (`clearvoice` 0.1.2, fp32) runs 11 times slower than real
|
| 77 |
+
time on this laptop's CPU, so it was run on the first 50 files. There, the ONNX fp32 graph on CUDA matches it at 74.3
|
| 78 |
+
dB mean (56.2 dB worst file), and no file is more than 0.08 dB SI-SDR below it. The full set then compares against
|
| 79 |
+
that fp32 graph. "vs fp32" is the SI-SDR of each output against the fp32 graph's, mean / worst file; "worst file" is
|
| 80 |
+
the largest SI-SDR drop on any one file. Pass (the speech-enhancement threshold used across these repositories): no
|
| 81 |
+
file more than 0.5 dB below. Real-time factor on an RTX 3080 Laptop GPU, whole pipeline.
|
| 82 |
+
|
| 83 |
+
| | Files | PESQ | STOI | SI-SDR (dB) | vs fp32 (dB) | Worst file | Real-time factor |
|
| 84 |
+
|---|---|---|---|---|---|---|---|
|
| 85 |
+
| noisy input | 824 | 1.97 | 0.921 | 8.39 | - | - | - |
|
| 86 |
+
| original (PyTorch fp32, CPU) | first 50 | 3.184 | 0.9457 | 19.32 | - | - | 10.8 |
|
| 87 |
+
| ONNX fp32 (CUDA, not published) | first 50 | 3.184 | 0.9457 | 19.32 | - | -0.08 dB vs original | - |
|
| 88 |
+
| ONNX fp32 (CUDA, not published) | 824 | 3.035 | 0.9530 | 18.67 | - | - | 0.087 |
|
| 89 |
+
| `fp16/` (CUDA) | 824 | 3.033 | 0.9530 | 18.68 | 66.6 / 41.0 | -0.09 dB | 0.087 |
|
| 90 |
+
| int8 (not published) | 824 | 2.929 | 0.9490 | 14.10 | 20.8 / -7.0 | -29.2 dB (583 files below -0.5) | 0.090 |
|
| 91 |
+
| int4 (not published) | 824 | 2.023 | 0.9170 | 8.82 | 9.7 / -11.2 | -30.1 dB | 0.090 |
|
| 92 |
+
|
| 93 |
+
## How these were made
|
| 94 |
+
|
| 95 |
+
From [FRCRN](https://huggingface.co/alibabasglab/FRCRN_SE_16K) at revision `3766e6a64b`, starting from an fp32 ONNX graph (where it came from is said above).
|
| 96 |
+
fp16: onnxconverter-common with inputs and outputs kept fp32, or, where the network's activations leave fp16's
|
| 97 |
+
range, fp16 weights with fp32 math (said above when so). int8: weight-only, every Conv / MatMul / GRU weight int8
|
| 98 |
+
with a per-output-channel scale behind DequantizeLinear and activations in fp32, so it runs on the CPU provider
|
| 99 |
+
without a calibration set. int4: ONNX Runtime's MatMulNBits (weight-only, block 32) on the MatMul weights, the rest
|
| 100 |
+
int8 as above, where the graph has enough MatMul weights to matter. No bf16: ONNX Runtime has no bf16 convolution or
|
| 101 |
+
GRU kernels. Every graph was benchmarked before upload; the `sha256` column above is what the files must hash to.
|
| 102 |
+
|
| 103 |
+
## License
|
| 104 |
+
|
| 105 |
+
Apache-2.0. These files are a derivative of the original model and carry its license: it is copied in this
|
| 106 |
+
repository, and it governs your use of these files. The original model card follows unchanged.
|
| 107 |
+
|
| 108 |
+
---
|
| 109 |
+
|
| 110 |
+
# Original model card
|
| 111 |
+
|
| 112 |
+
The FRCRN_SE_16K model weights for 16 kHz speech enhancement in [ClearerVoice-Studio](https://github.com/modelscope/ClearerVoice-Studio/tree/main) repo.
|
| 113 |
+
|
| 114 |
+
This model is trained on large scale datasets inclduing open-sourced and private data.
|
| 115 |
+
|
| 116 |
+
It enhances speech audios by removing background noise.
|