Nodes/ComfyUI-Replicate/Replicate meta/musicgen
ComfyUI Node

Replicate meta/musicgen

Text-to-music generation in ComfyUI

By replicate·Created 2 years ago·Updated 2 years ago· 207
Replicate meta/musicgen
  • input_audio
  • AUDIO
model_versionstereo-melody-large
prompt
duration8
continuationfalse
continuation_start0
continuation_end
multi_band_diffusionfalse
normalization_strategyloudness
top_k250
top_p0.00
temperature1.00
classifier_free_guidance3
output_formatwav
seed
force_rerunfalse

Type a description of a piece of music - "upbeat 80s synthwave with a driving bassline" - and this node hands you back an audio clip of it. It's Meta's MusicGen, the text-to-music model, wrapped so you can call it from a ComfyUI graph. Great for scoring a video, prototyping a loop, or generating background music without touching a DAW. One thing worth being clear about: it makes instrumental music. No vocals, no lyrics.

And the usual Replicate caveat, because this is a Replicate node: it doesn't run locally. Your prompt goes up to Replicate's cloud, the model runs on their GPU, and the audio comes back. You need a Replicate account and a REPLICATE_API_TOKEN, and you pay per run. There's nothing to download to your machine.

How it works

MusicGen is an autoregressive transformer that generates a stream of audio tokens (via Meta's EnCodec codec) and decodes them to sound - the same next-token idea as a language model, pointed at music. The "melody" variants add a twist: you can feed in a reference audio clip and the model will generate a new arrangement that follows its melody. That's the difference between the model versions in the dropdown.

The inputs and outputs that matter

  • prompt - describe the music: genre, mood, instruments, tempo, era. Be concrete; "lo-fi hip hop, mellow piano, vinyl crackle, 70 bpm" beats "nice music."
  • model_version - stereo-melody-large, stereo-large, melody-large, or large. The melody ones accept an input_audio to condition on; the plain ones are pure text-to-music. stereo versions output stereo.
  • duration (8) - clip length in seconds. Short by default. Longer clips cost more and can meander, so generate in chunks if you want length.
  • input_audio - a melody to follow (with a melody model), or the clip to extend when continuation is on.
  • temperature (1), top_k (250), top_p (0) - sampling knobs. Lower temperature = more predictable, higher = more adventurous.

The output is a single AUDIO stream you wire into a save-audio node. output_format picks wav or mp3, multi_band_diffusion trades speed for a cleaner decode, normalization_strategy controls loudness handling, and force_rerun bypasses Replicate's cache when identical inputs would otherwise return the same clip.

How to install it

Installing the pack once gives you every Replicate node, this one included.

  • ComfyUI Manager: search ComfyUI-Replicate, install, restart.
  • Manual:
    cd ComfyUI/custom_nodes
    git clone https://github.com/replicate/comfyui-replicate
    cd comfyui-replicate
    pip install -r requirements.txt
    
    then restart.

No weights to download - just the replicate pip package from requirements.txt. Set the token before you launch ComfyUI: export REPLICATE_API_TOKEN="r8_..." (from replicate.com/account/api-tokens).

Common issues & troubleshooting

The audio output won't preview or save. The pack's README is upfront that it was built for "simple text or image outputs," and lists better audio and video support as a roadmap item. MusicGen returns real audio here, but it's the least-mature part of the pack. If the AUDIO port misbehaves, update ComfyUI so it has native AUDIO support, and confirm you've got a save-audio node downstream.

The melody conditioning does nothing. input_audio only steers the tune on a melody model version. Pick stereo-melody-large or melody-large - the plain large/stereo-large ignore it.

Longer clips drift or repeat. MusicGen gets less coherent the longer it runs. Keep duration modest and use continuation to extend a good clip rather than asking for one long take, and nudge temperature down if it wanders harmonically.

You wanted a song with singing. MusicGen is instrumental only - that's a model limitation, not a setting. For vocals you'd layer a separate voice model on top.

CategoryReplicate

Inputs (16)

NameTypeDefaultDescription
model_versionoptCOMBOstereo-melody-large4 options: stereo-melody-large, stereo-large, melody-large, large
promptoptSTRING
input_audiooptAUDIO
durationoptINT8
continuationoptBOOLEANfalse
continuation_startoptINT0
continuation_endoptINT
multi_band_diffusionoptBOOLEANfalse
normalization_strategyoptCOMBOloudness4 options: loudness, clip, peak, rms
top_koptINT250
top_poptFLOAT0.00
temperatureoptFLOAT1.00
classifier_free_guidanceoptINT3
output_formatoptCOMBOwav2 options: wav, mp3
seedoptINT
force_rerunoptBOOLEANfalse

Outputs (1)

NameTypeDescription
AUDIOAUDIO