Nodes/ComfyUI-DN-VoxCPM/VoxCPM Text From File
ComfyUI Node

VoxCPM Text From File

Text From File — stop pasting your script into a text box

By DekaNear·Created 9 months ago·Updated 9 months ago· 1
VoxCPM Text From File
    • text
    file_path
    json_keytext

    There comes a point in every TTS project where the text stops being a sentence and becomes a script, and pasting a three-thousand-word chapter into a multiline box gets old fast. VoxCPM Text From File exists for that moment: it reads a file off disk and hands its contents to the graph as a plain STRING, ready to feed into a VoxCPM TTS node. It's a text loader with one narrow trick, and it's exactly the right kind of boring.

    The inputs

    • file_path - where the file lives. This one takes a real path (no input-folder auto-search like the audio loader); on Windows C:/Users/you/scripts/line1.txt, on Linux /home/you/scripts/line1.txt.
    • json_key (optional, default "text") - only matters for JSON files, explained below.

    Output is text (STRING). Wire it into VoxCPM Text-to-Speech or VoxCPM Batch TTS and your script stays on disk where it belongs.

    What it reads

    Two formats, handled sensibly:

    • .txt - the file's contents, verbatim.
    • .json - a bit smarter. If the JSON is an object, it pulls the value under json_key (so {"text": "…", "style": "…"} gives you the text field). If it's a list, it joins the items with newlines - handy when an LLM script generator hands you an array of lines.

    Anything else (.md, .csv, whatever) throws an "unsupported file format" error. Keep to txt or json.

    Installing it

    Part of the ComfyUI-DN-VoxCPM pack:

    cd ComfyUI/custom_nodes/
    git clone https://github.com/DekaNear/ComfyUI-DN-VoxCPM.git
    cd ComfyUI-DN-VoxCPM
    pip install -r requirements.txt
    

    Restart ComfyUI, or install "DN VoxCPM" from ComfyUI Manager.

    Where people get burned

    It's a plain utility, so the failures are plain too. The file has to exist at the exact path you give it - the node doesn't search folders for you, and a wrong path raises "file not found" rather than guessing. The other common stumble: pointing it at a .txt when your data is JSON, or vice versa. And for batch work, remember the loader just dumps the whole file into the STRING - if your script is one big text blob, feed it to Batch TTS (which splits on newlines) rather than the single-shot node, which will happily try to read the whole thing as one utterance.

    CategoryDN-VoxCPM/Advanced

    Inputs (2)

    NameTypeDefaultDescription
    file_pathSTRING
    json_keyoptSTRINGtext

    Outputs (1)

    NameTypeDescription
    textSTRING