ComfyUI Node

Trim Audio

Keep exactly the slice of audio you want

By kale4eat·Created 2 years ago·Updated about a year ago· 23
Trim Audio
  • audio
  • audio
start_second0.000
end_second0.000

The straightforward "keep this part, discard the rest" node. Give it a start and end time in seconds and it crops the clip down to that window - the basic move for turning a long recording into the exact segment you actually want, whether that's isolating one sentence out of a Whisper transcript's timestamps or just cutting dead air off the front and back of a recording.

How it works

It slices the underlying waveform tensor between the two timestamps you give it and returns a new AUDIO object covering just that range. The pack has a near-identical node, SDT_CutAudio, with the exact same three inputs - the distinction (going by standard audio-editor convention, where "trim" keeps the selection and "cut" removes it) is that Trim keeps what's between your two timestamps and drops everything outside it, while Cut does the opposite. If you actually want to delete a section from the middle of a clip and stitch the remainder back together, that's the one to reach for instead.

The inputs and outputs that matter

  • audio - the clip to trim, required.
  • start_second and end_second (both default 0, step 0.001) - the window to keep, in seconds, down to millisecond precision. That precision matters if you're trimming to timestamps pulled straight out of SDT_FasterWhisperSegmentProperty's start/end outputs - you can wire those floats directly in without rounding loss.
  • audio (output) - the trimmed clip.

How to install it

ComfyUI Manager: search ComfyUI-speech-dataset-toolkit, install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/kale4eat/ComfyUI-speech-dataset-toolkit
cd ComfyUI-speech-dataset-toolkit
pip install torchaudio --index-url https://download.pytorch.org/whl/cu121
pip install -r requirements.txt

No extra dependencies beyond the pack's torchaudio baseline.

Common issues & troubleshooting

Output is empty or errors. Check that end_second is actually greater than start_second and that both fall within the clip's real duration - SDT_AudioProperty will tell you the sample rate, and duration is a quick mental division from there (samples ÷ sample rate) if you need to sanity-check bounds before trimming.

Building an ASR-training clip pipeline and the trim boundaries feel slightly off from the transcript. Whisper-family timestamps aren't frame-perfect - they're accurate to roughly the granularity of the model's internal windowing, not sample-exact. If you need clean cuts right at word boundaries for a dataset, pad the trim window by a small margin on each side rather than trusting the raw timestamp to the millisecond.

Trimmed a clip that was supposed to keep the middle section and got the edges instead (or vice versa). That's the Trim/Cut mix-up - double-check you grabbed the right node for what you're trying to do.

Categoryspeech-dataset-toolkit/edit

Inputs (3)

NameTypeDefaultDescription
audioAUDIO
start_secondFLOAT0.000
end_secondFLOAT0.000

Outputs (1)

NameTypeDescription
audioAUDIO