Dbazemore Simonlob commited on
Commit
5fd5573
·
0 Parent(s):

Duplicate from nineninesix/diamond-1.0

Browse files

Co-authored-by: Den Pavloff <Simonlob@users.noreply.huggingface.co>

.gitattributes ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.wav filter=lfs diff=lfs merge=lfs -text
37
+ TECH_REPORT.pdf filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ pipeline_tag: audio-to-audio
4
+ tags:
5
+ - speech-restoration
6
+ - speech-enhancement
7
+ - audio-to-audio
8
+ - autoregressive
9
+ - neural-audio-codec
10
+ - audio
11
+ ---
12
+
13
+ <div align="center">
14
+
15
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/65ae44614b5cc40be0e4fe72/qovLywMpRwPbWSyiCTbY-.png" alt="logo" width="800">
16
+
17
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Tech Report](https://img.shields.io/badge/📄-Tech%20Report-red.svg)](https://huggingface.co/nineninesix/diamond-1.0/resolve/main/TECH_REPORT.pdf) [![Model](https://img.shields.io/badge/🤗-Demo-yellow.svg)](https://huggingface.co/spaces/nineninesix/diamond) [![Website](https://img.shields.io/badge/⚡-nineninesix.ai-brightgreen.svg)](https://www.nineninesix.ai)
18
+
19
+ </div>
20
+
21
+ # **DIAMOND**
22
+
23
+ **A sequence-to-sequence model for speech restoration via an autoregressive RQ-Transformer over neural audio codec tokens**
24
+
25
+ [**Diamond**](https://huggingface.co/nineninesix/diamond-1.0/resolve/main/TECH_REPORT.pdf) turns degraded audio into near-studio 44.1 kHz speech. A bidirectional Transformer encodes the degraded mel-spectrogram; an autoregressive decoder with cross-attention predicts the tokens of a frozen neural audio codec (Descript Audio Codec, 9-book RVQ), which synthesizes the restored waveform.
26
+
27
+ Restoration is not denoising. A codec cuts the band above 8 kHz, clipping cuts the peaks, a lost packet zeroes the frame — no mask can return what the observation no longer contains. The missing content has to be **generated** from the surviving formants, which is why Diamond is a generative seq2seq model rather than a filter.
28
+
29
+ Diamond is trained **from scratch** — no pretrained backbone — and reaches the level of the strongest open restorers while remaining the best from-scratch restorer in its class.
30
+
31
+ ## Highlights
32
+
33
+ - **Two-transformer read-out.** A *time-transformer* models the frame sequence; a compact *depth-transformer* walks the 9 RVQ codebooks inside each frame. This restores the RVQ causal chain and distributes the output projection — where earlier models read all nine books out of a single frame vector with parallel heads.
34
+ - **From scratch, 166.6M trainable params.** No pretrained speech backbone, 63 GPU-hours of training for the released checkpoint.
35
+ - **44.1 kHz output.** The frozen DAC decoder synthesizes full-band audio; sibilants and "air" above 8 kHz are regenerated, not merely passed through.
36
+ - **Content is measured, not assumed.** A generative restorer can sound clean while smearing words, so CER against the ground-truth transcript is a mandatory second axis alongside DNSMOS.
37
+ - **Calibrated degradation.** Inputs come from a DSP augmentor whose codec palette is fitted per-sample to a real degraded-speech distribution, not from a bag of random effects.
38
+
39
+ ## Hear the difference
40
+
41
+ Real, heavily degraded speech restored to 44.1 kHz. DNSMOS-P.835 OVRL rises by more
42
+ than a full point on each clip — audible even without headphones. Try it live in the
43
+ [**Diamond Space**](https://huggingface.co/spaces/nineninesix/Diamond).
44
+
45
+ <table>
46
+ <thead>
47
+ <tr><th>#</th><th>Degraded input</th><th>Restored — 44.1&nbsp;kHz</th><th>DNSMOS&nbsp;OVRL</th></tr>
48
+ </thead>
49
+ <tbody>
50
+ <tr>
51
+ <td>1</td>
52
+ <td><audio controls src="https://huggingface.co/nineninesix/diamond-1.0/resolve/main/samples/example1_degraded.wav"></audio></td>
53
+ <td><audio controls src="https://huggingface.co/nineninesix/diamond-1.0/resolve/main/samples/example1_restored.wav"></audio></td>
54
+ <td>2.16&nbsp;→&nbsp;<b>3.50</b> &nbsp;(+1.34)</td>
55
+ </tr>
56
+ <tr>
57
+ <td>2</td>
58
+ <td><audio controls src="https://huggingface.co/nineninesix/diamond-1.0/resolve/main/samples/example2_degraded.wav"></audio></td>
59
+ <td><audio controls src="https://huggingface.co/nineninesix/diamond-1.0/resolve/main/samples/example2_restored.wav"></audio></td>
60
+ <td>2.83&nbsp;→&nbsp;<b>3.59</b> &nbsp;(+0.76)</td>
61
+ </tr>
62
+ <tr>
63
+ <td>3</td>
64
+ <td><audio controls src="https://huggingface.co/nineninesix/diamond-1.0/resolve/main/samples/example3_degraded.wav"></audio></td>
65
+ <td><audio controls src="https://huggingface.co/nineninesix/diamond-1.0/resolve/main/samples/example3_restored.wav"></audio></td>
66
+ <td>2.56&nbsp;→&nbsp;<b>3.65</b> &nbsp;(+1.10)</td>
67
+ </tr>
68
+ <tr>
69
+ <td>4</td>
70
+ <td><audio controls src="https://huggingface.co/nineninesix/diamond-1.0/resolve/main/samples/example4_degraded.wav"></audio></td>
71
+ <td><audio controls src="https://huggingface.co/nineninesix/diamond-1.0/resolve/main/samples/example4_restored.wav"></audio></td>
72
+ <td>3.32&nbsp;→&nbsp;<b>3.89</b> &nbsp;(+0.57)</td>
73
+ </tr>
74
+ </tbody>
75
+ </table>
76
+
77
+ ## Model Details
78
+
79
+ - **Developed by:** [nineninesix.ai](https://www.nineninesix.ai)
80
+ - **Model type:** Autoregressive sequence-to-sequence speech restoration (encoder + RQ-Transformer decoder over codec tokens)
81
+ - **Encoder:** Bidirectional Transformer, no downsampling — 20 layers, 512d, 8 heads (63.9M)
82
+ - **Decoder / time-transformer:** causal self-attention + cross-attention — 20 layers, 512d, 8 heads (88.7M)
83
+ - **Codebook read-out / depth-transformer:** local AR over the 9 RVQ codes of a frame — 4 layers, 384d, 6 heads (14.0M)
84
+ - **Parameters:** ≈ 166.6M trainable (the DAC codec, ~74M, is frozen and downloaded at runtime)
85
+ - **Audio codec:** [Descript Audio Codec](https://github.com/descriptinc/descript-audio-codec) — 44.1 kHz, 9-codebook RVQ, 86 frames/s
86
+ - **Primitives:** RMSNorm, learnable per-layer RoPE, QK-Norm, LayerScale, GELU FFN
87
+ - **Input / output sample rate:** any input, resampled to 24 kHz internally → 44,100 Hz output
88
+ - **Training data:** 681.5 h of studio speech, ~2.5k speakers, 28% natively wide-band.
89
+ - **Languages:** English
90
+ - **License:** Apache 2.0
91
+
92
+ ## Benchmarks
93
+
94
+ Measured on 750 real degraded recordings — identical clips for every model. DNSMOS-P.835 (raw `sig_bak_ovr.onnx`) for perceptual quality, CER against the ground-truth transcript for content preservation.
95
+
96
+ | Model | DNSMOS OVRL ↑ | SIG ↑ | BAK ↑ | CER (median) ↓ |
97
+ |---|---|---|---|---|
98
+ | Sidon | **3.923** | **4.129** | **4.416** | 0.016 |
99
+ | **Diamond (ours)** | 3.829 | 4.056 | 4.348 | 0.028 |
100
+ | RE-USE | 3.789 | 4.003 | 4.344 | **0.014** |
101
+ | Resemble Enhance | 3.764 | 3.994 | 4.301 | 0.027 |
102
+ | UniSE | 3.752 | 4.014 | 4.261 | 0.027 |
103
+ | VoiceFixer | 3.566 | 3.790 | 4.226 | 0.042 |
104
+ | input (degraded) | 3.575 | 3.890 | 4.082 | 0.014 |
105
+
106
+ Diamond improves ≈88% of clips (mean ΔOVRL +0.255) and places second of six on perceptual quality — ahead of RE-USE, which trains on roughly four times the data. Both systems that beat it on CER are **non-autoregressive**: the gap is the exposure bias inherent to AR decoding, not a capacity limit. The one other autoregressive system here, UniSE, lands on exactly Diamond's mean CER (0.131) by a different route — which suggests the tail belongs to the paradigm, not to this particular recipe.
107
+
108
+ ## Links
109
+
110
+ - **Checkpoint:** [huggingface.co/nineninesix/diamond-1.0](https://huggingface.co/nineninesix/diamond-1.0)
111
+ - **Technical Report:** [TECH_REPORT.pdf](https://huggingface.co/nineninesix/diamond-1.0/resolve/main/TECH_REPORT.pdf)
112
+ - **Training:** [github.com/nineninesix-ai/diamond-train](https://github.com/nineninesix-ai/diamond-train)
113
+ - **Website:** [nineninesix.ai](https://www.nineninesix.ai)
114
+
115
+ ## What it's good for
116
+
117
+ Offline restoration and **dataset cleansing** — turning large volumes of degraded recordings (podcasts, interviews, archival and user-generated audio that has passed through lossy codecs) into material clean enough to train on. This is the task Diamond was built for and the one it is measured on.
118
+
119
+ **Keep in mind:**
120
+
121
+ - **A thin CER tail.** As an autoregressive decoder, Diamond occasionally smears words on hard clips. Inference safeguards (chunked decoding, repetition penalty) hold it down, but the tail is real — check the transcript when content fidelity is critical.
122
+ - **Decoding is serial, not real-time.** One frame at a time, 86 frames per second of audio, plus the depth pass. This is offline restoration, not a live filter.
123
+ - **English-centric.** Training data is English; other languages are untested.
124
+ - **It generates, it does not filter.** Content above the codec's cutoff is invented from context — plausible, not recovered. Do not treat the output as forensic evidence of what was said.
125
+
126
+ > **Use it responsibly.** Restored speech is synthesized speech. Don't present it as an unaltered recording, and don't use it to fabricate or misattribute what someone said.
127
+
128
+ ## Acknowledgments
129
+
130
+ Built on the [Descript Audio Codec](https://github.com/descriptinc/descript-audio-codec) for the frozen token space. Trained on [LibriTTS-R](https://www.openslr.org/141/), [Hi-Fi TTS](https://www.openslr.org/109/), [VCTK](https://doi.org/10.7488/ds/2645). Evaluated with [DNSMOS P.835](https://github.com/microsoft/DNS-Challenge) and [faster-whisper](https://github.com/SYSTRAN/faster-whisper).
131
+
132
+ ## Citation
133
+
134
+ If you use this work in your research, please cite:
135
+
136
+ ```bibtex
137
+ @software{diamond_2026,
138
+ author = {Almaz Zholdoshbek uulu, Ulanbek Abdurazakov, Denis Pavlov and Nursultan Bakashov},
139
+ title = {Diamond: A Sequence-to-Sequence Model for Speech Restoration via an Autoregressive RQ-Transformer over Neural Audio Codec Tokens},
140
+ year = {2026},
141
+ publisher = {Hugging Face},
142
+ howpublished = {\url{https://huggingface.co/nineninesix/diamond-1.0}},
143
+ note = {Trained from scratch; no pretrained backbone}
144
+ }
145
+ ```
146
+
147
+ ## References
148
+
149
+ ```bibtex
150
+ @inproceedings{kumar2023dac,
151
+ title={High-Fidelity Audio Compression with Improved RVQGAN},
152
+ author={Kumar, Rithesh and Seetharaman, Prem and Luebs, Alejandro and Kumar, Ishaan and Kumar, Kundan},
153
+ booktitle={NeurIPS},
154
+ year={2023},
155
+ note={arXiv:2306.06546}
156
+ }
157
+
158
+ @inproceedings{lee2022rqtransformer,
159
+ title={Autoregressive Image Generation using Residual Quantization},
160
+ author={Lee, Doyup and Kim, Chiheon and Kim, Saehoon and Cho, Minsu and Han, Wook-Shin},
161
+ booktitle={CVPR},
162
+ year={2022},
163
+ note={arXiv:2203.01941}
164
+ }
165
+
166
+ @article{defossez2024moshi,
167
+ title={Moshi: a speech-text foundation model for real-time dialogue},
168
+ author={D{\'e}fossez, Alexandre and Mazar{\'e}, Laurent and Orsini, Manu and Royer, Am{\'e}lie and P{\'e}rez, Patrick and J{\'e}gou, Herv{\'e} and Grave, Edouard and Zeghidour, Neil},
169
+ journal={arXiv preprint arXiv:2410.00037},
170
+ year={2024}
171
+ }
172
+
173
+ @inproceedings{copet2023musicgen,
174
+ title={Simple and Controllable Music Generation},
175
+ author={Copet, Jade and Kreuk, Felix and Gat, Itai and Remez, Tal and Kant, David and Synnaeve, Gabriel and Adi, Yossi and D{\'e}fossez, Alexandre},
176
+ booktitle={NeurIPS},
177
+ year={2023},
178
+ note={arXiv:2306.05284}
179
+ }
180
+
181
+ @inproceedings{koizumi2023librittsr,
182
+ title={LibriTTS-R: A Restored Multi-Speaker Text-to-Speech Corpus},
183
+ author={Koizumi, Yuma and Zen, Heiga and Karita, Shigeki and Ding, Yifan and Yatabe, Kohei and Morioka, Nobuyuki and Bacchiani, Michiel and Zhang, Yu and Han, Wei and Bapna, Ankur},
184
+ booktitle={Interspeech},
185
+ year={2023},
186
+ note={arXiv:2305.18802}
187
+ }
188
+
189
+ @inproceedings{reddy2022dnsmos,
190
+ title={DNSMOS P.835: A Non-Intrusive Perceptual Objective Speech Quality Metric to Evaluate Noise Suppressors},
191
+ author={Reddy, Chandan K. A. and Gopal, Vishak and Cutler, Ross},
192
+ booktitle={ICASSP},
193
+ year={2022},
194
+ note={arXiv:2110.01763}
195
+ }
196
+ ```
197
+
198
+ ## License
199
+
200
+ Apache 2.0 — this model and its weights are released under the [Apache License 2.0](https://opensource.org/licenses/Apache-2.0).
201
+
202
+ The frozen [Descript Audio Codec](https://github.com/descriptinc/descript-audio-codec) is downloaded at runtime and carries its own license (MIT).
TECH_REPORT.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:35eac5ff11270f30fc2178c7c470e4a58234d7dc0114dea1fdc578fce822351d
3
+ size 1231121
diamond.json ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "encoder": {
3
+ "n_mels": 80,
4
+ "d_model": 512,
5
+ "n_heads": 8,
6
+ "n_layers": 20,
7
+ "ff_dim": 2048,
8
+ "conv_channels": [
9
+ 512,
10
+ 512
11
+ ],
12
+ "conv_kernel": 3,
13
+ "conv_stride": [
14
+ 1,
15
+ 1
16
+ ],
17
+ "pos_encoding": "rope",
18
+ "norm": "rms",
19
+ "activation": "gelu",
20
+ "dropout": 0.1,
21
+ "bidirectional": true,
22
+ "layer_scale_init": 0.05,
23
+ "rope_learnable": true,
24
+ "qk_norm": true
25
+ },
26
+ "decoder": {
27
+ "d_model": 512,
28
+ "n_heads": 8,
29
+ "n_layers": 20,
30
+ "ff_dim": 2048,
31
+ "n_codebooks": 9,
32
+ "vocab_size": 1024,
33
+ "pad_token_id": 1024,
34
+ "bos_token_id": 1024,
35
+ "pos_encoding": "rope",
36
+ "norm": "rms",
37
+ "activation": "gelu",
38
+ "dropout": 0.1,
39
+ "cross_attn_every_layer": true,
40
+ "rope_learnable": true,
41
+ "qk_norm": true,
42
+ "layer_scale_init": 0.05
43
+ },
44
+ "depth": {
45
+ "d_model": 384,
46
+ "n_heads": 6,
47
+ "n_layers": 4,
48
+ "ff_dim": 1536,
49
+ "dropout": 0.1,
50
+ "qk_norm": true,
51
+ "layer_scale_init": 0.05
52
+ },
53
+ "mel": {
54
+ "sample_rate": 24000,
55
+ "n_fft": 1024,
56
+ "hop_length": 280,
57
+ "win_length": 1024,
58
+ "n_mels": 80,
59
+ "fmin": 0,
60
+ "fmax": 8000,
61
+ "log_clamp_db": -80,
62
+ "normalization": "minmax"
63
+ },
64
+ "dac": {
65
+ "model": "44khz",
66
+ "sample_rate": 44100,
67
+ "n_codebooks": 9,
68
+ "vocab_size": 1024,
69
+ "frame_rate": 86.13,
70
+ "checkpoint_path": null
71
+ }
72
+ }
diamond.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6703b9dc88844722e45980e26b06a35f7167bb6d012c3b642dea6f3500bd06f7
3
+ size 666592168
samples/example1_degraded.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b39e5b969cc7ee9f45600d7b33cab00c22db81ce343f6ca5da46f9454864be17
3
+ size 498812
samples/example1_restored.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9bc0c0981c6c6fcd6a6a4ea2472c9c09c4408e1f4456f1f76385ead177afb8ce
3
+ size 916530
samples/example2_degraded.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3fab31faca02e79be0f07ab646dda7d68fb82e53f295509f7b040a55efa015e8
3
+ size 229052
samples/example2_restored.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ddc60a40d86bf5c8fa1a8ffde0aa102a4fda333abc8d12dc46cc564c8f936713
3
+ size 420846
samples/example3_degraded.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3ba005eed89c186ee4cd265959d1db115bd9afd79eec0f3b2794c296fc3a61e2
3
+ size 535484
samples/example3_restored.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e669fdeb47db0bebc8ab54fcac7eb78604688b4c26796aa0b84ee9fd593d10be
3
+ size 983916
samples/example4_degraded.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4bfa561451972f91c339777680123db23b8c2ac18fdc4435d80f711755e14ec9
3
+ size 555884
samples/example4_restored.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4f4e42e41ee2d3f7ca39d1604582bb21dd7138c89024f18ad8ccc9a08a517e09
3
+ size 1021400