Nodes/ComfyUI_AIIA/💬 AIIA Text Splitter
ComfyUI Node

💬 AIIA Text Splitter

Feed it a wall of narration, get back sentences a TTS can chew on

By havvk·Created about a year ago·Updated 6 months ago· 13
💬 AIIA Text Splitter
    • dialogue_json
    • sentence_count
    text
    speaker_nameNarrator
    split_modeauto
    min_chars4
    max_chars100

    The AIIA podcast pipeline was built around scripts: Speaker: line pairs that a parser turns into structured data, one chunk per line. That's great for two-voice dialogues. It's useless for a single-narrator voiceover, where your "script" is just a wall of prose. This node is the adapter: it takes plain long-form text and splits it into the same dialogue_json structure the script parser produces, so a narrator can flow through the pack's Emotion Annotator → TTS chain exactly like a scripted character.

    The use case that makes it shine: audiobooks, YouTube voiceovers, long single-voice narration where you want per-sentence emotion tagging later. You don't hand-write Narrator: ... for every line - you paste the whole chapter and let this node do the bookkeeping.

    How it works

    It's a sentence splitter with judgment. In the default auto mode it does four things in order: keeps paragraph breaks as structure; splits within each paragraph on sentence-ending punctuation (。!?!?…, including ellipsis); merges any sentence shorter than min_chars into the previous one (so fragments don't become two-second audio blips); and if a sentence runs past max_chars, it re-cuts it at a comma or semicolon. The result is a list of chunks that a TTS can actually speak naturally, each stamped with your speaker_name.

    The other two modes are simpler: by_sentence only splits on terminal punctuation (no merging, no re-splitting), and by_line splits on newlines only - useful when your text is already one-sentence-per-line.

    The inputs that matter

    • text - the long-form text. Multiline; paste it all.
    • speaker_name - default Narrator. This is what gets written into every segment's speaker field, so pick something your downstream nodes expect.
    • split_mode - auto is the right default for most prose. Reach for by_line when your input is already chunked.
    • min_chars (default 4) / max_chars (default 100) - the two tuning knobs. If a short line keeps vanishing into the previous one, raise min_chars... no, lower it. If long sentences keep getting chopped mid-thought, raise max_chars.

    Outputs: dialogue_json (the STRING you wire into Emotion Annotator or a TTS node) and sentence_count (an INT, handy for sanity-checking the split or driving a loop).

    Install

    Standard pack install - this one has no extra dependencies at all:

    cd ComfyUI/custom_nodes
    git clone https://github.com/havvk/ComfyUI_AIIA.git
    

    or ComfyUI Manager → search "ComfyUI_AIIA", then restart.

    Common issues

    • A sentence got cut in the wrong place. That's max_chars doing its job too eagerly - nudge it up, or switch to by_sentence and split the long line yourself.
    • Fragments all over the dialogue JSON. The min_chars merge threshold is too low; the node is faithfully keeping every two-word fragment as its own line. Raise it.
    • The Chinese/English mix. auto handles both, but the character-count thresholds behave differently across scripts - a 100-char Chinese sentence is a lot more speech than 100 English characters. Expect to tune.
    CategoryAIIA/Podcast

    Inputs (5)

    NameTypeDefaultDescription
    textSTRING待拆分的文本。支持多段落、多行。
    speaker_nameSTRINGNarrator说话人名称,写入 dialogue_json 的 speaker 字段
    split_modeCOMBOauto拆分模式: auto: 按句末标点拆分 + 短句合并 + 长句再拆 by_sentence: 仅按句号/问号/感叹号拆分 by_line: 按换行拆分
    min_charsoptINT41–50最小字符数。短于此的句子合并到前一句。
    max_charsoptINT10020–500最大字符数。超长句子在逗号/分号处强制拆分。

    Outputs (2)

    NameTypeDescription
    dialogue_jsonSTRING
    sentence_countINT