Nodes/ComfyUI Cut Audio/选取音频片段
ComfyUI Node

选取音频片段

AudioSelectSegment_CutAudio unpacks a split audio batch

By mailzwj·Created 4 months ago·Updated 4 months ago· 0
选取音频片段
  • audio_segments
  • 音频
index0

AudioSplitBySilence_CutAudio hands you a whole stack of segments in one batch - which is great until you realize you only wanted one of them. AudioSelectSegment_CutAudio is the other half of that pair: point it at the batch, type an index, get a single segment out. If you split a voice-over into twenty takes and want take three on its own, this is the node you'll glue onto the end of the splitter.

It's from the same small ComfyUI-cut-audio pack (mailzwj, Apache-2.0), under audio/cut-audio in the menu. On its own it does one boring thing. In the pack's intended chain - split, select, then process or save - it's the step that turns "a batch I can't do much with" into "the exact clip I wanted."

How it works

The batch that comes out of the splitter is a single AUDIO tensor where every segment is stacked on the batch dimension and right-padded with zeros up to the longest one. The selector grabs waveform[index:index+1] off that batch. Then the useful part: if the audio carries a segment_lengths key - which AudioSplitBySilence_CutAudio sets on its output - the node trims the zero padding off, so you get the real segment, not the padded one.

That padding-trim is the whole reason this node exists. Take the padded batch apart by hand and you'd be saving silence tails on everything but the longest take.

The inputs and outputs that matter

  • audio_segments (AUDIO) - the batch. In practice: the 音频片段 output of AudioSplitBySilence_CutAudio.
  • index (INT, default 0) - which segment. Zero-based, like everything in Python: the first take is 0, the third is 2. The tooltip says it explicitly - index from 0.

Output is a single 音频 (AUDIO) socket carrying the one chosen segment, ready for a save node, a TTS reference, a lip-sync, or whatever's downstream.

Where it bites

Three things, all predictable:

  • Out of range is a hard error, not a clamp. Ask for segment 20 of a 5-segment batch and the node raises with the segment count in the message. There's no wrap-around and no "give me the last one" mode - you'll see the error in the console and fix the index.
  • The padding-trim depends on the splitter's segment_lengths. Wire it straight off AudioSplitBySilence_CutAudio and it works. Feed it some other AUDIO batch that happens to be multi-clip but doesn't carry that key, and it returns the indexed item without trimming - fine for honest batches, misleading for padded ones.
  • You can't hear which index is which. There's no preview node in this pack, so if you don't know which take is at index 2, you'll be picking blind. Wire the output into a save/preview node and iterate indices, or consult the splitter's 对齐信息 (alignment JSON) output, which lists every segment's start time and duration - that's your map for choosing an index in the first place.

Installing it

Identical to the rest of the pack. In ComfyUI Manager, search ComfyUI-cut-audio and install, or:

cd ComfyUI/custom_nodes
git clone https://github.com/mailzwj/ComfyUI-cut-audio.git

Then restart ComfyUI. Dependencies are just torch - no models, no heavy installs, Apache-2.0. Like its siblings it's written against the newer comfy_api.latest node API, so keep ComfyUI current; the README notes comfy_api is normally bundled, and an out-of-date install is the usual reason these nodes don't show up.

The honest take

As a standalone node it's nearly invisible - index in, clip out. As the designated unpacker for the pack's splitter, it's what makes the whole "chop a long file into takes and process them one at a time" workflow possible. If you're batch-processing split segments, this is the node you'll reach for constantly. If you never split audio, you'll never touch it, and that's fine - it knows exactly what it's for.

Categoryaudio/cut-audio

Inputs (2)

NameTypeDefaultDescription
audio_segmentsAUDIO
indexINT00–9999要提取的片段索引(从0开始)。

Outputs (1)

NameTypeDescription
音频AUDIO