GUÍA de IA en audio

MúsicaGen

MusicGen is Meta's open-weight text-to-music model, published in June 2023, that writes music as a sequence of compressed audio tokens using a single transformer language model.

Escuche esta guíaNarrado por IA · ~8 min

En esta pagina9 minutos de lectura
  1. Descripción general
  2. Conclusiones clave
  3. Buceo profundo
  4. Generating and checking a short MusicGen clip
  5. Implementación en el mundo real
  6. El futuro de MusicGen
  7. Poniéndolo en práctica
  8. Fuentes y lecturas adicionales
  9. Sigue explorando
  10. Preguntas frecuentes

Descripción general

It can follow a text description such as a genre and mood, or a hummed or played melody, and outputs 32 kHz audio. Its code is MIT-licensed, while its weights are licensed for non-commercial use.

Conclusiones clave

  1. MusicGen is a single-stage transformer that generates EnCodec audio tokens from a text description and, optionally, a melody.
  2. Meta released MusicGen weights and code as part of AudioCraft on 2 August 2023.
  3. MusicGen was trained on about 20,000 hours of licensed music and comes in 300M, 1.5B and 3.3B parameter sizes.
  4. The delay interleaving pattern turns 30 seconds of four-codebook audio into about 1,500 autoregressive steps.
  5. MusicGen cannot produce realistic vocals, because vocals were removed from its training data.
  6. MusicGen code is MIT-licensed, but its model weights are CC-BY-NC 4.0, which prohibits commercial use.

Buceo profundo

MusicGen is a model that generates music from a text description, optionally guided by a melody. It was introduced by Jade Copet and colleagues at Meta AI in the paper "Simple and Controllable Music Generation", first posted to arXiv in June 2023. It works the way a text language model does, predicting the next token from the previous ones, except that its tokens represent short slices of compressed audio rather than words. A separate neural audio codec turns those tokens back into sound. The word simple in the title refers to the design: one transformer generates everything in a single stage, instead of the chain of models that earlier systems such as Google's MusicLM used to go from coarse to fine detail.

The first ingredient is EnCodec, a neural audio codec from the same Meta team, described in an October 2022 paper. A codec compresses audio into a compact form and reconstructs it. The MusicGen version takes 32 kHz mono audio, downsamples it by a stride of 640 samples to 50 frames per second, and represents each frame with residual vector quantization (RVQ): four codebooks of 2,048 entries each, where the first codebook captures the coarse content and each later codebook encodes what the previous ones missed. Thirty seconds of music therefore becomes 1,500 frames, each with four tokens.

The second ingredient is how those four parallel token streams are fed to one transformer. Predicting all 6,000 tokens of a 30-second clip one by one, called flattening, is accurate but slow. Predicting all four codebooks of a frame at once, called parallel, is fast but ignores dependencies between them. MusicGen's default "delay" pattern offsets each codebook by one step, so at each step the model predicts codebook 1 for the current frame, codebook 2 for the previous frame, and so on. The paper says this turns 30 seconds of audio into 1,500 autoregressive steps. In its ablation, flattening still scored best, delay came close, and parallel was worst.

Conditioning steers the generation. Text prompts are encoded by a frozen T5 text encoder, and the paper also tested FLAN-T5 and CLAP. For melody, the model reads a chromagram, a representation of how much energy falls in each of the 12 pitch classes over time. The authors found that the raw chromagram led the model to copy the original track, so they kept only the dominant pitch class at each step and used Demucs, a source-separation model, to remove drums and bass first, because those dominated the chromagram. Generation uses classifier-free guidance: during training the condition is dropped 20% of the time, and at inference the model blends conditioned and unconditioned predictions with a guidance scale of 3.0 to follow the prompt more closely.

Training used about 20,000 hours of licensed music: an internal set of 10,000 high-quality tracks plus 25,000 and 365,000 instrument-only tracks from the ShutterStock and Pond5 collections, all at 32 kHz with text descriptions and metadata. The team trained models of 300 million, 1.5 billion and 3.3 billion parameters for one million steps on 30-second crops, using 32, 64 and 96 GPUs respectively. Meta announced the model publicly on 2 August 2023 as part of AudioCraft, alongside AudioGen for sound effects and an improved EnCodec decoder. The Hugging Face model card says the version 1 models were trained between April and May 2023.

