Nodes/ComfyUI-MusicGen-HF/Save Audio (WAV/FLAC/MP3/Opus)
ComfyUI Node

Save Audio (WAV/FLAC/MP3/Opus)

The audio saver that actually tells you where things went

By ebrinz·Created about a year ago·Updated 10 months ago· 11
Save Audio (WAV/FLAC/MP3/Opus)
  • audio
  • filepath
filename_prefixmusicgen_audio
formatwav
quality128k

Every music generation workflow ends the same way: you need the audio on disk. SaveAudioStandalone - displayed as "Save Audio (WAV/FLAC/MP3/Opus)" - is this pack's proper exporter, and it's the one you should wire your HuggingFaceMusicGen audio output into. It writes four formats, gives you a filepath back, and behaves like you'd expect a ComfyUI saver to.

The nice part is the filepath string output. Instead of guessing where ComfyUI squirreled your file away, the node returns the absolute path to the thing it just wrote, which you can pipe into a text display or another node. No treasure hunt.

How it works

Everything goes through PyAV (the av library - same engine that does the pack's decoding and previews). The audio dict's waveform is encoded to your chosen container and written to ComfyUI/output/audio/ with a timestamp appended to your filename prefix, so you don't overwrite previous runs.

A couple of format-specific details worth knowing, because the code is doing more than meets the eye. Opus has a limited set of legal sample rates (8/12/16/24/48kHz), so the node resamples your 32kHz MusicGen output up to 48kHz on export. That's automatic, but it means an opus file isn't bit-identical to the source - expected and fine for listening. WAV and FLAC are lossless. MP3 and Opus are where the quality setting actually does anything.

The inputs that matter

  • audio - the AUDIO input, straight from MusicGen or any AUDIO-producing node.
  • filename_prefix - default musicgen_audio. You get musicgen_audio_1234567890.wav in output/audio/. Give it something descriptive before you generate a folder full of musicgen_audio_* files.
  • format - wav (default), flac, mp3, opus.
  • quality - 128k, 192k, 320k, V0. Only meaningful for mp3/opus: V0 is a variable-bitrate flag for mp3, the others are bitrates. For wav/flac it's ignored - don't read too much into it.

One output: filepath (STRING). It's marked as an output node, so it also flags the queue as done once audio lands on disk.

Install

This is the same pack as the main MusicGen node, so if you already have it, you're done. Otherwise: ComfyUI Manager → search "ComfyUI-MusicGen-HF", or

cd ComfyUI/custom_nodes
git clone https://github.com/ebrinz/ComfyUI-MusicGen-HF
cd ComfyUI-MusicGen-HF
pip install -r requirements.txt

and restart. PyAV (av>=15.0.0) is the important dependency here - it does all the actual encoding.

Troubleshooting

The classic confusion: you saved a file and can't find it. It's not in output/ directly - it's in output/audio/, and the filepath output tells you the exact location. If you pick V0 quality with opus, the code just doesn't set a bitrate and PyAV picks a default, so match the quality options to the format you chose. And if saving fails on an unusual source sample rate, remember the node expects a real AUDIO dict with a sample_rate key - hand it silence-shaped garbage and it'll happily write garbage. Files land where you can find them; the rest is just picking a format and pressing go.

Categoryaudio/musicgen

Inputs (4)

NameTypeDefaultDescription
audioAUDIO
filename_prefixSTRINGmusicgen_audio
formatCOMBOwav4 options: wav, flac, mp3, opus
qualityCOMBO128k4 options: 128k, 192k, 320k, V0

Outputs (1)

NameTypeDescription
filepathSTRING