Save 4 hours! We auto-setup your workflow! Free!

Drop your workflow.json — we handle every dependency, custom node, and model. Just open the link and run.

Auto-Setup Workflow Json (Free) Now!
ComfyUI > Nodes > ComfyUI-MusicGen-HF

ComfyUI Extension: ComfyUI-MusicGen-HF

Repo Name

ComfyUI-MusicGen-HF

Author
ebrinz (Account age: 2931 days)
Nodes
View all nodes(1)
Latest Updated
2025-11-18
Github Stars
0.01K

How to Install ComfyUI-MusicGen-HF

Install this extension via the ComfyUI Manager by searching for ComfyUI-MusicGen-HF
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI-MusicGen-HF in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

ComfyUI-MusicGen-HF Description

ComfyUI-MusicGen-HF adds ComfyUI nodes to generate music from text or continue existing audio using Hugging Face MusicGen, with BPM-based timing, loop previews, smooth transitions, and audio export.

ComfyUI-MusicGen-HF Introduction

ComfyUI-MusicGen-HF is a standalone collection of ComfyUI nodes for creating music with MusicGen models through Hugging Face Transformers. You can describe a sound in everyday language, generate a short audio clip, preview it, and save it in a format suited to your project.

The extension is useful when you need a musical idea for a video, a game scene, an animation, or another creative work. Beyond basic text-to-music generation, its nodes help you work with musical timing, use an existing audio clip as a starting point, repeat previews, and smooth the join between sections of audio. It supports NVIDIA GPUs through CUDA, Apple Silicon through MPS, and CPU operation when acceleration is unavailable. It does not require changes to ComfyUI’s core files.

How ComfyUI-MusicGen-HF Works

Think of a prompt as a creative brief for a musician. You describe the style, instruments, rhythm, and mood you want, then the MusicGen node produces audio based on that description. For example:

Upbeat jazz with a saxophone lead, walking bass, and light drums.

A basic workflow is:

Your description → MusicGen (Hugging Face) → Save Audio

You can build on that workflow in three ways:

  • Set a musical length. The BPM Duration Calculator turns tempo and a number of beats into seconds. At 120 beats per minute, 16 beats take 8 seconds. Connect its duration output to MusicGen’s duration_override input when you want a clip planned around that timing.
  • Start from existing audio. Load a reference clip and connect it to MusicGen’s optional conditioning_audio input. The extension describes this as audio continuation: MusicGen uses the clip as a starting point for generating more music.
  • Shape the result after generation. Preview a clip repeatedly, set a target duration, or use a transition node to make a repeated section or change between clips sound smoother.

BPM timing gives you a useful duration target, but it does not guarantee that every generated note or drum hit will land exactly on a beat. Listen to the result before relying on it as a finished loop.

ComfyUI-MusicGen-HF Features

Create music from a description

MusicGen (Hugging Face) is the main generation node. Its controls let you balance prompt-following, variation, and clip length:

ControlWhat it changes
promptDescribes the music you want. Mentioning instruments, genre, tempo, or mood gives the model more direction.
model_sizeSelects the small, medium, or large model. Larger choices generally take longer to run.
durationSets the requested clip length from 1 to 30 seconds.
guidance_scaleControls how strongly generation follows the prompt, from 1 to 10. A higher value emphasizes your description.
do_sampleEnables sampling for more varied results.
temperatureAdjusts sampling randomness from 0.1 to 2.0. Higher settings can produce less predictable results.
seedSets a random seed so you can revisit a generation setup.
max_new_tokensLimits how much audio the model generates, from 50 to 1503 tokens. Reducing it can help when a generation is too demanding.
conditioning_audioAccepts an optional reference clip for audio continuation.
duration_overrideAccepts a duration from another node, such as the BPM calculator. A value of 0 uses the manual duration setting.

For an initial experiment, try a short duration and a concrete prompt such as “gentle ambient synthesizer with soft piano and no heavy drums.” Change one setting at a time so you can hear its effect.

Plan a clip around tempo

BPM Duration Calculator accepts a tempo (bpm), a number of beats, and a time_signature such as 4/4, 3/4, 6/8, or 2/4. It outputs a duration in seconds and timing information. The time signature helps describe measures; it does not change the duration calculation. The node caps long results to stay within the generation token limit and rounds durations to approximately 0.02-second token boundaries.

BPM Duration Calculator → MusicGen duration_override → Save Audio

For example, set bpm to 120 and beats to 16 to request an 8-second clip. This is useful when sketching music for a timed scene or planning a repeated phrase.

Preview and repeat audio

Looping Audio Preview helps you hear how a clip feels when repeated. Set loop_count from 1 to 10, turn playback on or off with enable_preview, and use queue_mode when you want new audio to wait for the current preview to finish. Its conditioning_audio output also passes the input audio along to MusicGen.

Give separate preview nodes distinct instance_id values if you are working with several clips. Higher loop counts create more repeated audio and can use more memory.

Smooth transitions and adjust duration

Smooth Audio Queue processes audio for timed playback and transitions. Its target_duration setting can trim or pad audio to a requested length; 0 keeps the original duration. Set crossfade_duration between 0 and 2 seconds to blend transitions, and use separate queue_id values for independent streams. Its conditioning_audio output retains the original input for a MusicGen continuation workflow.

A crossfade is like gradually lowering one clip while raising the next. A longer fade may suit sustained sounds, while a shorter fade may preserve the impact of a quick rhythmic change.

Professional Loop Transition offers additional controls for repeated music:

