Capability first · transport second

NativeSpeechPlayback.js

Prepares an inert native speech descriptor and plays ordered PCM through the existing shared Web Audio owner.

SDK 0.97.1Runtime 0.8.12Protocol arcane/1
On this page

Overview

Prepares an inert native speech descriptor and plays ordered PCM through the existing shared Web Audio owner.

  • Artifact
    NativeSpeechPlayback.js · esm
  • Classification
    public first party
  • Availability
    Browser / native WebView with Web Audio and selected streaming speech
  • Normalization
    Preparation starts no synthesis or playback. play schedules every supplied s16le sample in original order with audio-clock backpressure. Pause retains playback position; stop cancels only that utterance. finished and released distinguish playback termination from joined native cleanup; errors remain observable.

Import and lifecycle

JavaScript
import nativeSpeechPlayback from '/node_modules/arcane-os/runtime/arcane/modules/NativeSpeechPlayback.js';

Preparation is inert. Explicit play calls the supplied streaming speech API, schedules PCM on the caller-owned AudioContext and owns only this utterance and its nodes. It never closes the shared output context.

Application-facing behavior: default prepareNativeSpeechPlayback({speech,request,getAudioContext,signal=null}); returns {kind:native-speech,input,voice,language,speed,play}. play({signal,onState}) returns finished/released/state/error/pause/resume/stop. The caller owns its AudioContext; this module never closes unrelated output.

Protocol and host implementation

speech.synthesizeStream with awaited PCM consumption This detail does not widen the application-facing API or grant authority.

Exports, signatures, parameters, and results

BindingFormDeclaration or signatureParameter syntax
defaultdefault · functionfunction prepareNativeSpeechPlayback({speech, request, getAudioContext, signal = null}){speech, request, getAudioContext, signal = null}
CallableKindExact public signatureParameter syntax
defaultexported-functionfunction prepareNativeSpeechPlayback({speech, request, getAudioContext, signal = null}){speech, request, getAudioContext, signal = null}

Parameter meanings and results

prepareNativeSpeechPlayback({speech,request,getAudioContext,signal=null}) returns {kind:native-speech,input,voice,language,speed,play}. play({signal,onState}) returns finished, released, state/error getters and pause/resume/stop boolean controls. Ordered s16le PCM is converted to Web Audio samples at the supplied rate and channel count; awaited consumption provides audio-clock backpressure. finished resolves true after natural playback or false after stop, and rejects actual failures; released additionally joins native synthesis and cleanup. Pause retains the unplayed position. Cancellation targets only this utterance, independently of microphone capture.

Events, side effects, and errors

Source-literal CustomEvent dispatches

No source-literal CustomEvent dispatch is part of this artifact.

Lifecycle and event flow

  • Optional onState({state,error}) observes queued, waiting-for-audio, playing, paused, complete, stopped or error.

Direct coded failures

  • ARCANE_AI_REQUEST_ABORTED
  • ARCANE_AI_SPEECH_PLAYBACK_FAILED

Exported Error subclasses

This artifact exports no Error subclass.

Documented failure behavior

  • TypeError for missing streaming speech or AudioContext owner.
  • ARCANE_AI_SPEECH_PLAYBACK_FAILED for unusable PCM or closed audio output.
  • Native synthesis, playback and cleanup failures remain observable; combined failures retain their causes.

Availability and capabilities

Browser / native WebView with Web Audio and selected streaming speech. Preparation starts no synthesis or playback. play schedules every supplied s16le sample in original order with audio-clock backpressure. Pause retains playback position; stop cancels only that utterance. finished and released distinguish playback termination from joined native cleanup; errors remain observable.

Browser Web Audio and a supplied streaming speech API; application selection, native engine availability and output-context lifetime remain with their owners.

Contract example

JavaScript
import prepareNativeSpeechPlayback from 'arcane-os/modules/NativeSpeechPlayback.js';

function prepareDragonAnnouncement(speech, getAudioContext, signal) {
    return prepareNativeSpeechPlayback({
        speech, getAudioContext, signal,
        request: {input: 'The dragon has landed.', languageCode: 'en-US'}
    });
}
// Call descriptor.play() from the owning playback action, then join released.

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