3.7 KiB
Deferred audiobook-production architecture
Architecture only. No audiobook schema, API call, credential storage or background worker is introduced here. Audio Review is a separate listening/review feature and does not generate or approve audiobook audio.
Future author workflow
Chapters may be explicitly marked Ready for Audio. Audio Generated and Audio Approved remain separate states. A changed manuscript invalidates affected generated audio and requires review; readiness is not proof of publication suitability. Final assembly, pronunciation/voice continuity, mastering and publication checks are distinct stages.
Use the author's existing ElevenLabs subscription credits after explicit account connection in a future authorised implementation. Background generation is permitted only from available credits above a configurable reserve; the requested default reserve is 100,000 credits. For example, a 120,000 balance permits at most 20,000 credits of authorised background work, subject to a fresh verified balance and the provider's actual charging rules. A balance at/below the reserve schedules no automatic generation. Do not promise prices, API limits or credit calculations until official provider contracts are verified during that implementation.
A future Finish Audiobook command may use remaining subscription credits. Paid overage is a separate action requiring explicit user approval, a visible estimate and a hard spending cap. Failed/retried requests must never become implicit approval to exceed the cap.
Stable cache and invalidation
Use the existing canonical manuscript identity and stable paragraph occurrence GUIDs. A generation key includes manuscript identity, paragraph GUID, normalized text hash, voice identity/version and complete generation settings/model version. Text changes invalidate that paragraph's cached audio; ordering changes can reuse unchanged eligible chunks. Hash equality alone must not merge separate author/book contexts or expose another author's audio. Voice/settings changes invalidate the relevant key. Maintain source revision/provenance so approval is tied to exact audio and text.
Generation is a resumable state machine with a durable intent/job ID, provider idempotency where available, charge reservation, submission receipt, reconciliation and completed artifact. Persist the provider request/charge identity before retry decisions. After timeout, reconcile the provider outcome before issuing a potentially billable duplicate. A per-user/account budget lock and reservation ledger prevent concurrent workers consuming the same above-reserve credits. Unknown balances/costs fail closed for background billing. An explicit spending cap is enforced across retries and concurrent work, not merely checked once in the UI.
Audio artifacts are private, content-addressed within authorised scope, and stored separately from canonical prose. Restore/export, retention, deletion, provider copies, consent, license rights and generated-voice privacy require explicit future policy. The Writer working objective, accepted activity history and paragraph identities remain the shared foundation; the new review-session table is not a billing ledger or generation queue.
Integration boundaries
Future author-approved readiness/approval commands belong alongside chapter workflows and Writer. A future audio-generation service consumes accepted checkpoints asynchronously; it never rewrites canonical manuscript synchronisation or infers author approval from playback. Review sessions may later reference an approved generated artifact, but external media review continues to work independently. Do not couple the current media-control contract to any provider URL, credentials or paid API.