SettingWhen it may help
beat_matchAlign a transition to beats in rhythmic music.
phrase_matchWork toward a transition at a musical phrase boundary.
zero_crossLook for waveform points that can make a cut less noticeable.
power_matchBalance differing audio levels before a crossfade.
transition_beatsSet the transition length in beats, from 0.25 to 8.
crossfade_curveChoose how the blend changes over time: linear, equal_power, exponential, or s_curve.
auto_normalizeBalance audio levels automatically.
dc_offset_removalReduce waveform bias that can contribute to clicks.
phase_alignAlign waveforms to help reduce cancellation during a transition.

Set bpm to match the audio’s actual tempo when using beat-based transitions. Distinct loop_id values keep independent transition chains separate. These tools can improve a join, but the best settings depend on what you hear in the source audio.

Load, save, and export audio

Load Audio File brings an existing clip into a workflow for preview, processing, or conditioning. Save MusicGen Audio (Legacy) provides a simpler saving option.

Save Audio (WAV/FLAC/MP3/Opus) offers several export choices:

FormatAvailable optionsA useful choice when…
WAVUncompressedYou want an uncompressed file for further editing.
FLACLosslessYou want to retain audio quality in a smaller file than WAV.
MP3128k, 192k, 320k, V0You need a widely compatible compressed file.
Opus64k, 96k, 128k, 192k, 320kYou want a compact file in a modern audio format.

ComfyUI-MusicGen-HF Models

The MusicGen node offers three model sizes. Start with small to explore prompts, then try a larger model when you want to compare the results and have time and memory available.

ModelApproximate size listed by the authorWhat to expect
Small1.5 GBThe fastest option and a practical starting point for experiments.
Medium3.3 GBA quality-focused option that takes longer to generate.
Large3.3 GBThe author’s highest-quality option and the slowest to generate.

Model size, duration, and your computer’s available resources all affect the experience. The first use of a model downloads it to the Hugging Face cache; later uses can load the cached copy.

What's New with ComfyUI-MusicGen-HF

The version history supplied by the author lists these releases:

  • v1.1.0: Added the BPM Duration Calculator, Looping Audio Preview, and Smooth Audio Queue. MusicGen also gained a duration override and improved conditioning support. Together, these changes make it easier to plan clips by beats, audition repetitions, and build longer audio workflows.
  • v1.0.0: Introduced text-to-music generation, audio loading and conditioning, export to WAV/FLAC/MP3/Opus, and CUDA/MPS/CPU device support.

The supplied version history does not identify when every currently documented node, including Professional Loop Transition, was added.

Troubleshooting ComfyUI-MusicGen-HF

The model takes a long time to start

  1. Check your internet connection if this is the first time you have selected that model.
  2. Allow time for its download to finish. The author says model files are cached in ~/.cache/huggingface/ for subsequent use.
  3. Try the small model first to establish that generation works.

Generation runs out of memory or feels too slow

  1. Select the small model.
  2. Request a shorter duration and reduce max_new_tokens.
  3. Lower preview loop_count if you are repeating audio.
  4. Simplify a workflow with several simultaneous audio-processing nodes.

The author recommends at least 8 GB of RAM, with 12 GB or more for smoother queue processing. A GPU is optional, but can accelerate generation.

An Apple Silicon Mac reports an MPS error

The author states that the node falls back to CPU when MPS fails. If you are diagnosing the problem, check that the Mac meets the stated macOS 12.3+ and PyTorch 2.0+ requirements. CPU generation may be slower.

A BPM-based clip is shorter than expected

  1. Check the bpm and beats values. At 120 BPM, 16 beats equal 8 seconds.
  2. Check whether the calculated request exceeds the node’s generation limit; the author says it is capped at approximately 30.06 seconds.
  3. Remember that the calculator rounds to approximately 0.02-second token boundaries.
  4. Do not change the time signature expecting it to change the duration; it affects measure information instead.

A preview will not loop or a queue behaves unexpectedly

  1. Set loop_count above 1 and check that enable_preview is on.
  2. Give each independent Looping Audio Preview node a unique instance_id.
  3. Give independent Smooth Audio Queue streams different queue_id values.
  4. Reduce loop counts if previewing becomes memory-intensive.

A loop clicks, sounds choppy, or changes volume

  1. Confirm that the transition node’s bpm matches the source audio if you are using beat-based processing.
  2. For a choppy join, try a longer transition_beats value or zero_cross.
  3. For a volume jump, try power_match and auto_normalize.
  4. For a hollow-sounding blend, try phase_align with an equal_power curve.
  5. For clicks or other artifacts, try dc_offset_removal or an s_curve crossfade. In Smooth Audio Queue, shorten crossfade_duration if the source clip is very short.

No troubleshooting screenshots or videos are included in the supplied documentation.

Frequently asked questions

Do I need a GPU?
No. The extension supports CPU operation. It can also use CUDA on supported NVIDIA GPUs or MPS on supported Apple Silicon Macs.

Can I continue a piece of music I already have?
Yes. Load the clip with Load Audio File and connect it to MusicGen’s conditioning_audio input. Listen to the result to judge how well the continuation fits.

Can I make a perfectly seamless loop just by setting a BPM?
BPM controls a duration target, not the exact placement of notes. Preview the repetition and use a transition node if the join needs work.

Why does a longer preview use more memory?
The preview node creates repeated audio for the requested number of loops. Try a lower loop_count when resources are limited.

Which export format should I choose?
Use WAV or FLAC when preserving audio for further work matters most. Choose MP3 for broad compatibility, or Opus when a compact modern format suits your destination.

Learn More about ComfyUI-MusicGen-HF

For hands-on learning, begin with MusicGen → Save Audio. Then add the BPM calculator to plan a clip’s length, or add a preview node to hear how the result repeats.

ComfyUI-MusicGen-HF Related Nodes

RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Models, enabling artists to harness the latest AI tools to create incredible art.

ComfyUI-MusicGen-HF detailed guide | ComfyUI