Nodes/ComfyUI-AjoNodes/πŸ”Š Audio Collect & Concat
ComfyUI Node

πŸ”Š Audio Collect & Concat

Stitch audio clips into one β€” and survive the shared-state trap

By AJO-readingΒ·Created about a year agoΒ·Updated about a year agoΒ· 11
πŸ”Š Audio Collect & Concat
  • audio
  • concatenated_audio
  • collected_count
β—„expected_count1β–Ί

ComfyUI treats an AUDIO wire as one self-contained blob per run. That's fine for a single generated voiceover, but it breaks down the moment your audio arrives in pieces - an LLM narrating chapter by chapter, a TTS pipeline that outputs per-line clips, a video job where each segment carries its own soundtrack. There's no built-in "glue these together." That gap is what πŸ”Š Audio Collect & Concat (class AJO_AudioCollectAndConcat) tries to fill: it collects expected_count audio clips across multiple workflow runs and hands you one continuous clip.

How it actually works

Here's the part worth understanding, because it's unusual. The node doesn't gather clips in a single run - it accumulates them across runs. It keeps a list in its own class (so it survives between queue executions), appends whatever AUDIO arrives on each run, and blocks everything downstream with ComfyUI's ExecutionBlocker until it has seen expected_count clips. On the final run it checks that every collected segment shares the same sample rate (it raises a ValueError if not), concatenates the waveforms along the sample axis with torch.cat, returns the merged audio, and clears the buffer.

That re-run pattern is the workflow: queue the job, feed clip 1, queue again with clip 2, and so on until the last run finally outputs the concatenation. The count on the collected_count output tells you where you are.

The inputs that matter

  • audio (AUDIO) - the segment to append this run. The only required wire.
  • expected_count (INT, default 1) - how many clips you're assembling. Set it once and leave it; this is the one you'll actually touch.

Outputs are concatenated_audio (AUDIO) and collected_count (INT). Wire the audio into a Save or Preview Audio node (the pack ships AJO_SaveAudio/AJO_PreviewAudio in its source but they're disabled - use ComfyUI's built-in ones).

The trap you must not ignore

The accumulating state lives on the class, not the instance. That means it's global: two instances of this node in the same workflow share one buffer and will fight over it, and a workflow that errors halfway leaves stale audio in the buffer that silently gets mixed into your next successful run. There's no reset button - the list only clears on a successful concat. So the rules are: one instance per project, set expected_count to match exactly how many times you feed it (or downstream stays blocked forever), and if a run fails, restart ComfyUI before trying again. Sample-rate mismatch is the other common ValueError; make sure every segment is produced at the same rate.

Honest take: this is a niche, fiddly node. If you're doing single-shot audio, skip it - with expected_count at its default of 1 it's just a passthrough. Reach for it only when you're assembling multi-part audio and can live with the re-run discipline.

Install

It ships in ComfyUI-AjoNodes, a tiny two-node pack with zero extra dependencies (no requirements.txt - it only uses comfy_extras and comfy_execution, which ship with ComfyUI). Install via ComfyUI Manager by searching "ComfyUI-AjoNodes", or:

cd ComfyUI/custom_nodes
git clone https://github.com/AJO-reading/ComfyUI-AjoNodes.git

Then restart ComfyUI. Node appears under the audio category.

Categoryaudio

Inputs (2)

NameTypeDefaultDescription
audioAUDIOβ€”
expected_countINT11–999β€”

Outputs (2)

NameTypeDescription
concatenated_audioAUDIOβ€”
collected_countINTβ€”