Nodes/ComfyUI-SRT-subtitles-VoxCPM/Load Text from File (Path)
ComfyUI Node

Load Text from File (Path)

Read your subtitle file from disk instead of pasting it into a text box

By judian17·Created 10 months ago·Updated 10 months ago· 7
Load Text from File (Path)
    • STRING
    file_pathC:\path\to\subtitle.srt

    A one-input text loader that exists to keep you from pasting a 200-line SRT file into a text box. Give it a file path and it returns the file's contents as a plain STRING, ready to plug into the srt_text port of the VoxCPM SRT Processor, Dubber, or Auto-Dubber. It's the difference between a workflow you can rerun on a different subtitle file and a workflow where you hand-edit a widget every time.

    How it works

    The single input is file_path (a string, default C:\path\to\subtitle.srt). Before opening the file it strips surrounding quotes - a real quality-of-life touch, because Windows' "Copy as path" context menu loves to wrap paths in "...", and that used to be a classic path-not-found failure mode. It reads the file as UTF-8 first, and if that fails, falls back to GBK, which is a thoughtful nod to the pack's Chinese-speaking users and anyone dealing with legacy-encoded subtitle files.

    Output is a single STRING with the whole file. Wire it into any of the pack's srt_text inputs and you're set.

    What to watch out for

    This node is minimal, and the edges show. If the file doesn't exist, it doesn't throw - it returns a string like Error: File not found at ... on the STRING output. That error string then flows into the SRT Processor, which fails to parse it and raises its own error ("SRT text could not be parsed or is empty"). So the failure is real, just two hops down the line; check the node's log output if you're staring at a parse error you can't explain.

    Also, relative paths resolve relative to wherever the ComfyUI server process is running, which is not always where you think it is - an absolute path is the safer bet. And the file content replaces whatever you'd have typed: if you connect this node to a Processor's srt_text while that widget also has text, the wired value wins.

    Installing it

    Part of the judian17/ComfyUI-SRT-subtitles-VoxCPM pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/judian17/ComfyUI-SRT-subtitles-VoxCPM
    

    Restart ComfyUI, or install via ComfyUI Manager (search "SRT subtitles VoxCPM"). It's categorized under utils rather than audio/tts, and it has zero dependencies of its own - no model, no torch - so it's safe to use even before you've downloaded the VoxCPM model. The language-transfer workflow (SRT_VoxCPM_transfer.json) uses two of these, one per subtitle file, which is the pattern you'll want to copy if you're dubbing into another language.

    Categoryutils

    Inputs (1)

    NameTypeDefaultDescription
    file_pathSTRINGC:\path\to\subtitle.srt

    Outputs (1)

    NameTypeDescription
    STRINGSTRING