Feature Extraction
Transformers
Safetensors
moss-audio-tokenizer
audio
audio-tokenizer
neural-codec
moss-tts-family
MOSS Audio Tokenizer
speech-tokenizer
trust-remote-code
custom_code
Instructions to use frepresent/MOSS-Audio-Tokenizer-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use frepresent/MOSS-Audio-Tokenizer-v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="frepresent/MOSS-Audio-Tokenizer-v2", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("frepresent/MOSS-Audio-Tokenizer-v2", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Commit ·
87350fc
0
Parent(s):
Duplicate from OpenMOSS-Team/MOSS-Audio-Tokenizer-v2
Browse filesCo-authored-by: yitian gong <fdugyt@users.noreply.huggingface.co>
- .gitattributes +49 -0
- .gitignore +3 -0
- LICENSE +201 -0
- README.md +221 -0
- __init__.py +1 -0
- config.json +415 -0
- configuration_moss_audio_tokenizer.py +475 -0
- demo/demo_gt.wav +3 -0
- images/arch.png +3 -0
- images/metric.png +3 -0
- model-00001-of-00003.safetensors +3 -0
- model-00002-of-00003.safetensors +3 -0
- model-00003-of-00003.safetensors +3 -0
- model.safetensors.index.json +0 -0
- modeling_moss_audio_tokenizer.py +0 -0
.gitattributes
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.bz2 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 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.db* filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.ark* filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
**/*ckpt*data* filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
**/*ckpt*.meta filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
**/*ckpt*.index filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*.gguf* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
*.ggml filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
*.llamafile* filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
*.pt2 filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 43 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 44 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
| 45 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 46 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 47 |
+
*.wav filter=lfs diff=lfs merge=lfs -text
|
| 48 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 49 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
dev/*
|
| 2 |
+
demo/demo_rec*.wav
|
| 3 |
+
__pycache__
|
LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Apache License
|
| 2 |
+
Version 2.0, January 2004
|
| 3 |
+
http://www.apache.org/licenses/
|
| 4 |
+
|
| 5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 6 |
+
|
| 7 |
+
1. Definitions.
|
| 8 |
+
|
| 9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 11 |
+
|
| 12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 13 |
+
the copyright owner that is granting the License.
|
| 14 |
+
|
| 15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 16 |
+
other entities that control, are controlled by, or are under common
|
| 17 |
+
control with that entity. For the purposes of this definition,
|
| 18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 19 |
+
direction or management of such entity, whether by contract or
|
| 20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 22 |
+
|
| 23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 24 |
+
exercising permissions granted by this License.
|
| 25 |
+
|
| 26 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 27 |
+
including but not limited to software source code, documentation
|
| 28 |
+
source, and configuration files.
|
| 29 |
+
|
| 30 |
+
"Object" form shall mean any form resulting from mechanical
|
| 31 |
+
transformation or translation of a Source form, including but
|
| 32 |
+
not limited to compiled object code, generated documentation,
|
| 33 |
+
and conversions to other media types.
|
| 34 |
+
|
| 35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 36 |
+
Object form, made available under the License, as indicated by a
|
| 37 |
+
copyright notice that is included in or attached to the work
|
| 38 |
+
(an example is provided in the Appendix below).
|
| 39 |
+
|
| 40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 41 |
+
form, that is based on (or derived from) the Work and for which the
|
| 42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 44 |
+
of this License, Derivative Works shall not include works that remain
|
| 45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 46 |
+
the Work and Derivative Works thereof.
|
| 47 |
+
|
| 48 |
+
"Contribution" shall mean any work of authorship, including
|
| 49 |
+
the original version of the Work and any modifications or additions
|
| 50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 54 |
+
means any form of electronic, verbal, or written communication sent
|
| 55 |
+
to the Licensor or its representatives, including but not limited to
|
| 56 |
+
communication on electronic mailing lists, source code control systems,
|
| 57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 59 |
+
excluding communication that is conspicuously marked or otherwise
|
| 60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 61 |
+
|
| 62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 64 |
+
subsequently incorporated within the Work.
|
| 65 |
+
|
| 66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 71 |
+
Work and such Derivative Works in Source or Object form.
|
| 72 |
+
|
| 73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 76 |
+
(except as stated in this section) patent license to make, have made,
|
| 77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 78 |
+
where such license applies only to those patent claims licensable
|
| 79 |
+
by such Contributor that are necessarily infringed by their
|
| 80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 82 |
+
institute patent litigation against any entity (including a
|
| 83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 84 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 85 |
+
or contributory patent infringement, then any patent licenses
|
| 86 |
+
granted to You under this License for that Work shall terminate
|
| 87 |
+
as of the date such litigation is filed.
|
| 88 |
+
|
| 89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 90 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 91 |
+
modifications, and in Source or Object form, provided that You
|
| 92 |
+
meet the following conditions:
|
| 93 |
+
|
| 94 |
+
(a) You must give any other recipients of the Work or
|
| 95 |
+
Derivative Works a copy of this License; and
|
| 96 |
+
|
| 97 |
+
(b) You must cause any modified files to carry prominent notices
|
| 98 |
+
stating that You changed the files; and
|
| 99 |
+
|
| 100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 101 |
+
that You distribute, all copyright, patent, trademark, and
|
| 102 |
+
attribution notices from the Source form of the Work,
|
| 103 |
+
excluding those notices that do not pertain to any part of
|
| 104 |
+
the Derivative Works; and
|
| 105 |
+
|
| 106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 107 |
+
distribution, then any Derivative Works that You distribute must
|
| 108 |
+
include a readable copy of the attribution notices contained
|
| 109 |
+
within such NOTICE file, excluding those notices that do not
|
| 110 |
+
pertain to any part of the Derivative Works, in at least one
|
| 111 |
+
of the following places: within a NOTICE text file distributed
|
| 112 |
+
as part of the Derivative Works; within the Source form or
|
| 113 |
+
documentation, if provided along with the Derivative Works; or,
|
| 114 |
+
within a display generated by the Derivative Works, if and
|
| 115 |
+
wherever such third-party notices normally appear. The contents
|
| 116 |
+
of the NOTICE file are for informational purposes only and
|
| 117 |
+
do not modify the License. You may add Your own attribution
|
| 118 |
+
notices within Derivative Works that You distribute, alongside
|
| 119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 120 |
+
that such additional attribution notices cannot be construed
|
| 121 |
+
as modifying the License.
|
| 122 |
+
|
| 123 |
+
You may add Your own copyright statement to Your modifications and
|
| 124 |
+
may provide additional or different license terms and conditions
|
| 125 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 126 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 127 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 128 |
+
the conditions stated in this License.
|
| 129 |
+
|
| 130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 132 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 133 |
+
this License, without any additional terms or conditions.
|
| 134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 135 |
+
the terms of any separate license agreement you may have executed
|
| 136 |
+
with Licensor regarding such Contributions.
|
| 137 |
+
|
| 138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 140 |
+
except as required for reasonable and customary use in describing the
|
| 141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 142 |
+
|
| 143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 144 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 147 |
+
implied, including, without limitation, any warranties or conditions
|
| 148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 150 |
+
appropriateness of using or redistributing the Work and assume any
|
| 151 |
+
risks associated with Your exercise of permissions under this License.
|
| 152 |
+
|
| 153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 154 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 155 |
+
unless required by applicable law (such as deliberate and grossly
|
| 156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 157 |
+
liable to You for damages, including any direct, indirect, special,
|
| 158 |
+
incidental, or consequential damages of any character arising as a
|
| 159 |
+
result of this License or out of the use or inability to use the
|
| 160 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 161 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 162 |
+
other commercial damages or losses), even if such Contributor
|
| 163 |
+
has been advised of the possibility of such damages.
|
| 164 |
+
|
| 165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 168 |
+
or other liability obligations and/or rights consistent with this
|
| 169 |
+
License. However, in accepting such obligations, You may act only
|
| 170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 171 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 172 |
+
defend, and hold each Contributor harmless for any liability
|
| 173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 174 |
+
of your accepting any such warranty or additional liability.
|
| 175 |
+
|
| 176 |
+
END OF TERMS AND CONDITIONS
|
| 177 |
+
|
| 178 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 179 |
+
|
| 180 |
+
To apply the Apache License to your work, attach the following
|
| 181 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 182 |
+
replaced with your own identifying information. (Don't include
|
| 183 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 184 |
+
comment syntax for the file format. We also recommend that a
|
| 185 |
+
file or class name and description of purpose be included on the
|
| 186 |
+
same "printed page" as the copyright notice for easier
|
| 187 |
+
identification within third-party archives.
|
| 188 |
+
|
| 189 |
+
Copyright [yyyy] [name of copyright owner]
|
| 190 |
+
|
| 191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 192 |
+
you may not use this file except in compliance with the License.
|
| 193 |
+
You may obtain a copy of the License at
|
| 194 |
+
|
| 195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 196 |
+
|
| 197 |
+
Unless required by applicable law or agreed to in writing, software
|
| 198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 200 |
+
See the License for the specific language governing permissions and
|
| 201 |
+
limitations under the License.
|
README.md
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
library_name: transformers
|
| 4 |
+
tags:
|
| 5 |
+
- audio
|
| 6 |
+
- audio-tokenizer
|
| 7 |
+
- neural-codec
|
| 8 |
+
- moss-tts-family
|
| 9 |
+
- MOSS Audio Tokenizer
|
| 10 |
+
- speech-tokenizer
|
| 11 |
+
- trust-remote-code
|
| 12 |
+
- arxiv:2602.10934
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# MOSS-Audio-Tokenizer-v2
|
| 16 |
+
|
| 17 |
+
This is the code for the 48khz stereo version of MOSS-Audio-Tokenizer presented in [MOSS-Audio-Tokenizer: Scaling Audio Tokenizers for Future Audio Foundation Models](https://arxiv.org/abs/2602.10934).
|
| 18 |
+
|
| 19 |
+
**MOSS-Audio-Tokenizer-v2** is a unified discrete audio tokenizer based on the **Cat** (**C**ausal **A**udio **T**okenizer with **T**ransformer) architecture. Scaling to 2 billion parameters, it functions as a unified discrete interface, delivering both lossless-quality reconstruction and high-level semantic alignment.
|
| 20 |
+
|
| 21 |
+
**Key Features:**
|
| 22 |
+
|
| 23 |
+
* **Extreme Compression & Variable Bitrate**: It compresses 48kHz stereo audio into a remarkably low frame rate of 12.5Hz. Utilizing a 32-layer Residual Vector Quantization stack, it supports high-fidelity reconstruction across a wide range of bitrates.
|
| 24 |
+
* **Pure Transformer Architecture**: The model features a "CNN-free" homogeneous architecture built entirely from Causal Transformer blocks. With 2B combined parameters (Encoder + Decoder), it ensures exceptional scalability and supports low-latency streaming inference.
|
| 25 |
+
* **Large-Scale General Audio Training**: Trained on 3 million hours of diverse audio data, the model excels at encoding and reconstructing all audio domains, including speech, sound effects, and music.
|
| 26 |
+
* **Unified Semantic-Acoustic Representation**: While achieving state-of-the-art reconstruction quality, Cat produces discrete tokens that are "semantic-rich," making them ideal for downstream tasks like speech understanding (ASR) and generation (TTS).
|
| 27 |
+
* **Fully Trained From Scratch**: Cat does not rely on any pretrained encoders (such as HuBERT or Whisper) or distillation from teacher models. All representations are learned autonomously from raw data.
|
| 28 |
+
* **End-to-End Joint Optimization**: All components—including the encoder, quantizer, decoder, discriminator, and a decoder-only LLM for semantic alignment—are optimized jointly in a single unified training pipeline.
|
| 29 |
+
|
| 30 |
+
**Summary:**
|
| 31 |
+
By combining a simple, scalable architecture with massive-scale data, the Cat architecture overcomes the bottlenecks of traditional audio tokenizers. It provides a robust, high-fidelity, and semantically grounded interface for the next generation of native audio foundation models.
|
| 32 |
+
|
| 33 |
+
This repository contains a lightweight remote-code implementation that mirrors the current 🤗 Transformers
|
| 34 |
+
`transformers.models.moss_audio_tokenizer` module. It is hosted as a Hugging Face Hub model repository and should be
|
| 35 |
+
loaded with `trust_remote_code=True`.
|
| 36 |
+
|
| 37 |
+
<br>
|
| 38 |
+
<p align="center">
|
| 39 |
+
<img src="images/arch.png" width="95%"> <br>
|
| 40 |
+
Architecture of MossAudioTokenizer
|
| 41 |
+
</p>
|
| 42 |
+
<br>
|
| 43 |
+
|
| 44 |
+
## Usage
|
| 45 |
+
|
| 46 |
+
### Quickstart
|
| 47 |
+
|
| 48 |
+
```python
|
| 49 |
+
import torch
|
| 50 |
+
from transformers import AutoModel
|
| 51 |
+
import torchaudio
|
| 52 |
+
|
| 53 |
+
repo_id = "OpenMOSS-Team/MOSS-Audio-Tokenizer-v2"
|
| 54 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 55 |
+
model = AutoModel.from_pretrained(repo_id, trust_remote_code=True).eval().to(device)
|
| 56 |
+
|
| 57 |
+
audio_path = "demo/demo_gt.wav" # replace with your own 48 kHz stereo audio path if needed
|
| 58 |
+
wav, sr = torchaudio.load(audio_path)
|
| 59 |
+
if sr != model.sampling_rate:
|
| 60 |
+
wav = torchaudio.functional.resample(wav, sr, model.sampling_rate)
|
| 61 |
+
if wav.shape[0] == 1:
|
| 62 |
+
wav = wav.repeat(model.config.number_channels, 1)
|
| 63 |
+
else:
|
| 64 |
+
wav = wav[: model.config.number_channels]
|
| 65 |
+
wav = wav.unsqueeze(0).to(device)
|
| 66 |
+
enc = model.encode(wav, return_dict=True)
|
| 67 |
+
print(f"enc.audio_codes.shape: {enc.audio_codes.shape}")
|
| 68 |
+
dec = model.decode(enc.audio_codes, return_dict=True)
|
| 69 |
+
print(f"dec.audio.shape: {dec.audio.shape}")
|
| 70 |
+
wav = dec.audio.squeeze(0)
|
| 71 |
+
torchaudio.save("demo/demo_rec.wav", wav.cpu(), sample_rate=model.sampling_rate)
|
| 72 |
+
|
| 73 |
+
# Decode using only the first 8 layers of the RVQ
|
| 74 |
+
dec_rvq8 = model.decode(enc.audio_codes[:8], return_dict=True)
|
| 75 |
+
wav_rvq8 = dec_rvq8.audio.squeeze(0)
|
| 76 |
+
torchaudio.save("demo/demo_rec_rvq8.wav", wav_rvq8.cpu(), sample_rate=model.sampling_rate)
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
For production use with `trust_remote_code=True`, pin `revision` to a reviewed commit hash.
|
| 80 |
+
|
| 81 |
+
### Attention Backend And Compute Dtype
|
| 82 |
+
|
| 83 |
+
`config.attention_implementation` controls whether transformer layers prefer `sdpa` or `flash_attention_2`.
|
| 84 |
+
`config.compute_dtype` controls the non-quantizer autocast dtype and supports `fp32`, `bf16`.
|
| 85 |
+
`config.codec_weight_dtype` controls encoder/decoder parameter dtype and defaults to `fp32`.
|
| 86 |
+
The quantizer is always kept in fp32.
|
| 87 |
+
|
| 88 |
+
GPU bf16 loading:
|
| 89 |
+
|
| 90 |
+
```python
|
| 91 |
+
import torch
|
| 92 |
+
from transformers import AutoModel
|
| 93 |
+
|
| 94 |
+
repo_id = "OpenMOSS-Team/MOSS-Audio-Tokenizer-v2"
|
| 95 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 96 |
+
model = AutoModel.from_pretrained(repo_id, trust_remote_code=True, low_cpu_mem_usage=True, codec_weight_dtype="bf16").eval().to(device)
|
| 97 |
+
```
|
| 98 |
+
Passing codec_weight_dtype="bf16" at load time avoids first materializing encoder/decoder weights as fp32 on GPU and then converting them to bf16, which would increase peak GPU memory.
|
| 99 |
+
|
| 100 |
+
You can also switch an already loaded model:
|
| 101 |
+
|
| 102 |
+
```python
|
| 103 |
+
model.set_attention_implementation("flash_attention_2")
|
| 104 |
+
model.set_compute_dtype("bf16")
|
| 105 |
+
model.set_codec_weight_dtype("bf16") # encoder/decoder bf16, quantizer fp32
|
| 106 |
+
```
|
| 107 |
+
|
| 108 |
+
Avoid calling plain `model.to(torch.bfloat16)` on the whole codec; that also casts quantizer weights and can cause dtype mismatches or serious precision loss.
|
| 109 |
+
|
| 110 |
+
### Streaming
|
| 111 |
+
|
| 112 |
+
`MossAudioTokenizerModel.encode`, `decode`, `batch_encode`, and `batch_decode` all support streaming through a
|
| 113 |
+
`chunk_duration` argument.
|
| 114 |
+
|
| 115 |
+
- `chunk_duration` is expressed in seconds.
|
| 116 |
+
- `chunk_duration * MossAudioTokenizerConfig.sampling_rate` must be divisible by `MossAudioTokenizerConfig.downsample_rate`.
|
| 117 |
+
- Streaming batch inference is supported.
|
| 118 |
+
- The public waveform interface expects stereo inputs shaped `(2, T)` or batched stereo inputs shaped `(B, 2, T)`.
|
| 119 |
+
|
| 120 |
+
```python
|
| 121 |
+
import torch
|
| 122 |
+
from transformers import AutoModel
|
| 123 |
+
|
| 124 |
+
repo_id = "OpenMOSS-Team/MOSS-Audio-Tokenizer-v2"
|
| 125 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 126 |
+
model = AutoModel.from_pretrained(repo_id, trust_remote_code=True).eval().to(device)
|
| 127 |
+
audio = torch.randn(2, 48000 * 6).to(device) # dummy stereo waveform
|
| 128 |
+
|
| 129 |
+
# 6.0s @ 48kHz = 288000 samples, divisible by downsample_rate=3840
|
| 130 |
+
enc = model.encode(audio.unsqueeze(0), return_dict=True, chunk_duration=0.08)
|
| 131 |
+
dec = model.decode(enc.audio_codes, return_dict=True, chunk_duration=0.08)
|
| 132 |
+
|
| 133 |
+
batch_enc = model.batch_encode([audio, audio[:, : 48000 * 3]], chunk_duration=0.08)
|
| 134 |
+
codes_list = [
|
| 135 |
+
batch_enc.audio_codes[:, i, : batch_enc.audio_codes_lengths[i]]
|
| 136 |
+
for i in range(batch_enc.audio_codes.shape[1])
|
| 137 |
+
]
|
| 138 |
+
batch_dec = model.batch_decode(codes_list, chunk_duration=0.08)
|
| 139 |
+
```
|
| 140 |
+
|
| 141 |
+
## Repository layout
|
| 142 |
+
|
| 143 |
+
- `configuration_moss_audio_tokenizer.py`
|
| 144 |
+
- `modeling_moss_audio_tokenizer.py`
|
| 145 |
+
- `__init__.py`
|
| 146 |
+
- `config.json`
|
| 147 |
+
- `model.safetensors.index.json`
|
| 148 |
+
- sharded model weights: `model-00001-of-00003.safetensors`, `model-00002-of-00003.safetensors`,
|
| 149 |
+
`model-00003-of-00003.safetensors`
|
| 150 |
+
- `demo/demo_gt.wav`
|
| 151 |
+
|
| 152 |
+
## Evaluation Metrics
|
| 153 |
+
|
| 154 |
+
The table below compares the reconstruction quality of open-source audio tokenizers with MOSS-Audio-Tokenizer-v2 on speech and audio/music data.
|
| 155 |
+
|
| 156 |
+
- Speech metrics are evaluated on LibriSpeech test-clean (English) and AISHELL-2 (Chinese), reported as EN/ZH.
|
| 157 |
+
- Audio metrics are evaluated on the AudioSet evaluation subset, while music metrics are evaluated on MUSDB, reported as audio/music.
|
| 158 |
+
- STFT-Dist. denotes the STFT distance.
|
| 159 |
+
- Higher is better for speech metrics, while lower is better for audio/music metrics (Mel-Loss, STFT-Dist.).
|
| 160 |
+
- Nq denotes the number of quantizers.
|
| 161 |
+
|
| 162 |
+
| Model | bps | Frame rate | Nq | Speech: SIM ↑ (EN/ZH) | Speech: STOI ↑ (EN/ZH) | Speech: PESQ-NB ↑ (EN/ZH) | Speech: PESQ-WB ↑ (EN/ZH) | Audio/Music: Mel-Loss ↓ | Audio/Music: STFT-Dist. ↓ |
|
| 163 |
+
| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
|
| 164 |
+
| **XCodec2.0** | 800 | 50 | 1 | 0.82 / 0.74 | 0.92 / 0.86 | 3.04 / 2.46 | 2.43 / 1.96 | -- / -- | -- / -- |
|
| 165 |
+
| **MiMo Audio Tokenizer** | 850 | 25 | 4 | 0.80 / 0.74 | 0.91 / 0.87 | 2.94 / 2.62 | 2.39 / 2.14 | **0.82** / 0.81 | 2.33 / 2.23 |
|
| 166 |
+
| **Higgs Audio Tokenizer** | 1000 | 25 | 4 | 0.77 / 0.68 | 0.83 / 0.82 | 3.03 / 2.61 | 2.48 / 2.14 | 0.83 / **0.80** | **2.20** / **2.05** |
|
| 167 |
+
| **SpeechTokenizer** | 1000 | 50 | 2 | 0.36 / 0.25 | 0.77 / 0.68 | 1.59 / 1.38 | 1.25 / 1.17 | -- / -- | -- / -- |
|
| 168 |
+
| **XY-Tokenizer** | 1000 | 12.5 | 8 | 0.85 / 0.79 | 0.92 / 0.87 | 3.10 / 2.63 | 2.50 / 2.12 | -- / -- | -- / -- |
|
| 169 |
+
| **BigCodec** | 1040 | 80 | 1 | 0.84 / 0.69 | 0.93 / 0.88 | 3.27 / 2.55 | 2.68 / 2.06 | -- / -- | -- / -- |
|
| 170 |
+
| **Mimi** | 1100 | 12.5 | 8 | 0.74 / 0.59 | 0.91 / 0.85 | 2.80 / 2.24 | 2.25 / 1.78 | 1.24 / 1.19 | 2.62 / 2.49 |
|
| 171 |
+
| **MOSS-Audio-Tokenizer-v2 (Ours)** | 750 | 12.5 | 6 | 0.82 / 0.75 | 0.92 / 0.88 | 3.14 / 2.68 | 2.59 / 2.19 | 0.93 / 0.91 | 2.28 / 2.14 |
|
| 172 |
+
| **MOSS-Audio-Tokenizer-v2 (Ours)** | 1000 | 12.5 | 8 | **0.88** / **0.80** | **0.94** / **0.90** | **3.39** / **2.93** | **2.88** / **2.43** | 0.88 / 0.86 | 2.22 / 2.07 |
|
| 173 |
+
| **—** | **—** | **—** | **—** | **—** | **—** | **—** | **—** | **—** | **—** |
|
| 174 |
+
| **DAC** | 1500 | 75 | 2 | 0.48 / 0.41 | 0.83 / 0.79 | 1.87 / 1.67 | 1.48 / 1.37 | -- / -- | -- / -- |
|
| 175 |
+
| **Encodec** | 1500 | 75 | 2 | 0.60 / 0.45 | 0.85 / 0.81 | 1.94 / 1.80 | 1.56 / 1.48 | 1.12 / 1.04 | 2.60 / 2.42 |
|
| 176 |
+
| **Higgs Audio Tokenizer** | 2000 | 25 | 8 | 0.90 / 0.83 | 0.85 / 0.85 | 3.59 / 3.22 | 3.11 / 2.73 | 0.74 / 0.70 | **2.07** / **1.92** |
|
| 177 |
+
| **SpeechTokenizer** | 2000 | 50 | 4 | 0.66 / 0.50 | 0.88 / 0.80 | 2.38 / 1.79 | 1.92 / 1.49 | -- / -- | -- / -- |
|
| 178 |
+
| **Qwen3 TTS Tokenizer** | 2200 | 12.5 | 16 | **0.95** / 0.88 | **0.96** / 0.93 | 3.66 / 3.10 | 3.19 / 2.62 | -- / -- | -- / -- |
|
| 179 |
+
| **MiMo Audio Tokenizer** | 2250 | 25 | 12 | 0.89 / 0.83 | 0.95 / 0.92 | 3.57 / 3.25 | 3.05 / 2.71 | **0.70** / **0.68** | 2.21 / 2.10 |
|
| 180 |
+
| **Mimi** | 2475 | 12.5 | 18 | 0.89 / 0.76 | 0.94 / 0.91 | 3.49 / 2.90 | 2.97 / 2.35 | 1.10 / 1.06 | 2.45 / 2.32 |
|
| 181 |
+
| **MOSS-Audio-Tokenizer-v2 (Ours)** | 1500 | 12.5 | 12 | 0.93 / 0.86 | 0.95 / 0.92 | 3.66 / 3.24 | 3.23 / 2.77 | 0.83 / 0.79 | 2.15 / 1.98 |
|
| 182 |
+
| **MOSS-Audio-Tokenizer-v2 (Ours)** | 2000 | 12.5 | 16 | **0.95** / **0.89** | **0.96** / **0.94** | **3.80** / **3.44** | **3.45** / **3.01** | 0.79 / 0.75 | 2.10 / 1.93 |
|
| 183 |
+
| **—** | **—** | **—** | **—** | **—** | **—** | **—** | **—** | **—** | **—** |
|
| 184 |
+
| **DAC** | 3000 | 75 | 4 | 0.74 / 0.67 | 0.90 / 0.88 | 2.76 / 2.47 | 2.31 / 2.07 | 0.86 / 0.83 | 2.23 / 2.10 |
|
| 185 |
+
| **MiMo Audio Tokenizer** | 3650 | 25 | 20 | 0.91 / 0.85 | 0.95 / 0.93 | 3.73 / 3.44 | 3.25 / 2.89 | 0.66 / 0.65 | 2.17 / 2.06 |
|
| 186 |
+
| **SpeechTokenizer** | 4000 | 50 | 8 | 0.85 / 0.69 | 0.92 / 0.85 | 3.05 / 2.20 | 2.60 / 1.87 | -- / -- | -- / -- |
|
| 187 |
+
| **Mimi** | 4400 | 12.5 | 32 | 0.94 / 0.83 | 0.96 / 0.94 | 3.80 / 3.31 | 3.43 / 2.78 | 1.02 / 0.98 | 2.34 / 2.21 |
|
| 188 |
+
| **Encodec** | 4500 | 75 | 6 | 0.86 / 0.75 | 0.92 / 0.91 | 2.91 / 2.63 | 2.46 / 2.15 | 0.91 / 0.84 | 2.33 / 2.17 |
|
| 189 |
+
| **DAC** | 6000 | 75 | 8 | 0.89 / 0.84 | 0.95 / 0.94 | 3.75 / 3.57 | 3.41 / 3.20 | **0.65** / **0.63** | **1.97** / 1.87 |
|
| 190 |
+
| **MOSS-Audio-Tokenizer-v2 (Ours)** | 3000 | 12.5 | 24 | 0.96 / 0.92 | **0.97** / 0.95 | 3.94 / 3.64 | 3.66 / 3.28 | 0.75 / 0.71 | 2.04 / 1.87 |
|
| 191 |
+
| **MOSS-Audio-Tokenizer-v2 (Ours)** | 4000 | 12.5 | 32 | **0.97** / **0.93** | **0.97** / **0.96** | **3.98** / **3.72** | **3.75** / **3.39** | 0.73 / 0.69 | 2.02 / **1.84** |
|
| 192 |
+
|
| 193 |
+
### LibriSpeech Speech Metrics (MOSS-Audio-Tokenizer-v2 vs. Open-source Tokenizers)
|
| 194 |
+
|
| 195 |
+
The plots below compare our MOSS-Audio-Tokenizer-v2 model with other open-source speech tokenizers on the LibriSpeech dataset, evaluated with SIM, STOI, PESQ-NB, and PESQ-WB (higher is better).
|
| 196 |
+
We control the bps of the same model by adjusting the number of RVQ codebooks used during inference.
|
| 197 |
+
|
| 198 |
+
<table>
|
| 199 |
+
<tr>
|
| 200 |
+
<td align="center"><br><img src="images/metric.png" width="100%"></td>
|
| 201 |
+
</tr>
|
| 202 |
+
</table>
|
| 203 |
+
|
| 204 |
+
|
| 205 |
+
## Citation
|
| 206 |
+
If you use this code or result in your paper, please cite our work as:
|
| 207 |
+
```tex
|
| 208 |
+
@misc{gong2026mossaudiotokenizerscaling,
|
| 209 |
+
title={MOSS-Audio-Tokenizer: Scaling Audio Tokenizers for Future Audio Foundation Models},
|
| 210 |
+
author={Yitian Gong and Kuangwei Chen and Zhaoye Fei and Xiaogui Yang and Ke Chen and Yang Wang and Kexin Huang and Mingshu Chen and Ruixiao Li and Qingyuan Cheng and Shimin Li and Xipeng Qiu},
|
| 211 |
+
year={2026},
|
| 212 |
+
eprint={2602.10934},
|
| 213 |
+
archivePrefix={arXiv},
|
| 214 |
+
primaryClass={cs.SD},
|
| 215 |
+
url={https://arxiv.org/abs/2602.10934}
|
| 216 |
+
}
|
| 217 |
+
```
|
| 218 |
+
|
| 219 |
+
## License
|
| 220 |
+
MOSS-Audio-Tokenizer-v2 is released under the Apache 2.0 license. See `LICENSE` for the full license text.
|
| 221 |
+
|
__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Remote code package for Moss audio tokenizer."""
|
config.json
ADDED
|
@@ -0,0 +1,415 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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el": "modeling_moss_audio_tokenizer.MossAudioTokenizerModel"
|
| 8 |
+
},
|
| 9 |
+
"model_type": "moss-audio-tokenizer",
|
| 10 |
+
"sample_rate": 48000,
|
| 11 |
+
"sampling_rate": 48000,
|
| 12 |
+
"downsample_rate": 3840,
|
| 13 |
+
"causal_transformer_context_duration": 10.0,
|
| 14 |
+
"number_channels": 2,
|
| 15 |
+
"enable_channel_interleave": true,
|
| 16 |
+
"attention_implementation": "flash_attention_2",
|
| 17 |
+
"compute_dtype": "bf16",
|
| 18 |
+
"dtype": "float32",
|
| 19 |
+
"code_dim": 768,
|
| 20 |
+
"encoder_kwargs": [
|
| 21 |
+
{
|
| 22 |
+
"module_type": "PatchedPretransform",
|
| 23 |
+
"patch_size": 240
|
| 24 |
+
},
|
| 25 |
+
{
|
| 26 |
+
"module_type": "Transformer",
|
| 27 |
+
"input_dimension": 240,
|
| 28 |
+
"output_dimension": 384,
|
| 29 |
+
"d_model": 768,
|
| 30 |
+
"num_heads": 12,
|
| 31 |
+
"num_layers": 12,
|
| 32 |
+
"dim_feedforward": 3072,
|
| 33 |
+
"causal": true,
|
| 34 |
+
"norm": "layer_norm",
|
| 35 |
+
"positional_embedding": "rope",
|
| 36 |
+
"max_period": 10000,
|
| 37 |
+
"gating": "none",
|
| 38 |
+
"layer_scale": 0.01,
|
| 39 |
+
"conv_layout": true,
|
| 40 |
+
"context_duration": 1.0
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"module_type": "PatchedPretransform",
|
| 44 |
+
"patch_size": 2
|
| 45 |
+
},
|
| 46 |
+
{
|
| 47 |
+
"module_type": "Transformer",
|
| 48 |
+
"input_dimension": 768,
|
| 49 |
+
"output_dimension": 384,
|
| 50 |
+
"d_model": 768,
|
| 51 |
+
"num_heads": 12,
|
| 52 |
+
"num_layers": 12,
|
| 53 |
+
"dim_feedforward": 3072,
|
| 54 |
+
"causal": true,
|
| 55 |
+
"norm": "layer_norm",
|
| 56 |
+
"positional_embedding": "rope",
|
| 57 |
+
"max_period": 10000,
|
| 58 |
+
"gating": "none",
|
| 59 |
+
"layer_scale": 0.01,
|
| 60 |
+
"conv_layout": true,
|
| 61 |
+
"context_duration": 2.0
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"module_type": "PatchedPretransform",
|
| 65 |
+
"patch_size": 2
|
| 66 |
+
},
|
| 67 |
+
{
|
| 68 |
+
"module_type": "Transformer",
|
| 69 |
+
"input_dimension": 768,
|
| 70 |
+
"output_dimension": 384,
|
| 71 |
+
"d_model": 768,
|
| 72 |
+
"num_heads": 12,
|
| 73 |
+
"num_layers": 12,
|
| 74 |
+
"dim_feedforward": 3072,
|
| 75 |
+
"causal": true,
|
| 76 |
+
"norm": "layer_norm",
|
| 77 |
+
"positional_embedding": "rope",
|
| 78 |
+
"max_period": 10000,
|
| 79 |
+
"gating": "none",
|
| 80 |
+
"layer_scale": 0.01,
|
| 81 |
+
"conv_layout": true,
|
| 82 |
+
"context_duration": 4.0
|
| 83 |
+
},
|
| 84 |
+
{
|
| 85 |
+
"module_type": "PatchedPretransform",
|
| 86 |
+
"patch_size": 2
|
| 87 |
+
},
|
| 88 |
+
{
|
| 89 |
+
"module_type": "Transformer",
|
| 90 |
+
"input_dimension": 768,
|
| 91 |
+
"output_dimension": 384,
|
| 92 |
+
"d_model": 768,
|
| 93 |
+
"num_heads": 12,
|
| 94 |
+
"num_layers": 12,
|
| 95 |
+
"dim_feedforward": 3072,
|
| 96 |
+
"causal": true,
|
| 97 |
+
"norm": "layer_norm",
|
| 98 |
+
"positional_embedding": "rope",
|
| 99 |
+
"max_period": 10000,
|
| 100 |
+
"gating": "none",
|
| 101 |
+
"layer_scale": 0.01,
|
| 102 |
+
"conv_layout": true,
|
| 103 |
+
"context_duration": 8.0
|
| 104 |
+
},
|
| 105 |
+
{
|
| 106 |
+
"module_type": "PatchedPretransform",
|
| 107 |
+
"patch_size": 2
|
| 108 |
+
},
|
| 109 |
+
{
|
| 110 |
+
"module_type": "Transformer",
|
| 111 |
+
"input_dimension": 768,
|
| 112 |
+
"output_dimension": 640,
|
| 113 |
+
"d_model": 768,
|
| 114 |
+
"num_heads": 12,
|
| 115 |
+
"num_layers": 12,
|
| 116 |
+
"dim_feedforward": 3072,
|
| 117 |
+
"causal": true,
|
| 118 |
+
"norm": "layer_norm",
|
| 119 |
+
"positional_embedding": "rope",
|
| 120 |
+
"max_period": 10000,
|
| 121 |
+
"gating": "none",
|
| 122 |
+
"layer_scale": 0.01,
|
| 123 |
+
"conv_layout": true,
|
| 124 |
+
"context_duration": 10.0
|
| 125 |
+
},
|
| 126 |
+
{
|
| 127 |
+
"module_type": "PatchedPretransform",
|
| 128 |
+
"patch_size": 2
|
| 129 |
+
},
|
| 130 |
+
{
|
| 131 |
+
"module_type": "Transformer",
|
| 132 |
+
"input_dimension": 1280,
|
| 133 |
+
"output_dimension": 768,
|
| 134 |
+
"d_model": 1280,
|
| 135 |
+
"num_heads": 20,
|
| 136 |
+
"num_layers": 32,
|
| 137 |
+
"dim_feedforward": 5120,
|
| 138 |
+
"causal": true,
|
| 139 |
+
"norm": "layer_norm",
|
| 140 |
+
"positional_embedding": "rope",
|
| 141 |
+
"max_period": 10000,
|
| 142 |
+
"gating": "none",
|
| 143 |
+
"layer_scale": 0.01,
|
| 144 |
+
"conv_layout": true,
|
| 145 |
+
"context_duration": 10.0
|
| 146 |
+
}
|
| 147 |
+
],
|
| 148 |
+
"decoder_kwargs": [
|
| 149 |
+
{
|
| 150 |
+
"module_type": "Transformer",
|
| 151 |
+
"input_dimension": 768,
|
| 152 |
+
"output_dimension": 1280,
|
| 153 |
+
"d_model": 1280,
|
| 154 |
+
"num_heads": 20,
|
| 155 |
+
"num_layers": 32,
|
| 156 |
+
"dim_feedforward": 5120,
|
| 157 |
+
"causal": true,
|
| 158 |
+
"norm": "layer_norm",
|
| 159 |
+
"positional_embedding": "rope",
|
| 160 |
+
"max_period": 10000,
|
| 161 |
+
"gating": "none",
|
| 162 |
+
"layer_scale": 0.01,
|
| 163 |
+
"conv_layout": true,
|
| 164 |
+
"context_duration": 10.0
|
| 165 |
+
},
|
| 166 |
+
{
|
| 167 |
+
"module_type": "PatchedPretransform",
|
| 168 |
+
"patch_size": 2
|
| 169 |
+
},
|
| 170 |
+
{
|
| 171 |
+
"module_type": "Transformer",
|
| 172 |
+
"input_dimension": 640,
|
| 173 |
+
"output_dimension": 768,
|
| 174 |
+
"d_model": 768,
|
| 175 |
+
"num_heads": 12,
|
| 176 |
+
"num_layers": 12,
|
| 177 |
+
"dim_feedforward": 3072,
|
| 178 |
+
"causal": true,
|
| 179 |
+
"norm": "layer_norm",
|
| 180 |
+
"positional_embedding": "rope",
|
| 181 |
+
"max_period": 10000,
|
| 182 |
+
"gating": "none",
|
| 183 |
+
"layer_scale": 0.01,
|
| 184 |
+
"conv_layout": true,
|
| 185 |
+
"context_duration": 10.0
|
| 186 |
+
},
|
| 187 |
+
{
|
| 188 |
+
"module_type": "PatchedPretransform",
|
| 189 |
+
"patch_size": 2
|
| 190 |
+
},
|
| 191 |
+
{
|
| 192 |
+
"module_type": "Transformer",
|
| 193 |
+
"input_dimension": 384,
|
| 194 |
+
"output_dimension": 768,
|
| 195 |
+
"d_model": 768,
|
| 196 |
+
"num_heads": 12,
|
| 197 |
+
"num_layers": 12,
|
| 198 |
+
"dim_feedforward": 3072,
|
| 199 |
+
"causal": true,
|
| 200 |
+
"norm": "layer_norm",
|
| 201 |
+
"positional_embedding": "rope",
|
| 202 |
+
"max_period": 10000,
|
| 203 |
+
"gating": "none",
|
| 204 |
+
"layer_scale": 0.01,
|
| 205 |
+
"conv_layout": true,
|
| 206 |
+
"context_duration": 8.0
|
| 207 |
+
},
|
| 208 |
+
{
|
| 209 |
+
"module_type": "PatchedPretransform",
|
| 210 |
+
"patch_size": 2
|
| 211 |
+
},
|
| 212 |
+
{
|
| 213 |
+
"module_type": "Transformer",
|
| 214 |
+
"input_dimension": 384,
|
| 215 |
+
"output_dimension": 768,
|
| 216 |
+
"d_model": 768,
|
| 217 |
+
"num_heads": 12,
|
| 218 |
+
"num_layers": 12,
|
| 219 |
+
"dim_feedforward": 3072,
|
| 220 |
+
"causal": true,
|
| 221 |
+
"norm": "layer_norm",
|
| 222 |
+
"positional_embedding": "rope",
|
| 223 |
+
"max_period": 10000,
|
| 224 |
+
"gating": "none",
|
| 225 |
+
"layer_scale": 0.01,
|
| 226 |
+
"conv_layout": true,
|
| 227 |
+
"context_duration": 4.0
|
| 228 |
+
},
|
| 229 |
+
{
|
| 230 |
+
"module_type": "PatchedPretransform",
|
| 231 |
+
"patch_size": 2
|
| 232 |
+
},
|
| 233 |
+
{
|
| 234 |
+
"module_type": "Transformer",
|
| 235 |
+
"input_dimension": 384,
|
| 236 |
+
"output_dimension": 768,
|
| 237 |
+
"d_model": 768,
|
| 238 |
+
"num_heads": 12,
|
| 239 |
+
"num_layers": 12,
|
| 240 |
+
"dim_feedforward": 3072,
|
| 241 |
+
"causal": true,
|
| 242 |
+
"norm": "layer_norm",
|
| 243 |
+
"positional_embedding": "rope",
|
| 244 |
+
"max_period": 10000,
|
| 245 |
+
"gating": "none",
|
| 246 |
+
"layer_scale": 0.01,
|
| 247 |
+
"conv_layout": true,
|
| 248 |
+
"context_duration": 2.0
|
| 249 |
+
},
|
| 250 |
+
{
|
| 251 |
+
"module_type": "PatchedPretransform",
|
| 252 |
+
"patch_size": 2
|
| 253 |
+
},
|
| 254 |
+
{
|
| 255 |
+
"module_type": "Transformer",
|
| 256 |
+
"input_dimension": 384,
|
| 257 |
+
"output_dimension": 240,
|
| 258 |
+
"d_model": 768,
|
| 259 |
+
"num_heads": 12,
|
| 260 |
+
"num_layers": 12,
|
| 261 |
+
"dim_feedforward": 3072,
|
| 262 |
+
"causal": true,
|
| 263 |
+
"norm": "layer_norm",
|
| 264 |
+
"positional_embedding": "rope",
|
| 265 |
+
"max_period": 10000,
|
| 266 |
+
"gating": "none",
|
| 267 |
+
"layer_scale": 0.01,
|
| 268 |
+
"conv_layout": true,
|
| 269 |
+
"context_duration": 1.0
|
| 270 |
+
},
|
| 271 |
+
{
|
| 272 |
+
"module_type": "PatchedPretransform",
|
| 273 |
+
"patch_size": 240
|
| 274 |
+
}
|
| 275 |
+
],
|
| 276 |
+
"reversed_decoder_kwargs": [
|
| 277 |
+
{
|
| 278 |
+
"module_type": "PatchedPretransform",
|
| 279 |
+
"patch_size": 240
|
| 280 |
+
},
|
| 281 |
+
{
|
| 282 |
+
"module_type": "Transformer",
|
| 283 |
+
"input_dimension": 240,
|
| 284 |
+
"output_dimension": 384,
|
| 285 |
+
"d_model": 768,
|
| 286 |
+
"num_heads": 12,
|
| 287 |
+
"num_layers": 12,
|
| 288 |
+
"dim_feedforward": 3072,
|
| 289 |
+
"causal": true,
|
| 290 |
+
"norm": "layer_norm",
|
| 291 |
+
"positional_embedding": "rope",
|
| 292 |
+
"max_period": 10000,
|
| 293 |
+
"gating": "none",
|
| 294 |
+
"layer_scale": 0.01,
|
| 295 |
+
"conv_layout": true,
|
| 296 |
+
"context_duration": 1.0
|
| 297 |
+
},
|
| 298 |
+
{
|
| 299 |
+
"module_type": "PatchedPretransform",
|
| 300 |
+
"patch_size": 2
|
| 301 |
+
},
|
| 302 |
+
{
|
| 303 |
+
"module_type": "Transformer",
|
| 304 |
+
"input_dimension": 768,
|
| 305 |
+
"output_dimension": 384,
|
| 306 |
+
"d_model": 768,
|
| 307 |
+
"num_heads": 12,
|
| 308 |
+
"num_layers": 12,
|
| 309 |
+
"dim_feedforward": 3072,
|
| 310 |
+
"causal": true,
|
| 311 |
+
"norm": "layer_norm",
|
| 312 |
+
"positional_embedding": "rope",
|
| 313 |
+
"max_period": 10000,
|
| 314 |
+
"gating": "none",
|
| 315 |
+
"layer_scale": 0.01,
|
| 316 |
+
"conv_layout": true,
|
| 317 |
+
"context_duration": 2.0
|
| 318 |
+
},
|
| 319 |
+
{
|
| 320 |
+
"module_type": "PatchedPretransform",
|
| 321 |
+
"patch_size": 2
|
| 322 |
+
},
|
| 323 |
+
{
|
| 324 |
+
"module_type": "Transformer",
|
| 325 |
+
"input_dimension": 768,
|
| 326 |
+
"output_dimension": 384,
|
| 327 |
+
"d_model": 768,
|
| 328 |
+
"num_heads": 12,
|
| 329 |
+
"num_layers": 12,
|
| 330 |
+
"dim_feedforward": 3072,
|
| 331 |
+
"causal": true,
|
| 332 |
+
"norm": "layer_norm",
|
| 333 |
+
"positional_embedding": "rope",
|
| 334 |
+
"max_period": 10000,
|
| 335 |
+
"gating": "none",
|
| 336 |
+
"layer_scale": 0.01,
|
| 337 |
+
"conv_layout": true,
|
| 338 |
+
"context_duration": 4.0
|
| 339 |
+
},
|
| 340 |
+
{
|
| 341 |
+
"module_type": "PatchedPretransform",
|
| 342 |
+
"patch_size": 2
|
| 343 |
+
},
|
| 344 |
+
{
|
| 345 |
+
"module_type": "Transformer",
|
| 346 |
+
"input_dimension": 768,
|
| 347 |
+
"output_dimension": 384,
|
| 348 |
+
"d_model": 768,
|
| 349 |
+
"num_heads": 12,
|
| 350 |
+
"num_layers": 12,
|
| 351 |
+
"dim_feedforward": 3072,
|
| 352 |
+
"causal": true,
|
| 353 |
+
"norm": "layer_norm",
|
| 354 |
+
"positional_embedding": "rope",
|
| 355 |
+
"max_period": 10000,
|
| 356 |
+
"gating": "none",
|
| 357 |
+
"layer_scale": 0.01,
|
| 358 |
+
"conv_layout": true,
|
| 359 |
+
"context_duration": 8.0
|
| 360 |
+
},
|
| 361 |
+
{
|
| 362 |
+
"module_type": "PatchedPretransform",
|
| 363 |
+
"patch_size": 2
|
| 364 |
+
},
|
| 365 |
+
{
|
| 366 |
+
"module_type": "Transformer",
|
| 367 |
+
"input_dimension": 768,
|
| 368 |
+
"output_dimension": 640,
|
| 369 |
+
"d_model": 768,
|
| 370 |
+
"num_heads": 12,
|
| 371 |
+
"num_layers": 12,
|
| 372 |
+
"dim_feedforward": 3072,
|
| 373 |
+
"causal": true,
|
| 374 |
+
"norm": "layer_norm",
|
| 375 |
+
"positional_embedding": "rope",
|
| 376 |
+
"max_period": 10000,
|
| 377 |
+
"gating": "none",
|
| 378 |
+
"layer_scale": 0.01,
|
| 379 |
+
"conv_layout": true,
|
| 380 |
+
"context_duration": 10.0
|
| 381 |
+
},
|
| 382 |
+
{
|
| 383 |
+
"module_type": "PatchedPretransform",
|
| 384 |
+
"patch_size": 2
|
| 385 |
+
},
|
| 386 |
+
{
|
| 387 |
+
"module_type": "Transformer",
|
| 388 |
+
"input_dimension": 1280,
|
| 389 |
+
"output_dimension": 768,
|
| 390 |
+
"d_model": 1280,
|
| 391 |
+
"num_heads": 20,
|
| 392 |
+
"num_layers": 32,
|
| 393 |
+
"dim_feedforward": 5120,
|
| 394 |
+
"causal": true,
|
| 395 |
+
"norm": "layer_norm",
|
| 396 |
+
"positional_embedding": "rope",
|
| 397 |
+
"max_period": 10000,
|
| 398 |
+
"gating": "none",
|
| 399 |
+
"layer_scale": 0.01,
|
| 400 |
+
"conv_layout": true,
|
| 401 |
+
"context_duration": 10.0
|
| 402 |
+
}
|
| 403 |
+
],
|
| 404 |
+
"quantizer_type": "rlfq",
|
| 405 |
+
"quantizer_kwargs": {
|
| 406 |
+
"input_dim": 768,
|
| 407 |
+
"rvq_dim": 512,
|
| 408 |
+
"output_dim": 768,
|
| 409 |
+
"num_quantizers": 32,
|
| 410 |
+
"codebook_size": 1024,
|
| 411 |
+
"codebook_dim": 8,
|
| 412 |
+
"quantizer_type": "rlfq"
|
| 413 |
+
},
|
| 414 |
+
"transformers_version": "4.56.0.dev0"
|
| 415 |
+
}
|
configuration_moss_audio_tokenizer.py
ADDED
|
@@ -0,0 +1,475 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding=utf-8
|
| 2 |
+
# Copyright 2026 OpenMOSS and the HuggingFace Inc. team. All rights reserved.
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
"""MossAudioTokenizer model configuration."""
|
| 16 |
+
|
| 17 |
+
from typing import Any
|
| 18 |
+
|
| 19 |
+
try:
|
| 20 |
+
from transformers.configuration_utils import PreTrainedConfig
|
| 21 |
+
except ImportError:
|
| 22 |
+
from transformers.configuration_utils import PretrainedConfig as PreTrainedConfig
|
| 23 |
+
from transformers.utils import logging
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
logger = logging.get_logger(__name__)
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class MossAudioTokenizerConfig(PreTrainedConfig):
|
| 30 |
+
r"""
|
| 31 |
+
This is the configuration class to store the configuration of a [`MossAudioTokenizerModel`]. It is used to instantiate a
|
| 32 |
+
MossAudioTokenizer model according to the specified arguments, defining the model architecture.
|
| 33 |
+
|
| 34 |
+
Instantiating a configuration with the defaults will yield a similar configuration to that of the
|
| 35 |
+
[OpenMOSS-Team/MOSS-Audio-Tokenizer-v2](https://huggingface.co/OpenMOSS-Team/MOSS-Audio-Tokenizer-v2) architecture.
|
| 36 |
+
|
| 37 |
+
Configuration objects inherit from [`PreTrainedConfig`] and can be used to control the model outputs. Read the
|
| 38 |
+
documentation from [`PreTrainedConfig`] for more information.
|
| 39 |
+
|
| 40 |
+
Args:
|
| 41 |
+
sampling_rate (`int`, *optional*, defaults to 48000):
|
| 42 |
+
The sampling rate at which the audio waveform should be digitalized expressed in hertz (Hz).
|
| 43 |
+
downsample_rate (`int`, *optional*, defaults to 3840):
|
| 44 |
+
Total downsampling rate from waveform to tokens.
|
| 45 |
+
causal_transformer_context_duration (`float`, *optional*, defaults to 10.0):
|
| 46 |
+
Legacy global fallback context duration in seconds for causal transformer. If an individual transformer
|
| 47 |
+
entry in `encoder_kwargs` or `decoder_kwargs` provides `context_duration`, that per-module value takes
|
| 48 |
+
precedence.
|
| 49 |
+
encoder_kwargs (`list[dict]`, *optional*):
|
| 50 |
+
List of encoder module configurations. Each dict specifies a module type and its parameters.
|
| 51 |
+
decoder_kwargs (`list[dict]`, *optional*):
|
| 52 |
+
List of decoder module configurations in execution order.
|
| 53 |
+
number_channels (`int`, *optional*, defaults to 2):
|
| 54 |
+
Number of audio channels exposed by the public waveform interface.
|
| 55 |
+
enable_channel_interleave (`bool`, *optional*, defaults to `True`):
|
| 56 |
+
Whether to flatten multi-channel waveforms into a single internal stream before codec inference.
|
| 57 |
+
attention_implementation (`str`, *optional*, defaults to `"sdpa"`):
|
| 58 |
+
Attention implementation to prefer for transformer layers. Supported values are `"sdpa"` and
|
| 59 |
+
`"flash_attention_2"`.
|
| 60 |
+
compute_dtype (`str`, *optional*, defaults to `"fp32"`):
|
| 61 |
+
Inference compute dtype for non-quantizer modules. Supported values are `"fp32"`, `"bf16"`.
|
| 62 |
+
codec_weight_dtype (`str`, *optional*, defaults to `"fp32"`):
|
| 63 |
+
Parameter dtype for encoder and decoder modules. The quantizer remains fp32 because it explicitly disables
|
| 64 |
+
autocast and performs numerically sensitive codebook operations in fp32.
|
| 65 |
+
quantizer_type (`str`, *optional*, defaults to `"rlfq"`):
|
| 66 |
+
Quantizer type. Options include `"rvq"`, `"spec_rvq"`, `"rlfq"`, `"random_prefix_rlfq"`.
|
| 67 |
+
quantizer_kwargs (`dict`, *optional*):
|
| 68 |
+
Configuration for the quantizer including `input_dim`, `rvq_dim`, `output_dim`, `num_quantizers`,
|
| 69 |
+
`codebook_size`, and `codebook_dim`.
|
| 70 |
+
|
| 71 |
+
Example:
|
| 72 |
+
|
| 73 |
+
```python
|
| 74 |
+
>>> from transformers import MossAudioTokenizerModel, MossAudioTokenizerConfig
|
| 75 |
+
|
| 76 |
+
>>> # Initializing a MossAudioTokenizer style configuration
|
| 77 |
+
>>> configuration = MossAudioTokenizerConfig()
|
| 78 |
+
|
| 79 |
+
>>> # Initializing a model (with random weights) from the configuration
|
| 80 |
+
>>> model = MossAudioTokenizerModel(configuration)
|
| 81 |
+
|
| 82 |
+
>>> # Accessing the model configuration
|
| 83 |
+
>>> configuration = model.config
|
| 84 |
+
```
|
| 85 |
+
"""
|
| 86 |
+
|
| 87 |
+
model_type = "moss-audio-tokenizer"
|
| 88 |
+
|
| 89 |
+
# Backward-compatible alias used by some checkpoints.
|
| 90 |
+
attribute_map = {"sample_rate": "sampling_rate"}
|
| 91 |
+
|
| 92 |
+
sampling_rate: int
|
| 93 |
+
downsample_rate: int
|
| 94 |
+
causal_transformer_context_duration: float
|
| 95 |
+
encoder_kwargs: list[dict[str, Any]]
|
| 96 |
+
decoder_kwargs: list[dict[str, Any]]
|
| 97 |
+
number_channels: int
|
| 98 |
+
enable_channel_interleave: bool
|
| 99 |
+
attention_implementation: str
|
| 100 |
+
compute_dtype: str
|
| 101 |
+
codec_weight_dtype: str
|
| 102 |
+
quantizer_type: str
|
| 103 |
+
quantizer_kwargs: dict[str, Any]
|
| 104 |
+
|
| 105 |
+
def __init__(
|
| 106 |
+
self,
|
| 107 |
+
version: str | None = None,
|
| 108 |
+
sampling_rate: int = 48000,
|
| 109 |
+
downsample_rate: int = 3840,
|
| 110 |
+
causal_transformer_context_duration: float = 10.0,
|
| 111 |
+
encoder_kwargs: list[dict[str, Any]] | None = None,
|
| 112 |
+
decoder_kwargs: list[dict[str, Any]] | None = None,
|
| 113 |
+
number_channels: int = 2,
|
| 114 |
+
enable_channel_interleave: bool = True,
|
| 115 |
+
attention_implementation: str = "sdpa",
|
| 116 |
+
compute_dtype: str = "fp32",
|
| 117 |
+
codec_weight_dtype: str = "fp32",
|
| 118 |
+
quantizer_type: str = "rlfq",
|
| 119 |
+
quantizer_kwargs: dict[str, Any] | None = None,
|
| 120 |
+
**kwargs,
|
| 121 |
+
):
|
| 122 |
+
# Some checkpoints might include an incorrect/legacy `model_type` (e.g. "speech_tokenizer").
|
| 123 |
+
# We drop it to avoid overriding the class-level `model_type`.
|
| 124 |
+
kwargs.pop("model_type", None)
|
| 125 |
+
if "channels_numbers" in kwargs:
|
| 126 |
+
number_channels = kwargs.pop("channels_numbers")
|
| 127 |
+
if "enable_channel_interleave" in kwargs:
|
| 128 |
+
enable_channel_interleave = kwargs.pop("enable_channel_interleave")
|
| 129 |
+
if "attention_backend" in kwargs and attention_implementation == "sdpa":
|
| 130 |
+
attention_implementation = kwargs.pop("attention_backend")
|
| 131 |
+
if "codec_compute_dtype" in kwargs and compute_dtype == "fp32":
|
| 132 |
+
compute_dtype = kwargs.pop("codec_compute_dtype")
|
| 133 |
+
if "codec_load_dtype" in kwargs and codec_weight_dtype == "fp32":
|
| 134 |
+
codec_weight_dtype = kwargs.pop("codec_load_dtype")
|
| 135 |
+
reversed_decoder_kwargs = kwargs.pop("reversed_decoder_kwargs", None)
|
| 136 |
+
|
| 137 |
+
# `version` is accepted for compatibility but not used in modeling.
|
| 138 |
+
self.version = version
|
| 139 |
+
self.sampling_rate = sampling_rate
|
| 140 |
+
self.downsample_rate = downsample_rate
|
| 141 |
+
self.causal_transformer_context_duration = causal_transformer_context_duration
|
| 142 |
+
self.number_channels = number_channels
|
| 143 |
+
self.enable_channel_interleave = enable_channel_interleave
|
| 144 |
+
self.attention_implementation = attention_implementation
|
| 145 |
+
self.compute_dtype = compute_dtype
|
| 146 |
+
self.codec_weight_dtype = codec_weight_dtype
|
| 147 |
+
# Default encoder configuration
|
| 148 |
+
if encoder_kwargs is None:
|
| 149 |
+
encoder_kwargs = [
|
| 150 |
+
{
|
| 151 |
+
"module_type": "PatchedPretransform",
|
| 152 |
+
"patch_size": 240,
|
| 153 |
+
},
|
| 154 |
+
{
|
| 155 |
+
"module_type": "Transformer",
|
| 156 |
+
"input_dimension": 240,
|
| 157 |
+
"output_dimension": 384,
|
| 158 |
+
"d_model": 768,
|
| 159 |
+
"num_heads": 12,
|
| 160 |
+
"num_layers": 12,
|
| 161 |
+
"dim_feedforward": 3072,
|
| 162 |
+
"causal": True,
|
| 163 |
+
"norm": "layer_norm",
|
| 164 |
+
"positional_embedding": "rope",
|
| 165 |
+
"max_period": 10000,
|
| 166 |
+
"gating": "none",
|
| 167 |
+
"layer_scale": 0.01,
|
| 168 |
+
"conv_layout": True,
|
| 169 |
+
"context_duration": 1.0,
|
| 170 |
+
},
|
| 171 |
+
{
|
| 172 |
+
"module_type": "PatchedPretransform",
|
| 173 |
+
"patch_size": 2,
|
| 174 |
+
},
|
| 175 |
+
{
|
| 176 |
+
"module_type": "Transformer",
|
| 177 |
+
"input_dimension": 768,
|
| 178 |
+
"output_dimension": 384,
|
| 179 |
+
"d_model": 768,
|
| 180 |
+
"num_heads": 12,
|
| 181 |
+
"num_layers": 12,
|
| 182 |
+
"dim_feedforward": 3072,
|
| 183 |
+
"causal": True,
|
| 184 |
+
"norm": "layer_norm",
|
| 185 |
+
"positional_embedding": "rope",
|
| 186 |
+
"max_period": 10000,
|
| 187 |
+
"gating": "none",
|
| 188 |
+
"layer_scale": 0.01,
|
| 189 |
+
"conv_layout": True,
|
| 190 |
+
"context_duration": 2.0,
|
| 191 |
+
},
|
| 192 |
+
{
|
| 193 |
+
"module_type": "PatchedPretransform",
|
| 194 |
+
"patch_size": 2,
|
| 195 |
+
},
|
| 196 |
+
{
|
| 197 |
+
"module_type": "Transformer",
|
| 198 |
+
"input_dimension": 768,
|
| 199 |
+
"output_dimension": 384,
|
| 200 |
+
"d_model": 768,
|
| 201 |
+
"num_heads": 12,
|
| 202 |
+
"num_layers": 12,
|
| 203 |
+
"dim_feedforward": 3072,
|
| 204 |
+
"causal": True,
|
| 205 |
+
"norm": "layer_norm",
|
| 206 |
+
"positional_embedding": "rope",
|
| 207 |
+
"max_period": 10000,
|
| 208 |
+
"gating": "none",
|
| 209 |
+
"layer_scale": 0.01,
|
| 210 |
+
"conv_layout": True,
|
| 211 |
+
"context_duration": 4.0,
|
| 212 |
+
},
|
| 213 |
+
{
|
| 214 |
+
"module_type": "PatchedPretransform",
|
| 215 |
+
"patch_size": 2,
|
| 216 |
+
},
|
| 217 |
+
{
|
| 218 |
+
"module_type": "Transformer",
|
| 219 |
+
"input_dimension": 768,
|
| 220 |
+
"output_dimension": 384,
|
| 221 |
+
"d_model": 768,
|
| 222 |
+
"num_heads": 12,
|
| 223 |
+
"num_layers": 12,
|
| 224 |
+
"dim_feedforward": 3072,
|
| 225 |
+
"causal": True,
|
| 226 |
+
"norm": "layer_norm",
|
| 227 |
+
"positional_embedding": "rope",
|
| 228 |
+
"max_period": 10000,
|
| 229 |
+
"gating": "none",
|
| 230 |
+
"layer_scale": 0.01,
|
| 231 |
+
"conv_layout": True,
|
| 232 |
+
"context_duration": 8.0,
|
| 233 |
+
},
|
| 234 |
+
{
|
| 235 |
+
"module_type": "PatchedPretransform",
|
| 236 |
+
"patch_size": 2,
|
| 237 |
+
},
|
| 238 |
+
{
|
| 239 |
+
"module_type": "Transformer",
|
| 240 |
+
"input_dimension": 768,
|
| 241 |
+
"output_dimension": 640,
|
| 242 |
+
"d_model": 768,
|
| 243 |
+
"num_heads": 12,
|
| 244 |
+
"num_layers": 12,
|
| 245 |
+
"dim_feedforward": 3072,
|
| 246 |
+
"causal": True,
|
| 247 |
+
"norm": "layer_norm",
|
| 248 |
+
"positional_embedding": "rope",
|
| 249 |
+
"max_period": 10000,
|
| 250 |
+
"gating": "none",
|
| 251 |
+
"layer_scale": 0.01,
|
| 252 |
+
"conv_layout": True,
|
| 253 |
+
"context_duration": 10.0,
|
| 254 |
+
},
|
| 255 |
+
{
|
| 256 |
+
"module_type": "PatchedPretransform",
|
| 257 |
+
"patch_size": 2,
|
| 258 |
+
},
|
| 259 |
+
{
|
| 260 |
+
"module_type": "Transformer",
|
| 261 |
+
"input_dimension": 1280,
|
| 262 |
+
"output_dimension": 768,
|
| 263 |
+
"d_model": 1280,
|
| 264 |
+
"num_heads": 20,
|
| 265 |
+
"num_layers": 32,
|
| 266 |
+
"dim_feedforward": 5120,
|
| 267 |
+
"causal": True,
|
| 268 |
+
"norm": "layer_norm",
|
| 269 |
+
"positional_embedding": "rope",
|
| 270 |
+
"max_period": 10000,
|
| 271 |
+
"gating": "none",
|
| 272 |
+
"layer_scale": 0.01,
|
| 273 |
+
"conv_layout": True,
|
| 274 |
+
"context_duration": 10.0,
|
| 275 |
+
},
|
| 276 |
+
]
|
| 277 |
+
else:
|
| 278 |
+
encoder_kwargs = [dict(module_kwargs) for module_kwargs in encoder_kwargs]
|
| 279 |
+
for module_kwargs in encoder_kwargs:
|
| 280 |
+
if module_kwargs.get("module_type") == "Transformer":
|
| 281 |
+
module_kwargs.setdefault("context_duration", causal_transformer_context_duration)
|
| 282 |
+
self.encoder_kwargs = encoder_kwargs
|
| 283 |
+
|
| 284 |
+
# Default decoder configuration (execution order)
|
| 285 |
+
if decoder_kwargs is None and reversed_decoder_kwargs is not None:
|
| 286 |
+
reversed_decoder_kwargs = [dict(module_kwargs) for module_kwargs in reversed_decoder_kwargs]
|
| 287 |
+
decoder_kwargs = []
|
| 288 |
+
for module_kwargs in reversed_decoder_kwargs[::-1]:
|
| 289 |
+
if module_kwargs.get("module_type") != "Transformer":
|
| 290 |
+
decoder_kwargs.append(module_kwargs)
|
| 291 |
+
continue
|
| 292 |
+
module_kwargs = dict(module_kwargs)
|
| 293 |
+
module_kwargs["input_dimension"], module_kwargs["output_dimension"] = (
|
| 294 |
+
module_kwargs["output_dimension"],
|
| 295 |
+
module_kwargs["input_dimension"],
|
| 296 |
+
)
|
| 297 |
+
decoder_kwargs.append(module_kwargs)
|
| 298 |
+
|
| 299 |
+
if decoder_kwargs is None:
|
| 300 |
+
decoder_kwargs = [
|
| 301 |
+
{
|
| 302 |
+
"module_type": "Transformer",
|
| 303 |
+
"input_dimension": 768,
|
| 304 |
+
"output_dimension": 1280,
|
| 305 |
+
"d_model": 1280,
|
| 306 |
+
"num_heads": 20,
|
| 307 |
+
"num_layers": 32,
|
| 308 |
+
"dim_feedforward": 5120,
|
| 309 |
+
"causal": True,
|
| 310 |
+
"norm": "layer_norm",
|
| 311 |
+
"positional_embedding": "rope",
|
| 312 |
+
"max_period": 10000,
|
| 313 |
+
"gating": "none",
|
| 314 |
+
"layer_scale": 0.01,
|
| 315 |
+
"conv_layout": True,
|
| 316 |
+
"context_duration": 10.0,
|
| 317 |
+
},
|
| 318 |
+
{
|
| 319 |
+
"module_type": "PatchedPretransform",
|
| 320 |
+
"patch_size": 2,
|
| 321 |
+
},
|
| 322 |
+
{
|
| 323 |
+
"module_type": "Transformer",
|
| 324 |
+
"input_dimension": 640,
|
| 325 |
+
"output_dimension": 768,
|
| 326 |
+
"d_model": 768,
|
| 327 |
+
"num_heads": 12,
|
| 328 |
+
"num_layers": 12,
|
| 329 |
+
"dim_feedforward": 3072,
|
| 330 |
+
"causal": True,
|
| 331 |
+
"norm": "layer_norm",
|
| 332 |
+
"positional_embedding": "rope",
|
| 333 |
+
"max_period": 10000,
|
| 334 |
+
"gating": "none",
|
| 335 |
+
"layer_scale": 0.01,
|
| 336 |
+
"conv_layout": True,
|
| 337 |
+
"context_duration": 10.0,
|
| 338 |
+
},
|
| 339 |
+
{
|
| 340 |
+
"module_type": "PatchedPretransform",
|
| 341 |
+
"patch_size": 2,
|
| 342 |
+
},
|
| 343 |
+
{
|
| 344 |
+
"module_type": "Transformer",
|
| 345 |
+
"input_dimension": 384,
|
| 346 |
+
"output_dimension": 768,
|
| 347 |
+
"d_model": 768,
|
| 348 |
+
"num_heads": 12,
|
| 349 |
+
"num_layers": 12,
|
| 350 |
+
"dim_feedforward": 3072,
|
| 351 |
+
"causal": True,
|
| 352 |
+
"norm": "layer_norm",
|
| 353 |
+
"positional_embedding": "rope",
|
| 354 |
+
"max_period": 10000,
|
| 355 |
+
"gating": "none",
|
| 356 |
+
"layer_scale": 0.01,
|
| 357 |
+
"conv_layout": True,
|
| 358 |
+
"context_duration": 8.0,
|
| 359 |
+
},
|
| 360 |
+
{
|
| 361 |
+
"module_type": "PatchedPretransform",
|
| 362 |
+
"patch_size": 2,
|
| 363 |
+
},
|
| 364 |
+
{
|
| 365 |
+
"module_type": "Transformer",
|
| 366 |
+
"input_dimension": 384,
|
| 367 |
+
"output_dimension": 768,
|
| 368 |
+
"d_model": 768,
|
| 369 |
+
"num_heads": 12,
|
| 370 |
+
"num_layers": 12,
|
| 371 |
+
"dim_feedforward": 3072,
|
| 372 |
+
"causal": True,
|
| 373 |
+
"norm": "layer_norm",
|
| 374 |
+
"positional_embedding": "rope",
|
| 375 |
+
"max_period": 10000,
|
| 376 |
+
"gating": "none",
|
| 377 |
+
"layer_scale": 0.01,
|
| 378 |
+
"conv_layout": True,
|
| 379 |
+
"context_duration": 4.0,
|
| 380 |
+
},
|
| 381 |
+
{
|
| 382 |
+
"module_type": "PatchedPretransform",
|
| 383 |
+
"patch_size": 2,
|
| 384 |
+
},
|
| 385 |
+
{
|
| 386 |
+
"module_type": "Transformer",
|
| 387 |
+
"input_dimension": 384,
|
| 388 |
+
"output_dimension": 768,
|
| 389 |
+
"d_model": 768,
|
| 390 |
+
"num_heads": 12,
|
| 391 |
+
"num_layers": 12,
|
| 392 |
+
"dim_feedforward": 3072,
|
| 393 |
+
"causal": True,
|
| 394 |
+
"norm": "layer_norm",
|
| 395 |
+
"positional_embedding": "rope",
|
| 396 |
+
"max_period": 10000,
|
| 397 |
+
"gating": "none",
|
| 398 |
+
"layer_scale": 0.01,
|
| 399 |
+
"conv_layout": True,
|
| 400 |
+
"context_duration": 2.0,
|
| 401 |
+
},
|
| 402 |
+
{
|
| 403 |
+
"module_type": "PatchedPretransform",
|
| 404 |
+
"patch_size": 2,
|
| 405 |
+
},
|
| 406 |
+
{
|
| 407 |
+
"module_type": "Transformer",
|
| 408 |
+
"input_dimension": 384,
|
| 409 |
+
"output_dimension": 240,
|
| 410 |
+
"d_model": 768,
|
| 411 |
+
"num_heads": 12,
|
| 412 |
+
"num_layers": 12,
|
| 413 |
+
"dim_feedforward": 3072,
|
| 414 |
+
"causal": True,
|
| 415 |
+
"norm": "layer_norm",
|
| 416 |
+
"positional_embedding": "rope",
|
| 417 |
+
"max_period": 10000,
|
| 418 |
+
"gating": "none",
|
| 419 |
+
"layer_scale": 0.01,
|
| 420 |
+
"conv_layout": True,
|
| 421 |
+
"context_duration": 1.0,
|
| 422 |
+
},
|
| 423 |
+
{
|
| 424 |
+
"module_type": "PatchedPretransform",
|
| 425 |
+
"patch_size": 240,
|
| 426 |
+
},
|
| 427 |
+
]
|
| 428 |
+
else:
|
| 429 |
+
decoder_kwargs = [dict(module_kwargs) for module_kwargs in decoder_kwargs]
|
| 430 |
+
for module_kwargs in decoder_kwargs:
|
| 431 |
+
if module_kwargs.get("module_type") == "Transformer":
|
| 432 |
+
module_kwargs.setdefault("context_duration", causal_transformer_context_duration)
|
| 433 |
+
self.decoder_kwargs = decoder_kwargs
|
| 434 |
+
|
| 435 |
+
# Default quantizer configuration
|
| 436 |
+
if quantizer_kwargs is None:
|
| 437 |
+
quantizer_kwargs = {
|
| 438 |
+
"input_dim": 768,
|
| 439 |
+
"rvq_dim": 512,
|
| 440 |
+
"output_dim": 768,
|
| 441 |
+
"num_quantizers": 32,
|
| 442 |
+
"codebook_size": 1024,
|
| 443 |
+
"codebook_dim": 8,
|
| 444 |
+
"quantizer_type": "rlfq",
|
| 445 |
+
}
|
| 446 |
+
|
| 447 |
+
# Handle quantizer_type from kwargs or config
|
| 448 |
+
kw_qtype = quantizer_kwargs.get("quantizer_type", None)
|
| 449 |
+
if kw_qtype is not None:
|
| 450 |
+
self.quantizer_type = kw_qtype
|
| 451 |
+
else:
|
| 452 |
+
self.quantizer_type = quantizer_type
|
| 453 |
+
quantizer_kwargs["quantizer_type"] = quantizer_type
|
| 454 |
+
|
| 455 |
+
self.quantizer_kwargs = quantizer_kwargs
|
| 456 |
+
|
| 457 |
+
super().__init__(**kwargs)
|
| 458 |
+
|
| 459 |
+
@property
|
| 460 |
+
def num_quantizers(self) -> int:
|
| 461 |
+
"""Return the number of quantizers from quantizer_kwargs."""
|
| 462 |
+
return self.quantizer_kwargs.get("num_quantizers", 32)
|
| 463 |
+
|
| 464 |
+
@property
|
| 465 |
+
def codebook_size(self) -> int:
|
| 466 |
+
"""Return the codebook size from quantizer_kwargs."""
|
| 467 |
+
return self.quantizer_kwargs.get("codebook_size", 4096)
|
| 468 |
+
|
| 469 |
+
@property
|
| 470 |
+
def frame_rate(self) -> float:
|
| 471 |
+
"""Return the frame rate (tokens per second)."""
|
| 472 |
+
return self.sampling_rate / self.downsample_rate
|
| 473 |
+
|
| 474 |
+
|
| 475 |
+
__all__ = ["MossAudioTokenizerConfig"]
|
demo/demo_gt.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:631608f5c8b931ece1d45adc7f40a3b3b0ae2ec056a8a08a3565b04cc5750a4b
|
| 3 |
+
size 243244
|
images/arch.png
ADDED
|
Git LFS Details
|
images/metric.png
ADDED
|
Git LFS Details
|
model-00001-of-00003.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2d9f9182f17b143a23937feb87c63c08221bd28e685e4bc2fa55dcdce17fcde7
|
| 3 |
+
size 3978639168
|
model-00002-of-00003.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d4e48106d0254fe3b00ea0707e88fc6aee076993825e108dd9cef847f9db236e
|
| 3 |
+
size 3992738352
|
model-00003-of-00003.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d0449fe1b0ef1f6045946867148d8166b9a91a58d0feca4a18b641494d0b22da
|
| 3 |
+
size 523681336
|
model.safetensors.index.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
modeling_moss_audio_tokenizer.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|