Aratako commited on
Commit
2b291ec
·
verified ·
1 Parent(s): fecb8d4

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,7 @@ saved_model/**/* 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
 
 
 
 
 
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
+ assets/architecture.png filter=lfs diff=lfs merge=lfs -text
37
+ assets/codec_firing_examples.png filter=lfs diff=lfs merge=lfs -text
38
+ assets/english_reconstruction.png filter=lfs diff=lfs merge=lfs -text
39
+ assets/multilingual_reconstruction.png filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,227 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ - ja
6
+ - zh
7
+ - multilingual
8
+ datasets:
9
+ - amphion/Emilia-Dataset
10
+ - nvidia/hifitts-2
11
+ - reazon-research/reazonspeech
12
+ - MLCommons/peoples_speech
13
+ - facebook/voxpopuli
14
+ - facebook/multilingual_librispeech
15
+ - facebook/omnilingual-asr-corpus
16
+ - ai4bharat/IndicVoices
17
+ pipeline_tag: audio-to-audio
18
+ tags:
19
+ - audio
20
+ - speech
21
+ - neural-audio-codec
22
+ - speech-tokenizer
23
+ - variable-frame-rate
24
+ - streaming
25
+ - text-to-speech
26
+ ---
27
+
28
+ # RubatoCodec
29
+
30
+ [![Code: GitHub](https://img.shields.io/badge/Code-GitHub-black?logo=github)](https://github.com/third-intelligence/RubatoCodec)
31
+ ![Paper: coming soon](https://img.shields.io/badge/Paper-coming%20soon-lightgrey)
32
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue)](https://www.apache.org/licenses/LICENSE-2.0)
33
+
34
+ RubatoCodec is a neural speech codec that divides speech into a fixed number of
35
+ variable-duration events. Each event carries discrete code indices and an
36
+ explicit duration. Event placement adapts to speech content, while the number of
37
+ events is determined exactly by the utterance length, so the token sequence
38
+ length a speech generator must produce is predictable. A causal decoder renders
39
+ completed events incrementally, which makes the codec suitable for streaming
40
+ text-to-speech.
41
+
42
+ The name comes from the musical term *rubato*: local timing flexes while the
43
+ overall tempo is preserved.
44
+
45
+ - **Adaptive Firing with an exact event budget.** Multi-scale latent
46
+ dissimilarity and waveform spectral flux guide cumulative allocation on a
47
+ 50-Hz latent grid. For `T` frames the event count is exactly
48
+ `max(1, min(T, round(0.25 · T)))`, giving 12.5 events/s. No learned boundary
49
+ predictor, boundary labels, or rate loss is used.
50
+ - **Streaming decoding.** Events can be decoded one at a time or in chunks.
51
+ Event-by-event decoding takes about 11 ms per event on an NVIDIA H200, well
52
+ below the ~80 ms of audio each event represents on average.
53
+ - **Hybrid residual quantizer with depth control.** A semantically supervised
54
+ FSQ first layer is followed by 15 DAC-style residual VQ layers, each with
55
+ 4,096 entries. Any prefix depth from 1 to 16 can be decoded, giving code-index
56
+ bitrates of 0.15–2.4 kbit/s plus duration information.
57
+ - **Multilingual.** Trained on approximately 375,000 hours of speech, mostly
58
+ English, Japanese, and Chinese, with 16-kHz input and 44.1-kHz output.
59
+
60
+ ![RubatoCodec architecture](assets/architecture.png)
61
+
62
+ ## Model details
63
+
64
+ | | |
65
+ |---|---|
66
+ | Input / output sample rate | 16 kHz / 44.1 kHz |
67
+ | Latent grid | 50 Hz |
68
+ | Event rate | 12.5 events/s (retention ratio 0.25) |
69
+ | Quantizer | 16 layers × 4,096 entries; layer 0 FSQ with semantic distillation, layers 1–15 residual VQ |
70
+ | Bitrate | 1.23 kbit/s at depth 8, 2.43 kbit/s at depth 16 (LibriSpeech, including duration information) |
71
+ | Decoder | Fully causal Transformer + ISTFT head, streaming capable |
72
+ | Parameters | 246M codec (72M encoder, 173M decoder, 1M quantizer) + frozen [w2v-BERT 2.0](https://huggingface.co/facebook/w2v-bert-2.0) (580M, encoding only) |
73
+ | License | Apache 2.0 |
74
+
75
+ ## Usage
76
+
77
+ Install the package from the [GitHub repository](https://github.com/third-intelligence/RubatoCodec):
78
+
79
+ ```bash
80
+ git clone https://github.com/third-intelligence/RubatoCodec
81
+ cd RubatoCodec
82
+ uv sync
83
+ ```
84
+
85
+ Encode and decode:
86
+
87
+ ```python
88
+ import soundfile as sf
89
+ import torch
90
+
91
+ from rubatocodec import RubatoCodec
92
+
93
+ codec = RubatoCodec.from_pretrained("third-intelligence/RubatoCodec", device="cuda")
94
+
95
+ data, sr = sf.read("speech.wav", dtype="float32") # mono waveform
96
+ wav = torch.from_numpy(data)
97
+
98
+ enc = codec.encode(wav, sr=sr) # {"codes": (16, K) int64, "durs": (K,) int64}
99
+ audio = codec.decode(enc) # (1, 1, T_audio) at 44.1 kHz, full depth
100
+ audio = codec.decode(enc, depth=8) # lower bitrate with the first 8 layers
101
+
102
+ sf.write("recon.wav", audio[0, 0].cpu().numpy(), codec.output_sr)
103
+ ```
104
+
105
+ `durs` gives each event's duration in 20-ms grid frames. Loading also downloads
106
+ `facebook/w2v-bert-2.0`, which is used only for encoding.
107
+
108
+ Streaming decoding, inference settings, the code format, and training are
109
+ documented in the repository:
110
+ [inference guide](https://github.com/third-intelligence/RubatoCodec/blob/main/docs/inference.md),
111
+ [architecture](https://github.com/third-intelligence/RubatoCodec/blob/main/docs/architecture.md),
112
+ [training](https://github.com/third-intelligence/RubatoCodec/blob/main/docs/training.md).
113
+
114
+ ## Evaluation
115
+
116
+ RubatoCodec is evaluated on LibriSpeech test-clean, VCTK, JVS nonpara30, JVNV,
117
+ and seed-tts-eval test-zh against 13 other codecs. At comparable bitrates, it
118
+ shows the best intelligibility preservation among the compared codecs on the
119
+ English and Japanese benchmarks and high predicted quality, while the strongest
120
+ comparators achieve higher PESQ-WB and STOI.
121
+
122
+ dWER/dCER compare ASR transcripts of the reconstructed and original audio
123
+ (Whisper-large-v3 for English and Japanese, Paraformer-zh for Mandarin). SIM is
124
+ ECAPA-TDNN speaker similarity. Bitrates include duration information.
125
+
126
+ The tables below show a subset of the compared codecs. **Bold** and
127
+ <ins>underline</ins> mark the best and second-best scores within each bitrate
128
+ band.
129
+
130
+ **LibriSpeech test-clean (English)**
131
+
132
+ | Codec | Event rate (Hz) | Bitrate (kbit/s) | UTMOSv2 ↑ | DNSMOS ↑ | PESQ-WB ↑ | STOI ↑ | dWER (%) ↓ | SIM ↑ |
133
+ |---|---:|---:|---:|---:|---:|---:|---:|---:|
134
+ | *~1.2 kbit/s* | | | | | | | | |
135
+ | FlexiCodec, τ=1, depth 8 | 12.5 | 1.24 | 3.194 | 3.284 | 2.813 | 0.940 | <ins>0.83</ins> | 0.805 |
136
+ | MiMo-Audio-Tokenizer, depth 6 | 25.0 | 1.20 | 3.183 | 3.291 | 2.677 | 0.927 | 0.86 | <ins>0.879</ins> |
137
+ | MOSS-Audio-Tokenizer, depth 10 | 12.5 | 1.25 | 3.230 | 3.217 | **3.052** | **0.949** | 0.89 | **0.885** |
138
+ | DTM-Codec, 80-Hz target | 81.5 | 1.28 | <ins>3.421</ins> | **3.334** | <ins>2.971</ins> | <ins>0.947</ins> | 1.41 | 0.845 |
139
+ | **RubatoCodec, depth 8** | 12.5 | 1.23 | **3.478** | <ins>3.327</ins> | 2.684 | 0.931 | **0.75** | 0.862 |
140
+ | *~2.4 kbit/s* | | | | | | | | |
141
+ | Qwen3-TTS-Tokenizer-12Hz | 12.5 | 2.20 | 3.230 | 3.273 | <ins>3.177</ins> | <ins>0.958</ins> | <ins>0.53</ins> | 0.931 |
142
+ | MiMo-Audio-Tokenizer, depth 13 | 25.0 | 2.42 | 3.210 | <ins>3.288</ins> | 3.094 | 0.947 | 0.67 | <ins>0.933</ins> |
143
+ | MOSS-Audio-Tokenizer, depth 20 | 12.5 | 2.50 | <ins>3.239</ins> | 3.203 | **3.536** | **0.968** | 0.62 | **0.943** |
144
+ | **RubatoCodec, depth 16** | 12.5 | 2.43 | **3.486** | **3.314** | 3.029 | 0.950 | **0.50** | 0.920 |
145
+
146
+ **JVNV (Japanese emotional speech with nonverbal vocalizations)**
147
+
148
+ On expressive speech, RubatoCodec keeps dCER below 2% at both bitrates, while
149
+ every other compared codec exceeds 3%.
150
+
151
+ | Codec | Event rate (Hz) | Bitrate (kbit/s) | UTMOSv2 ↑ | DNSMOS ↑ | PESQ-WB ↑ | STOI ↑ | dCER (%) ↓ | SIM ↑ |
152
+ |---|---:|---:|---:|---:|---:|---:|---:|---:|
153
+ | *~1.2 kbit/s* | | | | | | | | |
154
+ | FlexiCodec, τ=1, depth 8 | 12.5 | 1.24 | 1.811 | 3.128 | 2.062 | 0.862 | 5.52 | 0.771 |
155
+ | MiMo-Audio-Tokenizer, depth 6 | 25.0 | 1.20 | **2.681** | **3.173** | 2.295 | 0.872 | 7.88 | 0.860 |
156
+ | MOSS-Audio-Tokenizer, depth 10 | 12.5 | 1.25 | 2.396 | 3.089 | **3.032** | **0.917** | <ins>5.44</ins> | **0.909** |
157
+ | DTM-Codec, 80-Hz target | 46.1 | 0.77 | 2.523 | 3.154 | 2.081 | 0.862 | 14.82 | 0.783 |
158
+ | **RubatoCodec, depth 8** | 12.5 | 1.23 | <ins>2.628</ins> | <ins>3.164</ins> | <ins>2.650</ins> | <ins>0.907</ins> | **1.92** | <ins>0.903</ins> |
159
+ | *~2.4 kbit/s* | | | | | | | | |
160
+ | Qwen3-TTS-Tokenizer-12Hz | 12.5 | 2.20 | 2.638 | 3.097 | <ins>3.041</ins> | <ins>0.931</ins> | <ins>3.01</ins> | <ins>0.945</ins> |
161
+ | MiMo-Audio-Tokenizer, depth 13 | 25.0 | 2.42 | **2.708** | **3.176** | 2.949 | 0.911 | 4.21 | 0.927 |
162
+ | MOSS-Audio-Tokenizer, depth 20 | 12.5 | 2.50 | 2.383 | 3.057 | **3.496** | **0.941** | 3.96 | **0.953** |
163
+ | **RubatoCodec, depth 16** | 12.5 | 2.43 | <ins>2.651</ins> | <ins>3.138</ins> | 3.032 | 0.929 | **1.54** | 0.941 |
164
+
165
+ **Quality versus bitrate** (RubatoCodec is marked with a red star)
166
+
167
+ ![English reconstruction versus bitrate](assets/english_reconstruction.png)
168
+
169
+ ![Japanese and Mandarin reconstruction versus bitrate](assets/multilingual_reconstruction.png)
170
+
171
+ **Adaptive event placement.** Each rectangle in the lower strip is one event.
172
+ Longer events cover pauses and low-energy regions, while speech receives
173
+ shorter events, with the same 12.5 events/s budget in every utterance.
174
+
175
+ ![Adaptive event placement on English, Japanese, and Mandarin speech](assets/codec_firing_examples.png)
176
+
177
+ The full protocol, all compared codecs and operating points, and throughput
178
+ measurements are in the
179
+ [evaluation document](https://github.com/third-intelligence/RubatoCodec/blob/main/docs/evaluation.md)
180
+ and the paper.
181
+
182
+ ## Training data
183
+
184
+ Approximately 375,000 hours of public and internal speech. Public sources include
185
+ [Emilia-YODAS](https://huggingface.co/datasets/amphion/Emilia-Dataset),
186
+ [HiFiTTS-2](https://huggingface.co/datasets/nvidia/hifitts-2) (44-kHz subset),
187
+ [ReazonSpeech](https://huggingface.co/datasets/reazon-research/reazonspeech),
188
+ [The People's Speech](https://huggingface.co/datasets/MLCommons/peoples_speech)
189
+ (excluding ShareAlike-licensed data),
190
+ [VoxPopuli](https://huggingface.co/datasets/facebook/voxpopuli),
191
+ [Multilingual LibriSpeech](https://huggingface.co/datasets/facebook/multilingual_librispeech)
192
+ (excluding English),
193
+ [Omnilingual ASR Corpus](https://huggingface.co/datasets/facebook/omnilingual-asr-corpus),
194
+ and [IndicVoices](https://huggingface.co/datasets/ai4bharat/IndicVoices). English, Japanese,
195
+ and Chinese account for approximately 44%, 27%, and 13% of the data, and other
196
+ languages for the remaining 16%.
197
+
198
+ ## Limitations
199
+
200
+ - RubatoCodec is trained on speech only and is intended for speech. It is not
201
+ designed for music or general audio.
202
+ - Encoding requires the whole utterance, because the event budget is defined at
203
+ the utterance level. Only decoding is streaming.
204
+ - Signal-fidelity metrics (PESQ-WB, STOI) are below those of the strongest
205
+ compared codecs at similar bitrates.
206
+ - Evaluation covers English, Japanese, and Mandarin, all of which appear in the
207
+ training data. Performance on other languages has not been evaluated.
208
+ - Like other speech codecs, RubatoCodec can be used in speech generation systems
209
+ capable of voice cloning. Do not use it to impersonate people or to create
210
+ deceptive content without consent.
211
+
212
+ ## Acknowledgements
213
+
214
+ RubatoCodec builds on [X-Codec-2.0](https://github.com/zhenye234/X-Codec-2.0)
215
+ and uses [w2v-BERT 2.0](https://huggingface.co/facebook/w2v-bert-2.0) as its
216
+ frozen semantic encoder. It also adapts components from
217
+ [BigCodec](https://github.com/Aria-K-Alethia/BigCodec),
218
+ [DAC](https://github.com/descriptinc/descript-audio-codec),
219
+ [Inworld TTS](https://github.com/inworld-ai/tts), and
220
+ [BigVGAN](https://github.com/NVIDIA/BigVGAN). See the repository for the full
221
+ list and their licenses.
222
+
223
+ ## License
224
+
225
+ The model weights and code are released under the
226
+ [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0). Third-party
227
+ components retain their respective licenses.
assets/architecture.png ADDED

Git LFS Details

  • SHA256: 96b1effd1ab479d4e964fff161028ea8d0b20a15b48164025a3f3ea059113209
  • Pointer size: 131 Bytes
  • Size of remote file: 311 kB
assets/codec_firing_examples.png ADDED

Git LFS Details

  • SHA256: c3a8ff7c33ca6b35126ce36502f226d2f414e45fd8fb45a91fee7fa8949ddb4d
  • Pointer size: 131 Bytes
  • Size of remote file: 477 kB
assets/english_reconstruction.png ADDED

Git LFS Details

  • SHA256: 5a949195c32ee18e4ac27d6730f4cf3d508ece93ab4e878af16c0f7597b12599
  • Pointer size: 131 Bytes
  • Size of remote file: 156 kB
assets/multilingual_reconstruction.png ADDED

Git LFS Details

  • SHA256: e2df2fc430a26f2027cba67815355c84e45340d83727c333075fc6f055a53af8
  • Pointer size: 131 Bytes
  • Size of remote file: 215 kB
config.json ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "semantic_model": "facebook/w2v-bert-2.0",
3
+ "semantic_layer_index": 16,
4
+ "sr": 16000,
5
+ "output_sr": 44100,
6
+ "codec_encoder": {
7
+ "ngf": 48,
8
+ "hidden_dim": 1024,
9
+ "up_ratios": [
10
+ 2,
11
+ 2,
12
+ 4,
13
+ 4,
14
+ 5
15
+ ],
16
+ "dilations": [
17
+ 1,
18
+ 3,
19
+ 9
20
+ ],
21
+ "activation": "snake_beta"
22
+ },
23
+ "codec_decoder": {
24
+ "hidden_dim": 1024,
25
+ "activation": "snake_beta",
26
+ "conv_padding_mode": "causal_full",
27
+ "resnet_kernel_size": 1,
28
+ "embed_kernel_size": 3,
29
+ "depth": 12,
30
+ "heads": 16,
31
+ "pos_emb_dim": 64,
32
+ "vq_dim": 2048,
33
+ "attn_causal": true,
34
+ "mlp_expansion": 4,
35
+ "upsampler_factors": [
36
+ 3
37
+ ],
38
+ "upsampler_kernel_sizes": [
39
+ 9
40
+ ],
41
+ "output_n_fft": 1176,
42
+ "output_hop_length": 294,
43
+ "quantizer": {
44
+ "mode": "rvq",
45
+ "num_quantizers": 16,
46
+ "codebook_size": 4096,
47
+ "fsq_levels": [
48
+ 8,
49
+ 8,
50
+ 8,
51
+ 8
52
+ ],
53
+ "cb1_type": "fsq",
54
+ "residual_type": "vq",
55
+ "vq_codebook_dim": 8
56
+ }
57
+ },
58
+ "firing": {
59
+ "enabled": true,
60
+ "mode": "adaptive",
61
+ "target_ratio": 0.25,
62
+ "max_gap": 64,
63
+ "decision": "clock",
64
+ "hnet_ms_offsets": [
65
+ [
66
+ 1,
67
+ 0
68
+ ],
69
+ [
70
+ 1,
71
+ 1
72
+ ],
73
+ [
74
+ 2,
75
+ 1
76
+ ]
77
+ ],
78
+ "head_in_budget": true,
79
+ "aggregate": "mean",
80
+ "signals": [
81
+ "hnet_ms",
82
+ "flux"
83
+ ]
84
+ },
85
+ "inference": {
86
+ "attention_window_seconds": 6.0,
87
+ "decode_window_frames": 300,
88
+ "decode_stride_frames": 100,
89
+ "decode_crossfade_ms": 10.0
90
+ }
91
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:edaa53e8263134625f69c721ffe168ba15659eefe76fb81f8ce6c755620ccb34
3
+ size 984379032