On the MusicCaps benchmark of expert-written music descriptions, MusicGen compared well. Frechet Audio Distance (FAD), which measures how far generated audio statistics are from real audio, was 3.1 for the 300M model, against 4.0 reported for MusicLM, 7.5 for Mousai and 14.8 for Riffusion; Noise2Music reported the best FAD at 2.1. In human ratings on a 1 to 100 scale, the 3.3B model scored 84.81 for overall quality and the 1.5B model 83.70 for relevance to the text, against 80.51 and 82.35 for the public MusicLM demo. The authors note that larger models did not always improve automatic metrics even when listeners preferred them. With melody conditioning, the similarity between the reference and generated chromagrams rose from 0.10 to 0.66. A stereo variant, fine-tuned from the mono model with eight codebooks, was rated higher than mono.

Compared with alternatives, MusicGen's main trade is simplicity for some control. Hierarchical systems like MusicLM cascade several models, which the MusicGen authors avoided. Diffusion-based systems such as Riffusion and Mousai generate spectrograms or latents through iterative denoising rather than token by token. Within token-based models, MusicGen's interleaving patterns are its distinguishing choice. Its open release is also a difference: Meta published weights and code, while MusicLM's implementation was not public at the time of the paper.

The limitations are stated by Meta itself. The model card says MusicGen cannot generate realistic vocals, because vocals were removed from training data; works best with English descriptions; performs unevenly across musical styles and cultures; sometimes collapses to silence at the end of a song; and may need prompt engineering. The paper's authors note that their method offers no fine-grained control over how closely the output follows the conditioning beyond classifier-free guidance, and that the dataset contains a larger proportion of Western-style music. They also raise the concern that generative models could compete unfairly with artists. The weights are licensed CC-BY-NC 4.0, which rules out commercial use, even though the code is MIT-licensed. In practice, running MusicGen requires Python, PyTorch and ffmpeg per the AudioCraft README, and a GPU is advisable for the larger checkpoints; the model card's examples generate clips of a few seconds at a time.

04Ejemplo resuelto

Generating and checking a short MusicGen clip

  1. Install Hugging Face Transformers version 4.31.0 or later and scipy, and confirm the use is non-commercial under the CC-BY-NC 4.0 weight license.

  2. Load facebook/musicgen-small through the text-to-audio pipeline to keep memory use low for a first test.

  3. Generate a clip from the prompt 'lo-fi hip hop beat with soft piano and vinyl crackle' and save the returned 32 kHz array as a WAV file.

  4. Generate a second clip from the same prompt and listen to both; sampling with top-k makes each run different.

  5. Change one element of the prompt, such as swapping piano for saxophone, and check whether the instrumentation changes accordingly.

  6. Compare with the melody checkpoint by supplying a short reference melody and listening for whether the tune carries over.

lo que muestra

Two or more short instrumental clips at 32 kHz that reflect the prompt's genre and instruments. Check them by listening for prompt adherence, for any collapse to silence near the end, and by noting that no realistic vocals appear, both of which match the limitations in Meta's model card.

Implementación en el mundo real

Meta released MusicGen with AudioGen and EnCodec as the AudioCraft framework on 2 August 2023, publishing model weights and training code so researchers could train models on their own data.

Melody conditioning: the MusicGen melody checkpoint extracts a chromagram from a reference track after removing drums and bass, then generates new music that follows that tune while matching a text prompt.

Researchers load the small, medium, large or melody checkpoints through Hugging Face Transformers (version 4.31.0 or later) with the text-to-audio pipeline to produce mono 32 kHz clips.

In the paper's listening tests on MusicCaps, the 3.3B-parameter MusicGen scored 84.81 out of 100 for overall quality, above the 80.51 measured for the public MusicLM demo.

The AudioCraft repository later added related research models such as MAGNeT, a non-autoregressive text-to-music model, and AudioSeal for audio watermarking, built on the same codebase.

El futuro de MusicGen

