🌸Flower Load Text From Folder
Feed a whole novel to TTS one chapter at a time without OOM-ing
- text
- full_path
- file_name
- file_name_no_ext
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.txtfiles live.filter_keyword/negativeKeywordprune the list, and the pattern language is worth learning:A&B|Cmeans "(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 bychars_per_auto_chapter, cutting at line breaks, merging a short tail into the previous block). In chapter modes the reportedfile_namegets 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
textoutput 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_pathfor 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.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| directory | STRING | — | |
| filter_keyword | STRING | — | |
| negativeKeyword | STRING | — | |
| seed | INT | 00–18446744073709550000 | — |
| continuous_processing | INT | 11–9999999 | — |
| sort_mode | COMBO | 2 options: 字母排序(Alphabetical), 自然排序(Natural) | |
| max_chars_per_segmentopt | INT | -1-1–18446744073709550000 | — |
| split_symbolsopt | STRING | ,.?!;:,。?!;: | — |
| split_by_chapteropt | COMBO | 根據章編號分章輸出(第一章) | 3 options: 無, 根據章編號分章輸出(第一章), 根據字數自編章節輸出(4000字合成一章) |
| chars_per_auto_chapteropt | INT | 40001–18446744073709550000 | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |
| full_path | STRING | — |
| file_name | STRING | — |
| file_name_no_ext | STRING | — |