Implementation:Facebookresearch Audiocraft MagnetApp
| Knowledge Sources | |
|---|---|
| Domains | Demo, Audio_Generation |
| Last Updated | 2026-02-14 01:00 GMT |
Overview
Concrete tool for running an interactive Gradio web demo of the MAGNeT text-to-music and text-to-sound generation model.
Description
MagnetApp is a Gradio web application that provides an interactive interface for the MAGNeT model. It supports text-conditioned generation for both music and environmental sound, with configurable parameters including model variant selection (small/medium, 10s/30s), temperature, top-k/top-p sampling, CFG coefficients, decoding steps, and span arrangement.
Usage
Run this application to demonstrate MAGNeT's text-to-music and text-to-sound generation capabilities through a web browser interface.
Code Reference
Source Location
- Repository: Facebookresearch_Audiocraft
- File: demos/magnet_app.py
- Lines: 1-351
Signature
def predict_full(model_path, text, temperature, top_k, top_p,
max_cfg_coef, min_cfg_coef, decoding_steps_1, decoding_steps_2,
decoding_steps_3, decoding_steps_4, span_score, span_arrangement):
"""Generate audio from text using MAGNeT model."""
Import
# Run as a standalone script
python demos/magnet_app.py
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| text | str | Yes | Text description for audio generation |
| model_path | str | Yes | Pretrained model identifier |
| temperature | float | No | Sampling temperature (default 3.0) |
| decoding_steps | list[int] | No | Steps per codebook [20,10,10,10] |
Outputs
| Name | Type | Description |
|---|---|---|
| audio | tuple(int, numpy.ndarray) | Generated audio as (sample_rate, waveform) |
Usage Examples
# Launch the demo
python demos/magnet_app.py --share
# Or programmatically:
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(['dogs barking and a cat meowing'])