Trim Audio (Booleans)
Trim the edges off audio without rebuilding the workflow
- fullaudio
- trimmedAudio
Trimmed audio has a way of needing a trim again - the moment you realize a chunk starts with a breath or ends mid-reverb, you're re-running the whole pipeline. TKTrimAudioWithBooleans is the small TKNodes utility that trims the start and end off an AUDIO stream with two boolean switches, so you can set the trim amounts once and toggle them on and off without ripping wires out.
The gimmick is in the name: the booleans. Most trim nodes just trim whatever number you type. This one gates each trim with a checkbox, which is genuinely handy when you're processing a loop of chunks and want to trim the first chunk's start and the last chunk's end but leave the middle ones alone - without changing the values, just the switches.
How it works
It's straightforward waveform slicing. The node reads the audio's sample rate, converts your millisecond values to sample counts, and slices the waveform tensor. shouldTrimStart gates the start trim, shouldTrimEnd gates the end trim. Both trims clamp so they never overrun the clip - you can't trim more than the total length, and if the trims would leave nothing, it returns a single sample of silence rather than erroring out.
One limitation to know up front: each trim maxes out at 1000ms (one second) per side, in 100ms steps. That's plenty for clipping breaths and leading silence, but it means this isn't the node for chopping a 30-second clip in half. For surgical edge-trimming it's perfect; for serious cutting you want the pack's chunkers or a proper editing step.
The inputs that matter
fullaudio is your AUDIO stream - the only required input. Then the optional pair, repeated for each end:
shouldTrimStart/shouldTrimEnd- the boolean gatestrimStartMs/trimEndMs- how much to cut, 0–1000ms in 100ms steps
That's the whole interface. Both booleans default to off, so the node is a no-op until you deliberately enable a trim - safe by default, which is the right call for a node that lives mid-pipeline.
Outputs
One: trimmedAudio, the same AUDIO type in, ready to feed a fuse node, a save node, or the next chunk in the chain.
Where it fits
In this pack's world, it slots between the chunker and the fuser. Your silence-based chunker gives you chunks that start with a hair of silence or end mid-fade; you trim the front of the first chunk and the back of the last, toggle the middle chunks' gates off, and fuse. It's also handy for cleaning up a voice track before you hand it to a speaker pipeline - leading silence is exactly what confuses diarization.
Install
Standard TKNodes fare: ComfyUI Manager, search "Handy Nodes", install, restart.
cd ComfyUI/custom_nodes
git clone https://github.com/trashkollector/TKNodes
Restart ComfyUI. The audio stack needs torchaudio, pydub, and FFmpeg on your PATH if you're feeding it from files, but no model downloads - this is pure waveform math. If you set a trim and hear nothing change, check the boolean is actually on; the most common "bug" with this node is a gate you forgot to flip.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| fullaudio | AUDIO | — | |
| shouldTrimStartopt | BOOLEAN | false | — |
| trimStartMsopt | INT | 00–1000 | — |
| shouldTrimEndopt | BOOLEAN | false | — |
| trimEndMsopt | INT | 00–1000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| trimmedAudio | AUDIO | — |