Nodes/comfyui-flower-tools/🌸Flower Load Text From Folder
ComfyUI Node

🌸Flower Load Text From Folder

Feed a whole novel to TTS one chapter at a time without OOM-ing

By weichenglin0215·Created 8 months ago·Updated 2 months ago· 0
🌸Flower Load Text From Folder
    • text
    • full_path
    • file_name
    • file_name_no_ext
    ◄directory►
    ◄filter_keyword►
    ◄negativeKeyword►
    ◄seed0►
    ◄continuous_processing1►
    ◄sort_mode▾►
    ◄max_chars_per_segment-1►
    ◄split_symbols,.?!;:,。?!;:►
    ◄split_by_chapter根據章編號分章輸出(第一章)►
    ◄chars_per_auto_chapter4000►

    Here's the problem Flower Load Text From Folder was built to solve, and it's a real one: ComfyUI TTS pipelines like Qwen-TTS choke on ultra-long inputs - feed them a whole novel chapter as one text blob and you get an out-of-memory crash or a garbled read. The community fix people reach for first is "split your files into ≤1000-character chunks by hand," which is miserable. This node automates the whole thing: it reads .txt files from a folder, chops long text into segments at sensible boundaries (even chapter-aware), and hands you one segment per execution, driven by a seed - so the TTS reads piece by piece and never sees the whole book at once.

    What it outputs

    text is the payload. The other three outputs are the real convenience: full_path, file_name, and file_name_no_ext - strings describing which file (or virtual chapter segment) the current text came from. That's what lets you save each narrated segment under a matching name instead of guessing later.

    The knobs that matter

    • directory - where the .txt files live. filter_keyword / negativeKeyword prune the list, and the pattern language is worth learning: A&B|C means "(A AND B) OR C", and blank means no filtering.
    • seed + continuous_processing - your position in the file list (or segment list). continuous_processing > 1 holds the same pick for that many consecutive images/runs.
    • max_chars_per_segment - the core dial. -1 (default) reads whole files; set it to e.g. 500 and the node segments text and steps through segments seed-by-seed, cutting at punctuation (split_symbols) so it never chops mid-sentence.
    • split_by_chapter - the dropdown with three modes. 無 (no chapter logic, just char-count segments), 根據章編號分章輸出(第一章) (detect 第X章 headings - Chinese or Arabic numerals, brackets tolerated - and keep each chapter's audio self-contained, default), and 根據字數自編章節輸出(4000字合成一章) (auto-chunk by chars_per_auto_chapter, cutting at line breaks, merging a short tail into the previous block). In chapter modes the reported file_name gets a label like 喜寶-V400-AI語音用-001第一章-0001-984, so saved audio files carry their chapter on the filename.

    There's a Refresh button that runs the real backend logic without executing the graph - it updates a content preview and the virtual segment list, which is genuinely handy for checking "is my chapter detection working" before you burn GPU time.

    Why it exists

    The README is explicit: this node exists because Qwen-TTS crashed on long text, and manual splitting was the workaround. The intended pipeline is FlowerLoadTextFromFolder → FlowerSplitSentences → TTS, optionally with FlowerFileNameCombination naming the output audio. If you're narrating audiobooks or long-form voiceover in ComfyUI, this is the missing middle - it's the only node in the pack whose whole identity is "make long text survivable for TTS."

    Install

    cd ComfyUI/custom_nodes
    git clone https://github.com/weichenglin0215/comfyui-flower-tools.git
    

    Restart (or ComfyUI Manager → search ComfyUI Flower Tools). No models, no downloads.

    Gotchas

    • Segmentation only kicks in at max_chars_per_segment ≥ 256. Set it below that and the node falls back to whole-file reading. The exact threshold matters more than the README lets on.
    • The text output changes per seed, but the graph only re-runs when the seed or settings change - that's normal ComfyUI caching, not a bug. Bump the seed to step through segments.
    • full_path for a virtual chapter is virtual - it points at the source file with a synthetic chapter-suffixed name, not a real on-disk file. Fine for naming saves, but don't try to open that path directly.
    • Encoding is assumed UTF-8; files in other encodings can read back as mojibake.
    Categoryflower-tools

    Inputs (10)

    NameTypeDefaultDescription
    directorySTRING—
    filter_keywordSTRING—
    negativeKeywordSTRING—
    seedINT00–18446744073709550000—
    continuous_processingINT11–9999999—
    sort_modeCOMBO2 options: 字母排序(Alphabetical), 自然排序(Natural)
    max_chars_per_segmentoptINT-1-1–18446744073709550000—
    split_symbolsoptSTRING,.?!;:,。?!;:—
    split_by_chapteroptCOMBO根據章編號分章輸出(第一章)3 options: 無, 根據章編號分章輸出(第一章), 根據字數自編章節輸出(4000字合成一章)
    chars_per_auto_chapteroptINT40001–18446744073709550000—

    Outputs (4)

    NameTypeDescription
    textSTRING—
    full_pathSTRING—
    file_nameSTRING—
    file_name_no_extSTRING—