Nodes/Index Translate · T8star-Aix/Index Translate SRT 字幕翻译
ComfyUI Node

Index Translate SRT 字幕翻译

Subtitle Translation That Never Leaves Your Machine

By T8mars·Created 22 days ago·Updated 16 days ago· 9
Index Translate SRT 字幕翻译
    • translated_srt
    • file_path
    • metadata
    ◄model_pathIndex-Translate-2B►
    ◄sourcezh►
    ◄targeten►
    ◄device▾►
    ◄precision▾►
    ◄output_budget256►
    ◄context_limit4096►
    ◄srt_text1 00:00:00,000 --> 00:00:02,000 你好,世界。 2 00:00:02,500 --> 00:00:05,000 欢迎使用本地字幕翻译。 ►
    ◄bilingualfalse►
    ◄save_filetrue►
    ◄filename_prefixIndexTranslate/subtitles►
    ◄glossary{}►
    ◄srt_file►

    Subtitle translation is the one job in this ecosystem where people still reflexively reach for an API - a DeepL key, a browser extension. Fine, until you want zh→en on a 40-minute clip, offline, or on something you'd rather not upload. Index Translate SRT 字幕翻译 does it as a node: hand it an SRT, get back an English SRT with the original numbering and timecodes intact.

    Despite the name, there's no server and no key. It's a local model running in ComfyUI's own Python.

    What it actually is

    The model is Index-Translate from IndexTeam (bilibili) - a translation-tuned 2B/9B, Apache-2.0, on a Qwen-family backbone. T8star-Aix wrapped it for ComfyUI; the pack ships a plain-text node too, but this is the one worth installing. Subtitle text has structure that a chat LLM will happily shred, and this one refuses to.

    The mechanism is narrower than "the model translates subtitles." The pack's subtitles.py does the structural work in plain Python: parse the SRT, validate the timing, send only the cue body to the model. Numbering, timecodes and blank-line blocking never touch it, which is why they can't come back mangled. Inline formatting (<i>, <b>, <u>, <font>, ASS-style {\...} tags) becomes %%IT_srt_...%% placeholders, translated as opaque tokens, then restored - with a count check afterward, so you get an error instead of a file with broken italics.

    Decoding is greedy (do_sample=False) with thinking disabled, and the prompt is a bare instruction to translate and output nothing else. You're running a translation function, not chatting with a model.

    The inputs that matter

    Defaults are source: zh → target: en, and target may not be auto - pick a code or a language name. Beyond that:

    • srt_text / srt_file - paste the subtitle, or give srt_file a path (relative paths resolve against ComfyUI's input folder). If srt_file has a value it wins and srt_text is ignored.
    • model_path - a folder name under ComfyUI/models/index_translate/, e.g. Index-Translate-2B, or an absolute path to a full model directory.
    • output_budget (default 256) - the token budget per cue, and the knob you'll touch most, because one truncated cue aborts the whole run.
    • bilingual (default false) - original text above the translation. Great for review passes, terrible if you're burning it into a video.
    • save_file / filename_prefix - on by default, writing output/IndexTranslate/subtitles_00001.srt (UTF-8 with BOM, CRLF), always counter-suffixed so nothing is overwritten. The real path comes back on file_path.
    • Optional glossary - a JSON object of term pairs, max 100 entries, injected into the prompt. {"ComfyUI": "ComfyUI"} is the point: keep product names out of the translator's hands.

    Outputs are translated_srt (the whole file as a string - wire it into a text preview or save node), file_path, and metadata (cue count, timing-preserved flag, languages, budget). It's an output node, so it always runs and reports the saved path on the node itself. Limits: 1 MiB, 5000 cues, 12000 characters per cue, UTF-8 / UTF-16 with BOM / GB18030.

    Install

    ComfyUI Manager, search Index Translate · T8star-Aix. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/T8mars/Comfyui-Index-Translate-T8 Comfyui-Index-Translate-T8
    # use ComfyUI's OWN python here
    python -m pip install -r Comfyui-Index-Translate-T8/requirements.txt
    

    Then get weights: the full Index-Translate-2B (or 9B) folder from huggingface.co/t8star/Index-Translate-Comfy, dropped into ComfyUI/models/index_translate/ unchanged - a relative model_path is pinned to that folder. Or let the pack fetch and SHA256-verify it:

    python ComfyUI/custom_nodes/Comfyui-Index-Translate-T8/download_model.py \
      --directory /path/to/ComfyUI/models/index_translate/Index-Translate-2B --model 2B
    

    Start with 2B: ~4.5 GB on disk, roughly 4.24 GiB of VRAM in bf16, ~10.5 GiB of free RAM on CPU/fp32. The 35B preview is catalogued but ships incomplete shards, so it won't load. NF4 (requirements-nf4.txt) and ConvRot INT8 (install_convrot.py on Windows) are optional speed paths, both reversible - ConvRot rollback is deleting one .pth and restarting.

    Where people get burned

    You need a real SRT, not a transcript. Feed it a wall of dialogue and the parser rejects it - the error literally says plain text can't establish a timeline. Get timecodes first.

    requirements.txt pins transformers==5.17.0. Classic dependency-hell shape: same environment as every other pack you own, and the README says check compatibility before upgrading. It does not touch torch, and the node's own error is blunt about that - install with the right Python and don't swap torch.

    Truncation kills the run, not the file. Hit the per-cue budget and you get a clear error and no output file, rather than half a subtitle track. Raise output_budget; the hard ceiling is arithmetic, since input tokens plus budget must fit under context_limit (default 4096, max 32768), so raise that too for long cues.

    The precision gates are real. bf16 and convrot-int8 want NVIDIA Ampere or newer and error out before loading weights. auto picks sensibly - bf16 on modern CUDA, fp32 otherwise, CPU if the arch or VRAM doesn't fit. NF4 is CUDA-only. And if you have optional kernels like FLA or Triton installed without a C compiler, 0.1.24+ falls back to the reference implementation and keeps translating: update and restart, don't install Visual Studio, don't set CC by hand.

    One model load per run. It loads once for the file and releases at the end, so a 900-cue SRT isn't 900 loads - the first cue just pays the load cost, and an identical re-run is cached. Change the subtitle, model folder or glossary and it re-translates.

    The Windows integrated package this README keeps mentioning? Irrelevant here. The node doesn't call it, doesn't share its Python, and doesn't need it running.

    CategoryIndex Translate

    Inputs (13)

    NameTypeDefaultDescription
    model_pathSTRINGIndex-Translate-2B—
    sourceSTRINGzh—
    targetSTRINGen—
    deviceCOMBO3 options: auto, cuda, cpu
    precisionCOMBO5 options: auto, bf16, fp32, nf4, convrot-int8
    output_budgetINT2561–32704每条字幕的输出预算。
    context_limitINT4096256–32768—
    srt_textSTRING1 00:00:00,000 --> 00:00:02,000 你好,世界。 2 00:00:02,500 --> 00:00:05,000 欢迎使用本地字幕翻译。 粘贴完整 SRT;仅翻译正文,保留序号和时间轴。
    bilingualBOOLEANfalse—
    save_fileBOOLEANtrue—
    filename_prefixSTRINGIndexTranslate/subtitles保存在 ComfyUI output 目录。
    glossaryoptSTRING{}—
    srt_fileoptSTRING有值时读取此文件,忽略 srt_text;相对路径位于 ComfyUI input 目录。

    Outputs (3)

    NameTypeDescription
    translated_srtSTRING—
    file_pathSTRING—
    metadataSTRING—