The MusicGen paper names its own open problems: finer control over how strictly output follows its conditioning, and better data augmentation and guidance for audio conditioning such as melodies. Meta's August 2023 announcement acknowledged that the training data skews toward Western-style music and English-only descriptions, which limits the model's range. Since 2023, the AudioCraft repository has grown to include MAGNeT, a non-autoregressive text-to-music and text-to-sound model, MusicGen Style, JASCO for conditioning on chords, melodies and drum tracks, and AudioSeal for watermarking generated audio, which shows the research direction toward faster generation, richer musical controls and provenance tools. Questions about training-data licensing, attribution and the economic effect on working musicians remain unresolved across the field, and the MusicGen authors flagged unfair competition for artists as an open issue. Evaluations using shared benchmarks such as MusicCaps, together with human listening tests, remain the main way to compare newer music models with MusicGen.

Poniéndolo en práctica

Por qué es importante

  • Acceso y alcance. Mejora la accesibilidad a través de transcripción, narración e interfaces de voz.
  • Costo y presupuesto. Los equipos de medios pueden enviar audio pulido más rápido con presupuestos más pequeños.
  • Velocidad y escala. Los sistemas de cara al cliente pueden procesar interacciones habladas a mayor escala.

cuidado con

  • Los riesgos de uso indebido de voz y suplantación de identidad aumentan cuando falta el consentimiento.
  • La precisión puede disminuir según los acentos, los dialectos o los entornos ruidosos.
  • El audio sintético puede confundirse con el habla auténtica sin un etiquetado claro.

Próximos pasos

  1. Obtenga consentimiento explícito para la captura, clonación y reutilización de voz.
  2. Pruebe la calidad en diversos oradores y condiciones de fondo.
  3. Defina cuándo un humano debe revisar o aprobar los resultados.
  4. Etiquete el audio sintético y mantenga registros de procedencia para la rendición de cuentas.

Fuentes y lecturas adicionales

  1. arXiv (Meta AI)Generación de música simple y controlable
  2. GitHub (facebookresearch)AudioCraft: Open source code for audio generation
  3. Hugging Facefacebook/musicgen-large model card
  4. Meta AIAudioCraft: A simple one-stop shop for audio modeling
  5. arXiv (Meta AI)High Fidelity Neural Audio Compression

Sigue explorando

Boletín gratuito

Recibe el resumen diario de IA

Tres noticias verificadas sobre IA cada mañana de lunes a viernes, explicadas con claridad. Gratis para siempre y sin anuncios.

Un correo cada día laborable. Date de baja con un clic. Nunca vendemos ni compartimos tu dirección.

Ponte a prueba

Take the MusicGen quiz

Corrección inmediata en cada respuesta y un certificado para compartir, con un ID verificable, cuando apruebas un curso.

Empezar el cuestionario

Apoya la educación gratuita sobre IA. AI Understanding es una organización sin fines de lucro 501(c)(3): sin anuncios ni muros de pago, nunca. Hacer una donación

Preguntas frecuentes

¿Qué es MusicGen?

MusicGen is Meta's open-weight text-to-music model, published in June 2023, that writes music as a sequence of compressed audio tokens using a single transformer language model. It can follow a text description such as a genre and mood, or a hummed or played melody, and outputs 32 kHz audio. Its code is MIT-licensed, while its weights are licensed for non-commercial use.

Which input can a melody-conditioned MusicGen variant accept in addition to text?

The melody-conditioned variant can use a text description and a reference melody; this input is not available in every text-only checkpoint.

¿Qué códec neuronal produce los tokens de audio que predice MusicGen?

MusicGen modela tokens discretos generados por el códec EnCodec de Meta, que también decodifica los tokens predichos nuevamente en audio.

How does MusicGen model multiple EnCodec code streams?

The architecture uses delayed interleaving in a single-stage autoregressive model; “single-stage” does not mean the whole song is generated in one forward pass.

¿Cómo sigue MusicGen una melodía proporcionada sin copiar la grabación exacta?

Un cromagrama captura qué clases de tono están presentes a lo largo del tiempo, lo que permite que MusicGen iguale la armonía y el contorno de la melodía sin reproducir el timbre original.

¿Qué proyecto y empresa lanzó MusicGen?

MusicGen se lanzó en 2023 como parte del proyecto AudioCraft de Meta AI, con código abierto y pesos de modelo.