Long Text Splitter (ASA)
Chop a Wall of Text Into TTS-Sized Chunks Without Splitting a Sentence
- text_chunks
- text_chunks_length
Long Text Splitter (ASA) exists because text-to-speech engines have a ceiling: feed one an entire 3,000-character chapter and you get a degraded, glitchy, or truncated read. The fix is to cut the text into chunks small enough for the TTS model to handle cleanly, synthesize each chunk, then stitch the audio back together - which is exactly the pipeline this pack is built around. This node is the front end of that pipeline: give it a wall of text, get back a list of sensible, length-capped chunks plus the chunk count.
That second output is the quietly important one. text_chunks_length is what your for loop uses as its iteration bound - pull chunk N with Index Select From List, synthesize, Make Audio Batch the results, and Combine Audio From List reassembles the finished narration. The whole pack is downstream of this node.
How it works
It's a regex-and-rejoin splitter with a few genuinely thoughtful touches. You pick one of three modes:
- sentence - splits on sentence-ending punctuation (Chinese and English:
。!?.!?) and newlines. - paragraph - treats blank lines as boundaries, recognizes markdown-ish
---separators, and even spots short title lines without punctuation and keeps them as their own chunk. - custom - splits on whatever delimiter string you supply.
Two protections stand out because they're the kind of thing that silently ruins TTS if handled wrong: URLs are stashed aside before splitting so https://example.com doesn't get torn apart at a period, and decimal/number dots are protected too - 3.14 stays 3.14, and "Section 1." doesn't get split at the dot. Any chunk that still exceeds max_length is further cut, breaking at the last space where one exists.
The inputs you'll actually touch
- text - the input, multi-line. Obvious.
- split_mode -
sentence(default),paragraph, orcustom. Sentence is the safe default for narration. - max_length - max characters per chunk,
50–1000, default200. Lower for strict TTS limits, higher for more context per line. - overlap - characters of the previous chunk's tail carried into the next,
0–100, default0. Only turn this on if your TTS needs the running context; it duplicates audio on the seam. - custom_delimiters - the split characters, used only in
custommode. - filter_chars - a list of characters to strip entirely (e.g.
#$%). Leave empty for no filtering.
Outputs: text_chunks (LIST) and text_chunks_length (INT).
Installing it
Part of whmc76/ComfyUI-AudioSuiteAdvanced (display "AudioSuiteAdvanced"). ComfyUI Manager → search "AudioSuiteAdvanced", or:
cd ComfyUI/custom_nodes
git clone https://github.com/whmc76/ComfyUI-AudioSuiteAdvanced
cd ComfyUI-AudioSuiteAdvanced
pip install -r requirements.txt
Restart ComfyUI. No models needed for this node itself.
Where people get burned
The overlap knob is the trap. It sounds like free context, and for some TTS backends it is - but the overlapping text gets synthesized again in the next chunk, so you can end up with stuttered words at every seam once the audio is concatenated. Start at 0; only raise it if your model reads the seam awkwardly.
Second, the CJK reality: sentence and custom modes split on punctuation, which works great for Chinese and Japanese. But when a chunk exceeds max_length and there's no space to break at, the hard cut lands mid-character-sequence. For Chinese text that's usually fine - characters stand alone - but it can split a number or a name across a boundary. Watch the first chunk boundary in your transcript before committing to a long run.
And the classic: this node is language-agnostic plumbing, so don't expect it to understand anything. It cuts at punctuation and length, not meaning. Feed it your script, glance at the output list once, and let the TTS do the rest.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| split_mode | COMBO | sentence | 3 options: sentence, paragraph, custom |
| custom_delimiters | STRING | 。!?.!? | — |
| max_length | INT | 20050–1000 | — |
| overlap | INT | 00–100 | — |
| filter_chars | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| text_chunks | LIST | — |
| text_chunks_length | INT | — |