Electron Stories and Audiobooks¶
Historical context: this page was written while the Electron and Tauri apps coexisted. Mentions of Tauri helpers, pages, tests and regression results describe that migration period; the Tauri shell has since been removed and the shared code now lives in
electron/src/shared/. Existing Tauri installs: see the migration guide.
Stories and Audiobook are available from the sidebar and command search. Each keeps a separate draft. Choose a saved default voice, enter or import text, then render. Stories supports per-line voice overrides; chapter headings and pause markup use the same storyToSpans compiler as Tauri. Both pages accept [pause 500ms] and [pause 0.5s]; samples, placeholders and the Insert pause buttons all show the seconds form, and markup in every locale's placeholder stays literal ([pause 0.5s], [voice:NAME]). [emotion:TEXT] sets a per-line emotion that resets at each [voice:] and chapter (each line in Stories); the Audiobook toolbar's Emotion button inserts it, grayed with the reason on engines that ignore emotion (see expressive-speech.md). Characters the Audiobook script names but has not cast yet get one calm note (they read in the main voice) instead of a warning per name. Audiobook submits the original script to the existing backend parser.
Plain-text audiobook imports recognize chapter-title lines with LF, CRLF or CR line endings. Manuscripts with existing Markdown H1 headings retain their explicit structure and original text.
In Stories, a line's Merge with next action joins it to the following line
when both have the same speaker, voice override and speed setting. Different
explicit choices stay separate, even when they currently resolve to the same
voice or speed. Chapter headings and busy editors cannot be merged. The first
line keeps its identity and settings, both texts remain in order, and plain
prose becomes one spoken passage. Bracket-bearing text gets a visible [voice:]
reset at the former boundary so inline voice, emotion, prosody and pause scopes
remain independent. The merged line saves with the draft and named project.
Both editors use the shared longform backend, real chapter progress, assembly status, and an explicit Stop action. Progress moves with every synthesized chunk, not only at chapter boundaries: the backend streams live progress events (book-wide fraction, time left, realtime factor and mean chunk time; not stored in job history), and the tracker shows the percentage, elapsed time, time left and the realtime factor (seconds of audio produced per second of rendering). Time left comes from the rolling rate of the most recent freshly synthesized chunks; chapters and lines served from cache move the bar but never the rate, so a resumed render does not look instantly done. If no chunk lands for six typical chunk times (at least two minutes; ten before the first chunk, which can include a model load) the tracker says the render looks stalled and points at Logs → Backend. The elapsed clock survives leaving and reopening the page. Older backends without progress events fall back to the chapter-count estimate, which ignores cached chapters. Stop aborts the HTTP stream so the backend stops scheduling chapters. A truncated stream cannot replace the last successful output. Interrupted server manifests can be resumed explicitly without sending the edited manuscript again. Each page lists only its own interrupted renders (stories on Stories, books on Audiobook), one card per project with the newest manifest; a disabled Resume says why (text-to-speech not ready, or another render running), and Dismiss hides that project's cards on this device. Navigation leaves a render running; a renderer restart disconnects it and recovery uses the server manifest inventory.
Generation is separate from playback and export. Vidstack provides the player, with a seek bar instead of decoding a full waveform for long audio; Play becomes available after the native media provider reports that it is ready. The existing backend produces MP3 and M4B, and the native export dialog saves a local copy. A completed render also offers a cue sheet through that dialog: a .txt file with one HH:MM:SS<TAB>Title line per rendered chapter. This is useful for show notes, podcast services, and players that ignore embedded chapters—M4B embeds them, while MP3 cannot. The timestamps sum the same whole-millisecond chapter durations used for the M4B metadata, so their whole-second, unbounded-hour values match the embedded starts. Failed chapters add neither a line nor elapsed time.
Draft writes reuse the coalesced persistence helper and flush on lifecycle events. Working drafts currently use browser storage. Named Stories and Audiobook projects use the shared native IndexedDB adapter in a separate Electron database. Saves await the committed transaction, concurrent writes are serialized, and opening or deleting a project requires confirmation. Projects include script/lines, voices, settings and the last output reference. Storage failures are surfaced. Book details include author, narrator, year, genre, description and an uploaded JPEG/PNG cover. Loudness offers off, ACX and podcast presets. Audiobook pronunciation rows reach the existing lexicon engine; duplicate words are flagged before rendering. These settings persist with the draft. Full cast management and other advanced controls remain tracked in electron/PARITY.md.
Saved audio and connections¶
Completed Stories and Audiobook results stay with the VoiceStudio connection that rendered them. Switching to another local data directory or remote computer keeps the editable text and each connection's latest result; its player appears only when that connection is selected and ready. A verified, app-managed local data directory has an opaque identifier, so local port changes retain its result. Attached or otherwise unverified local directories use the current connection only: a fresh render remains usable, while a restart or reload needs an explicit check for older audio. Identity discovery never delays backend readiness. Opening or starting another project replaces the current workspace's result slots without deleting saved projects or rendered files.
Older results and imported projects whose connection is unknown keep their saved details without automatically requesting audio. Use Check saved audio on this connection to check that filename through the current authenticated connection. This checks availability only: a matching filename may contain a different file. The warning and original saved details remain available after a successful check, including after reopening the app. No request goes directly to a previous connection. A connection change, authentication reset, new render, new project or data reset cancels a pending check, and its late reply cannot adopt the result. Restoring a valid session for the same connection makes its saved result available again.
Connection records stay in private local draft persistence without local data paths or credentials. Older path-based records lose their automatic association but retain their saved result details for an explicit availability check. Saving a named project retains its result details even when another connection hides the player; replacing that workspace from a dub still asks before discarding it. Home does not open a project over an active Stories or Audiobook render. Named projects carry only an opaque result-owner token, not connection endpoints, local data paths, credentials or other connections' cached results. Availability-only results carry no ownership token in a named project; reopening that project requires another explicit availability check. The app's private working session keeps its checked state and warning across reloads. An unknown token requires the same explicit availability check. This behavior does not establish the cause of an interrupted render or a slow generation.
electron/tests/longform-smoke.mjs verifies the main flows with mocked generation and real audio playback. Runtime tests cover stop, duplicate prevention, truncated responses, explicit resume and shared Stories compilation. Real installed-model verification passed for one English chapter: MP3 rendering, cached WAV chapter audition, and Electron-driven M4B rendering/playback. Multi-voice, multi-chapter, cancellation/recovery and other engines still require real runtime coverage.
Script voice tags now expose saved-profile assignments in the Cast section. Only names present in the current script are sent as voice_map; assignments persist for reuse if a tag is reintroduced. An assignment to a removed profile blocks rendering until changed or reset to Default. Chapter, word and estimated runtime counts reuse the Tauri script helpers.
Audiobook Preview plan uses the backend parser and exposes per-chapter auditions. Auditions send the same voice, cast, language and pronunciation inputs as full renders, warming the shared cache. Editing those inputs clears stale auditions. Preview requests are aborted on navigation, never replace a full render, and expose their own Vidstack playback.
Production overrides now expose synthesis steps, guidance, sampling temperatures, postprocessing, seed and repeat variation. Emotion controls appear when the active engine advertises support. Reset restores the shared Tauri defaults; untouched fields are omitted from requests. The extracted longformOverrides helper is used by both apps, and chapter auditions carry the same overrides as full renders. Seamless-join controls (gap between lines, gap between paragraphs, trim engine silence) live in the same panel; untouched or reset controls show the preserved server defaults (zero gaps, trimming off). Set gaps and enable trimming explicitly for seamless joins; see docs/expressive-speech.md.
Run electron/tests/longform-live.mjs with VOICESTUDIO_LIVE_PROFILE set to a local saved profile for an explicit real-render check. It verifies the active model is already installed before synthesis. The real run exposed missing JSON request headers in the shared client and array-shaped failed-chapter results; regression tests now cover both.
Stories now includes named characters with saved voice assignments, character selection per line, explicit per-line voice overrides, shared/global speed and per-line speed overrides. Voice resolution and chapter compilation reuse the Tauri helpers. Lines move up/down with keyboard-accessible buttons; chapter insertion uses the same heading grammar. A story with every spoken span assigned can render without an unnecessary default-voice selection. Removed profiles block rendering rather than silently changing the voice. The book-wide speed lives in the Stories setup card, under the voice list. When some lines carry their own speed, the card says how many and offers one click to clear those overrides so the whole book follows the slider.
Stories Auto-cast accepts tagged dialogue, screenplay text and attributed prose with LF, CRLF or lone-CR line endings. The shared local parser appends lines, reuses existing characters/voices, and assigns available profiles to new speakers. Distinct names that normalize to the same identifier remain separate characters. No network or LLM call is involved.
A Stories script can also be built from a finished dub, which replaces the current script, cast and pending import with the dub's speakers and lines. The action lives in the Dub workspace; see docs/electron-dubbing.md.
WebVTT (.vtt) captions also import locally. Stories extracts dialogue from blocks that start with a valid timing line, optionally preceded by a cue identifier. It skips comments and blocks without a timing line in either position.
Paste & Split offers three presets: Sentences (size-limited, with a max-characters field), Paragraphs (split at blank lines, the default) and Chapters (one line per chapter body). A # Heading line is always its own line, in every preset.
Stories imports TXT, Markdown and SRT locally; EPUB/PDF still use the shared backend importer. The EPUB importer skips marked pagination and ancillary sections such as cover, title, dedication, contents and copyright pages. Unmarked pages are judged by the book's own structure: only a short, heading-less, unlisted page ahead of the reading start is skipped, even when an EPUB 2 guide or EPUB 3 landmark declares that start; headed or substantial unlisted prologues are retained; the same kind of stray page is skipped at the back only once back matter that the contents lists has begun, so an unlisted file that continues the last chapter is always kept. Publisher and bibliography headings such as “Published by” and “Novels by” are skipped only on short, unlisted pages before the reading start; an ambiguous heading alone (for example “Works”) is not enough to delete a section. Unmarked numeric paragraphs and page-break layout classes remain narration. Chapter titles prefer the EPUB 3 table of contents, then NCX labels and headings; namespace aliases and declared encodings are supported. Malformed optional navigation falls back to headings, while malformed package/container XML reports an import error. Imported text goes into a persisted review buffer, then Auto-cast or Split into lines appends to existing work. The splitter is shared with the browser app and offers three presets: Sentences (the sentence-aware splitter with the same 40-2000 character limit), Paragraphs (the default; one line per blank-line paragraph, or per line when the text has no blank lines at all; LF, CRLF and lone-CR endings are all understood) and Chapters (one line per chapter body, split only at chapter headings — a non-empty # Title, the same grammar the renderer uses). A chapter heading is always its own line so it renders as a chapter marker.
The Electron workspace keeps title, default voice, language and output format together in a fixed setup card. Advanced cast, production and book controls use separate collapsed cards; starting a new project, saving, opening and deleting named projects sit in the pane's Projects tab beside the controls. New project starts an empty draft after a confirmation; saved projects are never changed by it, and any of them can be reopened later to change voices or the cover and render again. The editor keeps its full working width; an empty Story shows one Add First Line action, while an empty Audiobook shows the supported chapter and voice markup directly in the script field.
Stories line auditions reuse the shared WAV assembler and canonical voice/pause/speed parser. Auditions resolve inline names with the same fallback as full renders, expose Stop, and play through Vidstack independently. Changing synthesis inputs clears stale playback; navigation aborts pending auditions. Browser coverage verifies actual playback with mocked generation.
The optional Stories Stems section renders one WAV per character with the shared Tauri assembler. It reports completed character groups, supports cancellation, and offers explicit individual downloads after completion. No automatic multi-file download is triggered. Input changes discard stale download links. Browser regression checks all character groups and the downloaded WAV bytes. The shared native Save As bridge writes renderer-generated bytes in packaged Windows and Linux builds; macOS remains the native export gate.
EPUB local manifest and navigation links support percent-encoded filenames, including spaces and Unicode. Percent escapes are decoded once; literal plus signs remain part of the filename.
EPUB chapters honor byte-order marks and XML/HTML encoding declarations, including legacy Latin and CJK encodings. Unsupported or invalid declarations use the shared text-import fallback so one bad declaration does not abort the book.
EPUB decompression limits include required metadata as well as navigation and chapter content. A navigation document without a navigation element falls back to chapter headings.
Long-script layout¶
A long script grows the editor inside the page's own scroll container, so it never draws over what sits below it. Generate or Stop, the chapter tracker and the render status share one footer pinned to the setup pane. With the pane collapsed, the same panel sticks to the bottom of the editor instead. When Generate is unavailable, the panel gives the single reason: an import is running, the engine is not ready, there are no spoken lines or no script, a line has no voice and no default voice is set, or a pronunciation word is listed twice.
Clear a script¶
Stories and Audiobook offer Clear script with confirmation. Stories removes all lines, chapter markers and pending import text while retaining the cast; Audiobook clears its manuscript. The web Stories editor clears pending pasted text too, stops playback, ignores late preview results and releases preview audio when clearing, removing or replacing lines. Confirmation also names pending imported text. Clearing an imported script does not recreate the demo story.
The pinned tracker scrolls within the height the setup pane has left, so Stop stays reachable in a compact window. Collapsing setup moves these controls into the editor, where they stay visible while you scroll.
SRT and WebVTT manuscript imports preserve spoken numbers, including countdowns and numeric-only cues; cue indices, timestamps, the WEBVTT header, NOTE/STYLE/REGION blocks and cue identifiers are removed.
Finished renders appear in Projects under their title (the book title, else the first chapter) with a one-line recipe of voice · speed · engine · length. An expandable How it was made panel lists voice, speed, engine, language, format, size and any non-default settings; it holds counts and settings only, never script text. Renders made before details were recorded say so.
Render history includes effective sampling settings (including performance-tier defaults). Non-finite request values are rejected; older malformed numeric details are sanitized so Projects and completion events remain readable.
The output language picker in Clone, Stories and Audiobook disables languages outside the selected engine’s declared finite set. Auto remains available; unknown or model-specific language sets remain selectable and are checked by the backend. Reference recording languages and dubbing translation targets are independent of this output-language control. Switching engines preserves the selected language rather than rewriting saved projects.
The finished-render library filters for Stories and Audiobooks before applying its row limit, so newer dubbing jobs cannot hide an older finished book.
Resuming starts a fresh job while preserving the original checkpoint until all chapters render successfully. Checkpoint writes and syncs are best effort, so an interrupted resumed job can leave both the original and new checkpoints available; either can reuse the shared chapter cache. Closing an unstarted response or interrupting the render leaves the original plan available, including when a replacement checkpoint could not be saved. A render with no failed chapters retires the original even if the replacement checkpoint could not be saved. A partial output keeps the original plan available to retry its failed chapters.
Cache pruning runs when a render exits, including after Stop, and evicts unused chapter and segment audio oldest first. Each render reserves existing inputs before reporting progress or loading its engine, then keeps the whole plan's chapter and segment inputs protected until it exits. This includes later chapters and reusable segments that a resumed book has not reached yet, plus temporary WAVs being published. Unrelated audio becomes evictable once the plan's inputs are identified. Protected files and JSON bookkeeping needed to locate older entries after moving the data directory count toward the cache size, so the budget may be exceeded until a later render can evict them. An unsuccessful or cancelled FFmpeg assembly removes its incomplete output and retains the recovery checkpoint.
Markdown source: View on AtomGit·Content from the open-source project om/VoiceStudio