|
| 1 | +<!--Copyright 2026 The HuggingFace Team. All rights reserved. |
| 2 | +
|
| 3 | +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
| 4 | +the License. You may obtain a copy of the License at |
| 5 | +
|
| 6 | +http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | +
|
| 8 | +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
| 9 | +an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| 10 | +specific language governing permissions and limitations under the License. |
| 11 | +--> |
| 12 | + |
| 13 | +# LongCat-AudioDiT |
| 14 | + |
| 15 | +LongCat-AudioDiT is a text-to-audio diffusion model from Meituan LongCat. The diffusers integration exposes a standard [`DiffusionPipeline`] interface for text-conditioned audio generation. |
| 16 | + |
| 17 | +This pipeline supports loading the original flat LongCat checkpoint layout from either a local directory or a Hugging Face Hub repository containing: |
| 18 | + |
| 19 | +- `config.json` |
| 20 | +- `model.safetensors` |
| 21 | + |
| 22 | +The loader builds the text encoder, transformer, and VAE from `config.json`, restores component weights from `model.safetensors`, and ties the shared UMT5 embedding when needed. |
| 23 | + |
| 24 | +This pipeline was adapted from the LongCat-AudioDiT reference implementation: https://github.com/meituan-longcat/LongCat-AudioDiT |
| 25 | + |
| 26 | +## Usage |
| 27 | + |
| 28 | +```py |
| 29 | +import torch |
| 30 | +from diffusers import LongCatAudioDiTPipeline |
| 31 | + |
| 32 | +repo_id = "<longcat-audio-dit-repo-id>" |
| 33 | +tokenizer_path = os.environ["LONGCAT_AUDIO_DIT_TOKENIZER_PATH"] |
| 34 | + |
| 35 | +pipe = LongCatAudioDiTPipeline.from_pretrained( |
| 36 | + repo_id, |
| 37 | + tokenizer=tokenizer_path, |
| 38 | + torch_dtype=torch.float16, |
| 39 | + local_files_only=True, |
| 40 | +) |
| 41 | +pipe = pipe.to("cuda") |
| 42 | + |
| 43 | +audio = pipe( |
| 44 | + prompt="A calm ocean wave ambience with soft wind in the background.", |
| 45 | + audio_end_in_s=2.0, |
| 46 | + num_inference_steps=16, |
| 47 | + guidance_scale=4.0, |
| 48 | + output_type="pt", |
| 49 | +).audios |
| 50 | +``` |
| 51 | + |
| 52 | +## Tips |
| 53 | + |
| 54 | +- `audio_end_in_s` is the most direct way to control output duration. |
| 55 | +- `output_type="pt"` returns a PyTorch tensor shaped `(batch, channels, samples)`. |
| 56 | +- If your tokenizer path is local-only, pass it explicitly to `from_pretrained(...)`. |
| 57 | + |
| 58 | +## LongCatAudioDiTPipeline |
| 59 | + |
| 60 | +[[autodoc]] LongCatAudioDiTPipeline |
| 61 | + - all |
| 62 | + - __call__ |
| 63 | + - from_pretrained |
0 commit comments