musicgen-medium

MusicGen‑Medium is a text‑to‑audio transformer released by Meta (Facebook) that converts natural‑language prompts into high‑fidelity music waveforms. The model operates at a 32 kHz sampling rate and is built on a single‑stage auto‑regressive architecture that predicts four EnCodec codebooks in parallel, delivering only 50 auto‑regressive steps per second of audio.

facebook 1.2M downloads mit Text To Audio
Frameworkstransformerspytorch
Tagsmusicgentext-to-audio
Downloads
1.2M
License
mit
Pipeline
Text To Audio
Author
facebook

Run musicgen-medium locally on a Q4KM hard drive

Get MusicGen‑Medium pre‑installed on a high‑speed Q4KM SSD for instant, offline generation. Shop now and enjoy plug‑and‑play performance on any workstation.

Shop Q4KM Drives

Technical Overview

MusicGen‑Medium is a text‑to‑audio transformer released by Meta (Facebook) that converts natural‑language prompts into high‑fidelity music waveforms. The model operates at a 32 kHz sampling rate and is built on a single‑stage auto‑regressive architecture that predicts four EnCodec codebooks in parallel, delivering only 50 auto‑regressive steps per second of audio. Unlike earlier pipelines such as MusicLM, MusicGen does not rely on a separate semantic representation; the language model directly generates the acoustic tokens, which reduces latency and simplifies the generation pipeline.

Key capabilities include:

  • Genre‑aware generation – prompts like “a funky house with 80s hip hop vibes” or “a chill lofi track” are faithfully reproduced.
  • Length control – the set_generation_params(duration=…) API lets developers specify exact output length (e.g., 8 seconds).
  • Parallel codebook decoding – a small inter‑codebook delay enables simultaneous prediction of all four codebooks, cutting inference time dramatically.
  • Fine‑grained conditioning – the model can also accept short audio prompts for style transfer, though the primary interface is pure text.

Architecture highlights:

  • 1.5 B transformer parameters (the “medium” checkpoint).
  • Four‑codebook EnCodec tokenizer trained at 50 Hz, each codebook representing a different frequency band.
  • Single‑stage decoder that maps token sequences directly to 32 kHz PCM audio.
  • Implemented in PyTorch and fully compatible with the 🤗 Transformers text-to-audio pipeline (v4.31+).

Intended use cases span creative content creation (podcast intros, background scores), rapid prototyping for game audio, and research on controllable music synthesis. The model’s open‑source nature encourages integration into DAWs, web‑based music generators, and educational tools that explore AI‑driven composition.

Benchmark Performance

Benchmarks for text‑to‑audio models focus on audio quality (e.g., MOS – Mean Opinion Score), generation speed (seconds of audio per second of compute), and semantic fidelity (how well the output matches the prompt). The MusicGen paper (arXiv:2306.05284) reports that the medium checkpoint achieves MOS scores above 4.0 on a 5‑point scale for a variety of genres, while maintaining a generation speed of roughly 0.5 seconds of audio per second of GPU time on an RTX 3090.

These metrics matter because they directly translate to user experience: higher MOS means more pleasant listening, and faster generation enables real‑time applications such as interactive music assistants. Compared with the smaller musicgen‑small checkpoint (≈400 M parameters) MusicGen‑Medium offers a noticeable jump in timbral richness and rhythmic stability, yet it remains far more lightweight than the large (≈3 B) version, striking a practical balance for most production environments.

Hardware Requirements

Inference with MusicGen‑Medium is memory‑intensive due to the 1.5 B transformer and the 4‑codebook EnCodec decoder. Typical requirements are:

  • VRAM: 12 GB minimum; 16 GB+ recommended for batch‑size = 1 and to avoid out‑of‑memory errors when generating longer clips (≥30 seconds).
  • GPU: Any recent NVIDIA GPU with CUDA support (e.g., RTX 3060 12 GB, RTX 3070, RTX 3080, RTX 3090, or A100). The model runs fastest on GPUs with Tensor‑cores that accelerate fp16/bf16 operations.
  • CPU: A modern multi‑core CPU (8 cores or more) is sufficient; the CPU mainly handles preprocessing and token‑to‑audio post‑processing.
  • Storage: The checkpoint is ~5 GB (model weights + tokenizer). Allocate at least 10 GB to accommodate the model, cache files, and generated audio.
  • Performance: On a single RTX 3090, generating an 8‑second clip takes ~2 seconds of wall‑clock time (including token decoding and wav‑write). Using Torch‑scripted or ONNX‑exported versions can shave another 10‑15 % off the latency.

Use Cases

MusicGen‑Medium shines in scenarios where rapid, controllable music creation is needed without a human composer:

  • Podcast & video intros – generate catchy, royalty‑free beats on‑the‑fly.
  • Game audio prototyping – designers can type “mysterious ambient synth” and instantly hear a loop to iterate on level design.
  • Social media content – creators can produce background tracks for TikTok or Reels without copyright concerns.
  • Educational tools – music theory platforms can demonstrate how genre descriptors affect timbre and rhythm.

Integration is straightforward via the 🤗 Transformers text-to-audio pipeline, the original Audiocraft library, or by exporting the model to ONNX for deployment on edge devices.

Training Details

MusicGen‑Medium was trained on a large, diverse collection of licensed music tracks spanning multiple genres, instruments, and production styles. The training pipeline:

  • Uses the EnCodec tokenizer (4 codebooks, 32 kHz, 50 Hz token rate) to convert raw audio into discrete tokens.
  • Trains a 1.5 B‑parameter autoregressive transformer to predict all four codebooks simultaneously, with a small inter‑codebook delay to enable parallel decoding.
  • Optimizes a cross‑entropy loss over the token sequence, with teacher‑forcing for the text conditioning.
  • Employs mixed‑precision (fp16) training on clusters of NVIDIA A100 GPUs; the original research reports roughly 2 M GPU‑hours of compute.

Fine‑tuning is supported via the same 🤗 Transformers API – users can supply a domain‑specific dataset (e.g., cinematic scores) and continue training with a reduced learning rate to adapt the model while preserving its general music knowledge.

Licensing Information

The model card lists the license field as unknown, but the tags include license:cc-by-nc-4.0. This Creative Commons Attribution‑NonCommercial 4.0 International license permits:

  • Free use for research, education, and personal projects.
  • Modification and redistribution of the model weights, provided attribution is given to the original authors.

Because the license is non‑commercial, any commercial deployment (e.g., embedding the model in a paid SaaS product, selling generated music, or using it in a revenue‑generating game) requires a separate commercial agreement with Meta. Users must also retain the attribution notice in any public distribution of generated audio or derived models.

Pre-loaded AI models. Ready to run.

Skip the downloads. Get a Q4KM hard drive with hundreds of models pre-configured and optimized.

Shop Q4KM Hard Drives