Nodes/comfyui_epub_tts/Load EPUB File
ComfyUI Node

Load EPUB File

Getting a Book Out of an EPUB and Ready for a Voice

By kallama·Created 7 months ago·Updated 7 months ago· 0
Load EPUB File
    • epub_data
    epub_file
    skip_keywordsabout, acknowledgement, acknowledgment, colophon, copyright, cover, dedication, front, nav, praise, preface, title, toc
    front_matter_keywordschapter, part, prologue
    require_int_chapters
    min_text_length1

    Every audiobook workflow in this pack starts here. LoadEPUB is the front door of comfyui_epub_tts: it reads a .epub from your ComfyUI input folder, strips out all the book scaffolding, and hands the real content to the rest of the graph as a SPINEWALKER object.

    The part that matters more than you'd think: an EPUB isn't a text file. It's a zip of HTML documents plus a "spine" that says what order to read them in, and it's stuffed with copyright pages, dedications, tables of contents, and cover art. If you just dumped that at a TTS model you'd get a minute of "Nav. Table of contents. Copyright" before the book started - and the model would say all of it. This node is the filter that makes the difference between an audiobook and a robot reading a website.

    What it actually does

    Under the hood it uses ebooklib to read the book, then builds a SpineWalker that walks the spine and keeps only actual document content. The filtering is where you have control:

    • skip_keywords - a comma or newline-separated list of keywords matched against each file's idref or filename: about, acknowledgement, colophon, copyright, cover, dedication, front, nav, praise, preface, title, toc by default. That's your front-and-back-matter filter.
    • require_int_chapters - default true, and the sneaky one. It rejects any chapter whose filename has no digits in it. Most real EPUBs name chapters like ch_001.xhtml or 001.xhtml, and non-numeric files are usually navigational junk. If your book has chapter files named chapter-one.xhtml, you'll want this off.
    • front_matter_keywords - chapter, part, prologue by default. Used to detect the first real chapter: anything before the first page that mentions one of those words gets rejected as front matter.
    • min_text_length - drops near-empty pages (default 1, so basically only blank pages).

    Then comes the part nobody sees: each kept page's HTML gets run through BeautifulSoup (which drops <details> blocks) and trafilatura (which extracts main content and throws away tables, comments, and images - tables sound like gibberish read aloud). URLs get stripped and whitespace collapsed, because a TTS model will cheerfully read out a 40-character web address. The output epub_data is that clean text, packaged as the pack's internal SPINEWALKER type.

    The inputs that matter

    The dropdown epub_file is the one you'll actually touch - it lists every .epub in your ComfyUI input folder (yes, that means the book has to live in ComfyUI/input, and you may need to refresh/restart for a new file to show up). skip_keywords is the second most useful knob when a book's front matter doesn't match the defaults. The epub_data output only plugs into PreviewEPUB or EPUBChapterSplitter - that custom type is deliberate, so don't expect it to connect to arbitrary text nodes.

    Install

    ComfyUI Manager (search comfyui_epub_tts) or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/kallama/comfyui_epub_tts
    

    Restart ComfyUI, then drop your book in ComfyUI/input. Dependencies are ebooklib, bs4, and trafilatura - all lightweight, no model files. Two honest warnings: it needs DRM-free EPUBs (ebooklib will choke on a locked Kindle-era file - it's not a DRM stripper), and the pack is a young v0.0.1 with a boilerplate README, so if the defaults misbehave, tweak the keyword lists rather than hunting for documentation.

    CategoryEPUB TTS

    Inputs (5)

    NameTypeDefaultDescription
    epub_fileCOMBO0 options:
    skip_keywordsoptSTRINGabout, acknowledgement, acknowledgment, colophon, copyright, cover, dedication, front, nav, praise, preface, title, tocComma or newline separated keywords to skip (idref or filename)
    front_matter_keywordsoptSTRINGchapter, part, prologueKeywords used to detect the first real chapter
    require_int_chaptersoptCOMBO2 options: true, false
    min_text_lengthoptINT10–10000

    Outputs (1)

    NameTypeDescription
    epub_dataSPINEWALKER