Audio Segment By Paragraph
Turn a Transcript Into Time-Aligned Audio Clips (Plus an SRT, Free)
- audio
- AudioClip list
- size
- srt
If you've ever wanted to split a long recording into per-paragraph clips without opening a timeline editor, this is the node you're looking for. It's the flagship of the ComfyUI Audio Segment Plugin and the only node in the pack with actual brains: you feed it audio plus the transcript, and it returns each paragraph as its own time-aligned clip. It even hands you an SRT subtitle string on the way out, which is a nice bonus nobody advertises enough.
What it does
The pitch is simple - audio in, text in, clips out - but the mechanism underneath is doing real work. It runs speech recognition with word-level timestamps (OpenAI's Whisper, via the openai-whisper library), then aligns the paragraphs of your reference text against the ASR words, then slices the original audio at those boundaries with pydub. Each output clip is an AudioClip object carrying the audio itself plus startTime/endTime (milliseconds) and the paragraph text it corresponds to. If you've used Whisper for subtitles before, think of this as "Whisper word timestamps, but repurposed as a slicer."
The alignment is where it gets clever. Real transcripts never match ASR output exactly - homophones, traditional vs. simplified Chinese, words the model misheard. The node normalizes both sides (via opencc for Chinese, plus stripping punctuation and lowercasing) and then runs difflib.SequenceMatcher to find matching blocks, tolerating scattered errors by cumulative similarity. Paragraphs that match less than 50% get skipped rather than producing garbage clips. It's clearly built with Chinese audio in mind, but the normalization is harmless for English - it just strips punctuation and lowercases, so don't let the Chinese focus put you off.
The inputs that matter
audio- a standard ComfyUIAUDIOobject (from any audio loader). It assumes a batch size of 1 and takes the first channel group, so don't feed it a pre-batched tensor.text- a multiline string where each line is one paragraph. The node splits on newlines, so format your transcript accordingly. This is the one beginners get wrong: cram the whole thing on one line and you get one giant clip.model- a dropdown of the seven standard Whisper models (tiny,base,small,medium,large-v1,large-v2,large-v3). Start withbaseorsmallto check the pipeline; jump tolarge-v3when alignment accuracy actually matters. The node also picks up any.ptfile or Hugging Face model folder you drop intoComfyUI/models/stt/whisper/.
Outputs: AudioClip list (wire it into Select AudioClip From List), size (the clip count), and srt - a complete, ready-to-save subtitle string.
Installing the pack
Easiest route is ComfyUI Manager: search "Audio Segment" (pack title ComfyUI Audio Segment Plugin) and install. Manual route:
cd path/to/ComfyUI/custom_nodes/
git clone https://github.com/ahkimkoo/Comfyui-AudioSegment
cd Comfyui-AudioSegment
pip install -r requirements.txt
Then restart ComfyUI - the nodes appear under Audio/Segmentation. Two warnings before you do. First, the requirements.txt pulls in openai-whisper, transformers, torch, accelerate, pydub, and opencc-python-reimplemented - that's a heavy install, and ComfyUI already ships torch, so watch that nothing downgrades it (this is the classic custom-node dependency collision; ComfyUI Manager won't protect you from it). Second, Whisper needs the ffmpeg binary on your PATH - it's a system tool, not a pip package, so nothing in requirements.txt will install it for you. And the README's own clone command points at a gitee mirror ([email protected]:dreamidea/comfyui-audio-segment.git) while the canonical repo is the GitHub one above - they're the same project, use whichever works.
Common gotchas
The first run downloads your chosen Whisper model into ComfyUI/models/stt/whisper/ (the node creates that folder automatically), so expect a multi-hundred-MB download for base and roughly 3 GB for large-v3. The transcription runs on GPU if available, but a long file will still take a while - this is not a fast node. If your transcript has paragraphs that don't match what's actually spoken, those clips simply won't appear (the 50% similarity gate), so keep the reference text close to the audio. And if you get a silent clip back, your index math is off - see the Select AudioClip node for how out-of-range indexes behave. Honestly, for a niche pack with almost no community footprint, this one punches above its weight: text-aligned clips plus a subtitle file, all in-graph.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| audio | AUDIO | — | |
| text | STRING | 在此处输入按段落分隔的文本... | — |
| model | COMBO | 7 options: base, large-v1, large-v2, large-v3, medium, small, +1 |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| AudioClip list | * | — |
| size | INT | — |
| srt | STRING | — |