Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
language: en
|
| 4 |
+
tags:
|
| 5 |
+
- speech-enhancement
|
| 6 |
+
- audio
|
| 7 |
+
- speech
|
| 8 |
+
- svod
|
| 9 |
+
- gtcrn
|
| 10 |
+
- real-time
|
| 11 |
+
pipeline_tag: audio-to-audio
|
| 12 |
+
library_name: safetensors
|
| 13 |
+
base_model:
|
| 14 |
+
- Xiaobin-Guang/GTCRN
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# GTCRN β Grouped Temporal Convolutional Recurrent Network (svod port)
|
| 18 |
+
|
| 19 |
+
Speech enhancement model ported to run natively in [**svod**](https://github.com/npatsakula/svod) β
|
| 20 |
+
a pure-Rust inference stack on top of a JIT-compiled tensor runtime. This repo
|
| 21 |
+
holds the converted weights only; the model implementation lives in
|
| 22 |
+
`svod-model` (`model/src/gtcrn/`).
|
| 23 |
+
|
| 24 |
+
Ultralight real-time noise suppression: **48.8 K parameters**, **33.0 MMACs/s**.
|
| 25 |
+
Takes a noisy 16 kHz mono waveform, returns an enhanced waveform.
|
| 26 |
+
|
| 27 |
+
## Source
|
| 28 |
+
|
| 29 |
+
A faithful Rust port of the upstream
|
| 30 |
+
[Xiaobin-Guang/GTCRN](https://github.com/Xiaobin-Guang/GTCRN), checkpoint
|
| 31 |
+
`model_trained_on_dns3.tar` (trained on the DNS-Challenge 3 dataset). The
|
| 32 |
+
upstream architecture and training are unchanged; this repo republishes the
|
| 33 |
+
weights in `safetensors` with the small remaps described below.
|
| 34 |
+
|
| 35 |
+
## Architecture
|
| 36 |
+
|
| 37 |
+
```
|
| 38 |
+
noisy WAV β STFT(n_fft=512, hop=256, βhann)
|
| 39 |
+
β ERB analysis (257 bins β 129 bands)
|
| 40 |
+
β SFE (subband unfold)
|
| 41 |
+
β Encoder: 2Γ ConvBlock + 3Γ GTConvBlock (ShuffleNetV2)
|
| 42 |
+
β 2Γ DPGRNN (dual-path grouped RNN: intra-frame bidir GRU + inter-frame GRU)
|
| 43 |
+
β Decoder: 3Γ GTConvBlock (transpose) + 2Γ ConvBlock (transpose)
|
| 44 |
+
β ERB synthesis (129 β 257)
|
| 45 |
+
β complex ratio mask Γ input spectrogram
|
| 46 |
+
β ISTFT β enhanced WAV
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
## Usage
|
| 50 |
+
|
| 51 |
+
```bash
|
| 52 |
+
# Build svod-model and run the bundled example (noisy.wav β enhanced.wav):
|
| 53 |
+
cargo run -p svod-model --release --example gtcrn_enhance -- \
|
| 54 |
+
--in noisy.wav --out enhanced.wav --hub
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
In Rust:
|
| 58 |
+
|
| 59 |
+
```rust
|
| 60 |
+
use svod_model::gtcrn::{Gtcrn, GtcrnJit};
|
| 61 |
+
use svod_model::jit::InputSpec;
|
| 62 |
+
|
| 63 |
+
let model = Gtcrn::from_hub()?; // pulls gtcrn.safetensors from this repo
|
| 64 |
+
let mut jit = GtcrnJit::new(model);
|
| 65 |
+
jit.prepare(InputSpec::f32(&[1, 257, T, 2]))?; // T = number of STFT frames
|
| 66 |
+
// copy the [1, 257, T, 2] complex spectrogram into jit.spec_mut()?, then:
|
| 67 |
+
jit.execute()?;
|
| 68 |
+
let enhanced = jit.output()?;
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
STFT/ISTFT run eagerly on the host via `realfft`; the network forward pass is
|
| 72 |
+
JIT-compiled. See `model/examples/gtcrn_enhance.rs` for the full waveform β
|
| 73 |
+
waveform pipeline (it processes long audio in fixed-size frame chunks because
|
| 74 |
+
the in-graph GRU recurrence unrolls one IR node per time step).
|
| 75 |
+
|
| 76 |
+
## Files
|
| 77 |
+
|
| 78 |
+
| File | Description |
|
| 79 |
+
|---|---|
|
| 80 |
+
| `gtcrn.safetensors` | Converted model weights (249 tensors, 48.8 K params). |
|
| 81 |
+
| `golden.safetensors` | PyTorch reference output for the parity test (a 24-frame slice of `mix.wav`). |
|
| 82 |
+
|
| 83 |
+
## Conversion notes
|
| 84 |
+
|
| 85 |
+
Generated by `scripts/convert_gtcrn.py` (run `uv run scripts/convert_gtcrn.py
|
| 86 |
+
--selfcheck` to reproduce). Two remaps from the upstream PyTorch checkpoint:
|
| 87 |
+
|
| 88 |
+
1. **GRU gate order.** PyTorch `nn.GRU` stores gate rows as `[reset, update,
|
| 89 |
+
new]`; svod's `gru()` op expects `[z, r, h]`. The first two hidden-sized
|
| 90 |
+
gate blocks of every GRU weight/bias are swapped.
|
| 91 |
+
|
| 92 |
+
2. **Bidirectional key split.** The DPGRNN's bidirectional grouped RNNs expose
|
| 93 |
+
`rnn1`/`rnn2` modules whose reverse-direction weights
|
| 94 |
+
(`*_l0_reverse`) are renamed to separate `rnn1_b`/`rnn2_b` keys, matching
|
| 95 |
+
svod's representation of a bidirectional GRU as two unidirectional passes
|
| 96 |
+
(forward over the sequence + forward over the time-flipped sequence,
|
| 97 |
+
concatenated).
|
| 98 |
+
|
| 99 |
+
`num_batches_tracked` entries are dropped; BatchNorm `running_var` is kept
|
| 100 |
+
verbatim (svod folds it into `invstd = 1/β(var+Ξ΅)` at load time). The `--selfcheck`
|
| 101 |
+
flag verifies the GRU remap against svod's documented recurrence equations.
|
| 102 |
+
|
| 103 |
+
## Verification
|
| 104 |
+
|
| 105 |
+
The svod forward matches the upstream PyTorch `GTCRN.forward` to ~6 significant
|
| 106 |
+
figures on a fixed-frame slice (`max |Ξ|` relative < 1e-3), validated by the
|
| 107 |
+
`gtcrn::parity` test in `svod-model`.
|
| 108 |
+
|
| 109 |
+
## License
|
| 110 |
+
|
| 111 |
+
MIT β same as the upstream model. Weights Β© their respective authors; this repo
|
| 112 |
+
only republishes them in a converted format for use with svod.
|