Run this model with HF Jobs
Run swiss-ai/wavtokenizer-medium-speech-75token on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/swiss-ai/wavtokenizer-medium-speech-75token. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/swiss-ai/wavtokenizer-medium-speech-75token on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use swiss-ai/wavtokenizer-medium-speech-75token with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use swiss-ai/wavtokenizer-medium-speech-75token with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="swiss-ai/wavtokenizer-medium-speech-75token")# pip install -U transformers accelerate # Load model directly from transformers import AutoFeatureExtractor, AutoModel extractor = AutoFeatureExtractor.from_pretrained("swiss-ai/wavtokenizer-medium-speech-75token") model = AutoModel.from_pretrained("swiss-ai/wavtokenizer-medium-speech-75token", device_map="auto") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from swiss-ai/wavtokenizer-medium-speech-75token: direct link, hf CLI and curl.
- Browser
- Download file 5.65 kB
-
https://huggingface.co/swiss-ai/wavtokenizer-medium-speech-75token/resolve/main/README.md
- Command line
-
hf download hf://swiss-ai/wavtokenizer-medium-speech-75token/README.md
-
curl -L -o README.md https://huggingface.co/swiss-ai/wavtokenizer-medium-speech-75token/resolve/main/README.md
5.65 kB
| license: mit | |
| library_name: transformers | |
| pipeline_tag: feature-extraction | |
| tags: | |
| - audio | |
| - audio-tokenization | |
| - codec | |
| - wavtokenizer | |
| # WavTokenizer medium-speech 75 tokens/s | |
| WavTokenizer is a discrete acoustic codec tokenizer that compresses 24 kHz mono audio into a | |
| **single codebook** of 4096 codes at an extremely low frame rate, making it well suited as an | |
| audio tokenizer for language models. The encoder and quantizer follow EnCodec's SEANet encoder | |
| with single-codebook vector quantization; the decoder is a Vocos-style backbone (ConvNeXt blocks | |
| and a positional conv/attention net) with an inverse STFT head. | |
| It was proposed in [WavTokenizer: an Efficient Acoustic Discrete Codec Tokenizer for Audio | |
| Language Modeling](https://huggingface.co/papers/2408.16532) by Ji et al. (ICLR 2025). The | |
| original code (MIT license) is at | |
| [jishengpeng/WavTokenizer](https://github.com/jishengpeng/WavTokenizer). | |
| This repository contains the **medium speech** checkpoint at **75 tokens/s** (hop length | |
| 320), converted to the Transformers format from the original release | |
| [`novateur/WavTokenizer-medium-speech-75token`](https://huggingface.co/novateur/WavTokenizer-medium-speech-75token) (`wavtokenizer_medium_speech_320_24k.ckpt`). The conversion is verified | |
| bit-exact on encoding and within 1e-4 on decoded waveforms against the original implementation. | |
| ## Usage | |
| ```python | |
| import torch | |
| from datasets import Audio, load_dataset | |
| from transformers import AutoFeatureExtractor, WavTokenizerModel | |
| model = WavTokenizerModel.from_pretrained("swiss-ai/wavtokenizer-medium-speech-75token") | |
| feature_extractor = AutoFeatureExtractor.from_pretrained("swiss-ai/wavtokenizer-medium-speech-75token") | |
| dataset = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation") | |
| dataset = dataset.cast_column("audio", Audio(sampling_rate=feature_extractor.sampling_rate)) | |
| audio = dataset[0]["audio"]["array"] | |
| inputs = feature_extractor(audio=audio, sampling_rate=feature_extractor.sampling_rate, return_tensors="pt") | |
| with torch.no_grad(): | |
| audio_codes = model.encode(inputs["input_values"]).audio_codes # (batch, 1, ceil(samples / 320)) | |
| reconstruction = model.decode(audio_codes).audio_values | |
| ``` | |
| > [!WARNING] | |
| > Run the model in `float32`, the default and the only precision used by the original | |
| > implementation. As with any codec based on nearest-neighbour vector quantization, code | |
| > assignment is an argmin over codebook distances: half precision (`bfloat16`/`float16`) | |
| > perturbs the embeddings enough to flip codes near decision boundaries, so tokenization | |
| > is not reproducible across precisions. Decoded audio is always returned in `float32` | |
| > (the inverse STFT head upcasts internally). | |
| ## Available checkpoints | |
| | Checkpoint | Domain | Rate | Hop | Original release | | |
| |---|---|---:|---:|---| | |
| | [wavtokenizer-small-speech-40token](https://huggingface.co/swiss-ai/wavtokenizer-small-speech-40token) | speech | 40/s | 600 | [novateur/WavTokenizer](https://huggingface.co/novateur/WavTokenizer) | | |
| | [wavtokenizer-small-speech-75token](https://huggingface.co/swiss-ai/wavtokenizer-small-speech-75token) | speech | 75/s | 320 | [novateur/WavTokenizer](https://huggingface.co/novateur/WavTokenizer) | | |
| | **[wavtokenizer-medium-speech-75token](https://huggingface.co/swiss-ai/wavtokenizer-medium-speech-75token)** (this repo) | speech | 75/s | 320 | [novateur/WavTokenizer-medium-speech-75token](https://huggingface.co/novateur/WavTokenizer-medium-speech-75token) | | |
| | [wavtokenizer-medium-speech-75token-v2](https://huggingface.co/swiss-ai/wavtokenizer-medium-speech-75token-v2) | speech | 75/s | 320 | [novateur/WavTokenizer-medium-speech-75token](https://huggingface.co/novateur/WavTokenizer-medium-speech-75token) | | |
| | [wavtokenizer-medium-music-audio-75token](https://huggingface.co/swiss-ai/wavtokenizer-medium-music-audio-75token) | music/audio | 75/s | 320 | [novateur/WavTokenizer-medium-music-audio-75token](https://huggingface.co/novateur/WavTokenizer-medium-music-audio-75token) | | |
| | [wavtokenizer-medium-music-audio-75token-v2](https://huggingface.co/swiss-ai/wavtokenizer-medium-music-audio-75token-v2) | music/audio | 75/s | 320 | [novateur/WavTokenizer-medium-music-audio-75token](https://huggingface.co/novateur/WavTokenizer-medium-music-audio-75token) | | |
| | [wavtokenizer-large-unify-40token](https://huggingface.co/swiss-ai/wavtokenizer-large-unify-40token) | unified | 40/s | 600 | [novateur/WavTokenizer-large-unify-40token](https://huggingface.co/novateur/WavTokenizer-large-unify-40token) | | |
| | [wavtokenizer-large-speech-75token-v2](https://huggingface.co/swiss-ai/wavtokenizer-large-speech-75token-v2) | speech | 75/s | 320 | [novateur/WavTokenizer-large-speech-75token](https://huggingface.co/novateur/WavTokenizer-large-speech-75token) | | |
| ## Citation | |
| The original authors ask that work building on WavTokenizer cite it in exactly this format, | |
| together with their Language-Codec paper: | |
| ```bibtex | |
| @article{ji2024wavtokenizer, | |
| title={Wavtokenizer: an efficient acoustic discrete codec tokenizer for audio language modeling}, | |
| author={Ji, Shengpeng and Jiang, Ziyue and Wang, Wen and Chen, Yifu and Fang, Minghui and Zuo, Jialong and Yang, Qian and Cheng, Xize and Wang, Zehan and Li, Ruiqi and others}, | |
| journal={arXiv preprint arXiv:2408.16532}, | |
| year={2024} | |
| } | |
| @article{ji2024language, | |
| title={Language-codec: Reducing the gaps between discrete codec representation and speech language models}, | |
| author={Ji, Shengpeng and Fang, Minghui and Jiang, Ziyue and Huang, Rongjie and Zuo, Jialung and Wang, Shulei and Zhao, Zhou}, | |
| journal={arXiv preprint arXiv:2402.12208}, | |
| year={2024} | |
| } | |
| ``` | |