Nodes/ComfyUI-lethris-dia2/💬 Dia2 Captions Generator
ComfyUI Node

💬 Dia2 Captions Generator

The boring half of this pack is the useful half

By lord-lethris·Created 9 months ago·Updated 9 months ago· 1
💬 Dia2 Captions Generator
    • caption_text
    timestamps_json[]
    modePer Word
    formatSRT
    save_outputtrue

    The Dia2 Captions Generator does one small, specific job: it takes the word-by-word timestamps coming out of the 🗣️ Dia2 TTS Generator and turns them into actual subtitle files - SRT, VTT, or ASS/SSA. No transcribing, no Whisper pass, no guesswork. Most TTS gives you audio and nothing else; Dia2 hands you per-word alignments for free, and this node is what makes them useful.

    Why would you bother? Because the same pack that makes your multi-speaker dialogue audio also makes its subtitles, in one pass, with the timestamps locked to the exact audio you generated. That's a workflow killer for AI character dialogue videos, lip-sync projects (subtitles synced to the same audio you feed the lip-sync model), or just getting a transcript file out of a podcast-style script. Doing this by hand - or by running Whisper over audio you already generated - is slower and more error-prone than it has any right to be.

    How it works

    The TTS node returns timestamps_json, a JSON list of [word, seconds] pairs (seconds, not frames - the pack converts internally). This node parses that list, groups the words according to the mode you pick, and renders the groups into the caption format you pick. Simple, no model involved, nothing to download beyond what the pack already installed.

    The grouping modes matter more than they look:

    • Per Word - every word gets its own caption (0.5 seconds each). Honestly a niche mode; it's there for word-level karaoke-style overlays.
    • Sentence - groups words up to the next ., !, or ?. The one you'll use for normal subtitles.
    • Sentence Advanced - the same, but it also breaks on closing parentheses, so an inline action like (laughs) ends up on its own caption line instead of glued to the dialogue. If your script is full of Dia2 action tokens, use this mode.

    Formats are standard: SRT and VTT are nearly identical (different timestamp separators), ASS/SSA gets a full Script Info header with Arial 48 styling you can then edit in a subtitle tool. All of them are written to ComfyUI/output/captions/ with unique filenames - the node appends _001, _002 instead of overwriting, which is a thoughtful touch.

    The inputs

    There are only four, and you'll set two:

    • timestamps_json - a STRING. Wire this to the timestamps_json output of the Dia2 TTS Generator. That's the whole point of the node.
    • mode - Per Word, Sentence, or Sentence Advanced (default Per Word; switch to Sentence).
    • format - SRT, VTT, or ASS/SSA (default SRT).
    • save_output (optional) - whether to write the file to output/captions alongside returning it.

    The single output, caption_text, is a STRING containing the full subtitle file - you can save it anywhere with a standard text-save node, or preview it to check the alignment.

    Install and gotchas

    It ships in the same pack as the TTS node, so you're installing both at once: ComfyUI Manager (search "Dia2 TTS & Captions Generators for ComfyUI") or

    cd ComfyUI/custom_nodes
    git clone https://github.com/lord-lethris/ComfyUI-lethris-dia2
    cd ComfyUI-lethris-dia2
    pip install -r requirements.txt
    

    then restart. No extra model files for this node - the heavy lifting (the ~7.7 GB Dia2-2B weights in models/Dia2/) belongs to the TTS side.

    Where people trip up: feeding the node anything that isn't the TTS node's actual timestamps_json. If you paste [] or some other JSON shape, you get nothing (or a JSON parse error). And remember the TTS node's two-minute generation cap still applies - a longer script needs splitting before you caption it. For the rest, it just works, which is more than you can say for most of the audio layer in ComfyUI.

    Categorylethris🧠/Dia2

    Inputs (4)

    NameTypeDefaultDescription
    timestamps_jsonSTRING[]
    modeCOMBOPer Word3 options: Per Word, Sentence, Sentence Advanced
    formatCOMBOSRT3 options: SRT, VTT, ASS/SSA
    save_outputoptBOOLEANtrue

    Outputs (1)

    NameTypeDescription
    caption_textSTRING