On this page
Overview
Owns detached ordered speech preparation, complete semantic audio reuse, cache-only lookup, and per-caller cancellation behind AI.prepareTTS and AI.readPreparedTTS.
- Artifact
PreparedSpeech.js· esm - Classification
public first party - Availability
Browser or native WebView with Blob, AbortController, optional ready DBOPFS, and an injected synthesis callback for generation - Normalization
Preserves complete original parts and JSON-compatible semantic context, shares pending matching work on the same owner/storage group, admits segments in order, stores complete Blobs and MIME metadata, retains successful audio after failure or cancellation, and separates generation readiness from playback. Cache-only lookup uses the same semantic matcher, reads every stored audio reference without writes or repair, and returns null for missing matches/audio while preserving genuine read failures.
Import and lifecycle
import * as module from '/node_modules/arcane-os/runtime/arcane/modules/PreparedSpeech.js';
Import creates no provider, model, storage operation, audio context, or playback. prepareSpeech starts owned asynchronous generation/reuse; the injected AI callback owns synthesis. readPreparedSpeech reads existing complete audio without synthesis, activation, unmute, playback, storage writes, or repair. Optional DBOPFS operations serialize by database, table, and key within the realm; successful stored audio survives cancellation or failure.
Application-facing behavior: Named prepareSpeech({owner,parts,originalParts,selection,segmentation,storage,identity,signal,onState,synthesize}) returns {segments,state,ready,getAudio(index),cancel()}. Named async readPreparedSpeech({owner,parts,originalParts=parts,selection=null,segmentation=null,storage=null,identity=null,signal=null,onState=null}) returns a complete ready handle or null without synthesis, activation, unmute, playback, or storage writes. Manifest, audio availability, and returned-handle reads pass DBOPFS createTable:false, leaving absent tables absent; supplied adapters own the same read-existing contract. Omitted storage reads only completed matching same-owner in-memory preparations; pending or failed work returns null. A hit replays ready state and a miss emits nothing. The lookup signal detaches on settlement; the returned handle keeps independent explicit cancellation and MIME-preserving getAudio, including later storage errors. Applications use AI.prepareTTS, AI.readPreparedTTS, and AI.playPreparedTTS so the shared AI owner retains segmentation, provider readiness, capacity, and playback.
Protocol and host implementation
In-process preparation handle plus caller-owned DBOPFS raw audio and version-1 semantic manifest This detail does not widen the application-facing API or grant authority.
Exports, signatures, parameters, and results
| Binding | Form | Declaration or signature | Parameter syntax |
|---|---|---|---|
prepareSpeech | function | function prepareSpeech({
owner,
parts,
originalParts=parts,
selection=null,
segmentation=null,
storage=null,
identity=null,
signal=null,
onState=null,
synthesize
}={}) | {
owner,
parts,
originalParts=parts,
selection=null,
segmentation=null,
storage=null,
identity=null,
signal=null,
onState=null,
synthesize
}={} |
readPreparedSpeech | function | async function readPreparedSpeech({
owner,
parts,
originalParts=parts,
selection=null,
segmentation=null,
storage=null,
identity=null,
signal=null,
onState=null
}={}) | {
owner,
parts,
originalParts=parts,
selection=null,
segmentation=null,
storage=null,
identity=null,
signal=null,
onState=null
}={} |
Parameter meanings and results
prepareSpeech({owner,parts,originalParts=parts,selection=null,segmentation=null,storage=null,identity=null,signal=null,onState,synthesize}) returns {segments,state,ready,getAudio(index),cancel()}. The owning AI supplies segmented speech plus complete original parts and semantic context. Matching pending requests share synthesis on the same owner and storage group, while each handle can cancel independently. ready resolves the complete ordered record after generation/reuse and optional durable saving; getAudio(index) returns a complete Blob with preserved MIME metadata. Async readPreparedSpeech({owner,parts,originalParts=parts,selection=null,segmentation=null,storage=null,identity=null,signal=null,onState=null}) uses the same complete semantic matcher and resolves a ready handle or null. Durable lookup reads the existing manifest and every ordered audio file with DBOPFS createTable:false, including later handle.getAudio reads, so absent tables remain absent; supplied adapters own the same read-existing behavior. Already-started non-abortable reads may settle after cancellation, while observed cancellation prevents further reads or returning a handle; a missing match or audio returns null. Without storage, only completed matching same-owner retained in-memory work is eligible; pending or failed work returns null. The lookup signal detaches on settlement, so later abort does not cancel a returned handle; explicit handle cancel remains independent. Durable getAudio rereads stored files, preserving later read failures. Applications use AI.prepareTTS, AI.readPreparedTTS, and AI.playPreparedTTS to retain the shared segmentation, provider readiness, capacity, and playback owners.
Events, side effects, and errors
Source-literal CustomEvent dispatches
No source-literal CustomEvent dispatch is part of this artifact.
Lifecycle and event flow
- Optional synchronous onState({state,completed,total,segments,error}) observes preparation; observer failures reach shared diagnostics. Cache-only hits replay ready state and misses emit nothing. No playback event is emitted here.
Direct coded failures
ARCANE_AI_REQUEST_ABORTED
Exported Error subclasses
This artifact exports no Error subclass.
Documented failure behavior
- TypeError for malformed storage, part, callback, or JSON-compatible semantic metadata inputs.
- RangeError for an invalid segment index.
- AbortError with ARCANE_AI_REQUEST_ABORTED for cancelled handles or lookups.
- Complete synthesis/storage errors propagate through ready/getAudio; successful segments are retained. Cache-only lookup rejects malformed stored metadata and genuine storage errors rather than converting them to misses.
Availability and capabilities
Browser or native WebView with Blob, AbortController, optional ready DBOPFS, and an injected synthesis callback for generation. Preserves complete original parts and JSON-compatible semantic context, shares pending matching work on the same owner/storage group, admits segments in order, stores complete Blobs and MIME metadata, retains successful audio after failure or cancellation, and separates generation readiness from playback. Cache-only lookup uses the same semantic matcher, reads every stored audio reference without writes or repair, and returns null for missing matches/audio while preserving genuine read failures.
No Core capability. Blob, AbortController, optional ready DBOPFS, and an injected synthesis callback for generation supply the functional boundaries; application identity, priority, and retention policy remain with the caller.
Contract example
import {prepareSpeech} from '/node_modules/arcane-os/runtime/arcane/modules/PreparedSpeech.js';
// Applications use AI.prepareTTS; importing this mechanism starts no work.
console.log(typeof prepareSpeech);
Related reference
No direct Core call is claimed for this artifact. Any injected provider or consuming module retains its own documented authority.