Capability first · transport second

PreparedSpeech.js

Owns detached ordered speech preparation, complete semantic audio reuse, and per-caller cancellation behind AI.prepareTTS.

SDK 0.5.18Runtime 0.8.12Protocol arcane/1
On this page

Overview

Owns detached ordered speech preparation, complete semantic audio reuse, and per-caller cancellation behind AI.prepareTTS.

  • Artifact
    PreparedSpeech.js · esm
  • Classification
    public first party
  • Availability
    Browser or native WebView with Blob, AbortController, an injected synthesis callback, and optional ready DBOPFS
  • 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.

Import and lifecycle

JavaScript
import * as module from '/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. Optional DBOPFS writes 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()}; applications use AI.prepareTTS 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

BindingFormDeclaration or signatureParameter syntax
prepareSpeechfunctionfunction 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 }={}

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. Applications use AI.prepareTTS 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. 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.
  • Complete synthesis/storage errors propagate through ready/getAudio; successful segments are retained.

Availability and capabilities

Browser or native WebView with Blob, AbortController, an injected synthesis callback, and optional ready DBOPFS. 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.

No Core capability. Blob, AbortController, an injected synthesis callback, and optional ready DBOPFS supply the functional boundaries; application identity, priority, and retention policy remain with the caller.

Contract example

JavaScript
import {prepareSpeech} from '/arcane/modules/PreparedSpeech.js';

// Applications use AI.prepareTTS; importing this mechanism starts no work.
console.log(typeof prepareSpeech);

No direct Core call is claimed for this artifact. Any injected provider or consuming module retains its own documented authority.