Implementation:Facebookresearch Audiocraft MAGNeT get pretrained
| Knowledge Sources | |
|---|---|
| Domains | Audio_Generation, Masked_Generation |
| Last Updated | 2026-02-14 01:00 GMT |
Overview
Concrete tool for loading pretrained MAGNeT non-autoregressive text-to-music and text-to-sound generation models.
Description
MAGNeT provides a high-level user-facing API for non-autoregressive audio generation. Unlike autoregressive models, the generation duration is fixed by the model configuration and not user-configurable at inference time. The set_generation_params method configures MAGNeT-specific parameters including annealed CFG, per-codebook decoding steps, and span arrangement.
Usage
Import this class when you want to generate music or sounds using the faster non-autoregressive MAGNeT approach.
Code Reference
Source Location
- Repository: Facebookresearch_Audiocraft
- File: audiocraft/models/magnet.py
- Lines: 1-88
Signature
class MAGNeT(BaseGenModel):
@staticmethod
def get_pretrained(name: str = 'facebook/magnet-small-10secs', device=None):
"""Load a pretrained MAGNeT model."""
def set_generation_params(self, use_sampling=True, top_k=0, top_p=0.9,
temperature=3.0, max_cfg_coef=10.0, min_cfg_coef=1.0,
decoding_steps=[20,10,10,10], span_arrangement='nonoverlap'):
"""Configure MAGNeT generation parameters."""
Import
from audiocraft.models import MAGNeT
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| descriptions | list[str] | Yes | Text descriptions for generation |
| name | str | No | Pretrained model name |
Outputs
| Name | Type | Description |
|---|---|---|
| wav | torch.Tensor | Generated audio [B, C, T] |
Usage Examples
from audiocraft.models import MAGNeT
model = MAGNeT.get_pretrained('facebook/magnet-small-10secs')
model.set_generation_params(temperature=3.0, top_p=0.9)
wav = model.generate(['upbeat electronic music with heavy bass'])