Skip to content

@aosengine/voice ​

Interfaces ​

CaptureEvents ​

The Voxy events consumed by this module.

Properties ​

barge-in ​
ts
barge-in: object;
sequenceId ​
ts
sequenceId: number;
error ​
ts
error: object;
code ​
ts
code: string;
message ​
ts
message: string;
speech-start ​
ts
speech-start: object;
sequenceId ​
ts
sequenceId: number;
state-change ​
ts
state-change: object;
from ​
ts
from: string | null;
to ​
ts
to: string;
utterance-audio ​
ts
utterance-audio: object;
audio ​
ts
audio: Blob;
durationMs ​
ts
durationMs: number;
sequenceId ​
ts
sequenceId: number;

VoiceCapture ​

Structural port implemented by VoxyCore; permits injected capture in tests.

Methods ​

avatarIdle() ​
ts
avatarIdle(): void;
Returns ​

void

avatarSpeaking() ​
ts
avatarSpeaking(): void;
Returns ​

void

isStarted() ​
ts
isStarted(): boolean;
Returns ​

boolean

off() ​
ts
off<K>(event, handler): void;
Type Parameters ​
Type Parameter
K extends keyof CaptureEvents
Parameters ​
ParameterType
eventK
handler(value) => void
Returns ​

void

on() ​
ts
on<K>(event, handler): void;
Type Parameters ​
Type Parameter
K extends keyof CaptureEvents
Parameters ​
ParameterType
eventK
handler(value) => void
Returns ​

void

start() ​
ts
start(): Promise<void>;
Returns ​

Promise<void>

stop() ​
ts
stop(): void;
Returns ​

void


VoiceModule ​

Optional module with no capture, network or audio access until start.

Extends ​

Properties ​

id ​
ts
readonly id: string;

Unique id. Also the service id when init returns a service.

Inherited from ​

EngineModule.id

order? ​
ts
readonly optional order?: number;

Sort key. Lower runs first; equal keys keep registration order.

Rough convention: input -100, gameplay -50, physics 0, rendering helpers 200. Gameplay runs before physics so that the commands a guest tick emits are simulated by the step that follows rather than the next one.

Inherited from ​

EngineModule.order

Methods ​

beginFrame()? ​
ts
optional beginFrame(): void;

Run before the frame's fixed steps. Input capture lives here.

Returns ​

void

Inherited from ​

EngineModule.beginFrame

dispose() ​
ts
dispose(): void;

Release everything this module took.

Returns ​

void

Inherited from ​

EngineModule.dispose

endFrame()? ​
ts
optional endFrame(): void;

Run after rendering. Input's end-of-frame bookkeeping lives here.

Returns ​

void

Inherited from ​

EngineModule.endFrame

fixedUpdate()? ​
ts
optional fixedUpdate(dt): void;

Run once per fixed step.

Parameters ​
ParameterTypeDescription
dtnumberAlways ctx.config.fixedDt, whatever time.timeScale is; time scale changes how many steps a frame runs, not their length.
Returns ​

void

Inherited from ​

EngineModule.fixedUpdate

init() ​
ts
init(ctx): void | object | Promise<void | object>;

Acquire resources.

Parameters ​
ParameterTypeDescription
ctxEngineContextThe host surface.
Returns ​

void | object | Promise<void | object>

Nothing, or the service to publish under id.

Inherited from ​

EngineModule.init

setTranscribing() ​
ts
setTranscribing(enabled): void;

Keep VAD running, but cancel pending work and require a new utterance before routing audio.

Parameters ​
ParameterType
enabledboolean
Returns ​

void

Inherited from ​

VoiceService.setTranscribing

speaking() ​
ts
speaking(active): void;
Parameters ​
ParameterType
activeboolean
Returns ​

void

Inherited from ​

VoiceService.speaking

start() ​
ts
start(): Promise<void>;
Returns ​

Promise<void>

Inherited from ​

VoiceService.start

stop() ​
ts
stop(): void;
Returns ​

void

Inherited from ​

VoiceService.stop

update()? ​
ts
optional update(dt, alpha): void;

Run once per frame, after the fixed steps and before rendering.

Parameters ​
ParameterTypeDescription
dtnumberClamped wall-clock seconds since the previous frame, scaled by time.timeScale.
alphanumberInterpolation factor in [0, 1) for smoothing transforms.
Returns ​

void

Inherited from ​

EngineModule.update


VoiceOptions ​

Host callbacks, never called across the guest boundary.

Properties ​

playbackEchoGuardMs? ​
ts
optional playbackEchoGuardMs?: number;

Speaker-safe mode: suppress captured speech during playback and for this many milliseconds afterward. Omit for hands-free barge-in with headphones.

Methods ​

createCapture() ​
ts
createCapture(): 
  | VoiceCapture
| Promise<VoiceCapture>;

Create a fresh VoxyCore configured with sampleRate: 16000. Called only by start.

Returns ​

| VoiceCapture | Promise<VoiceCapture>

onError() ​
ts
onError(message): void;
Parameters ​
ParameterType
messagestring
Returns ​

void

onInterrupt() ​
ts
onInterrupt(): void;
Returns ​

void

onStatus() ​
ts
onStatus(status): void;
Parameters ​
ParameterType
statusstring
Returns ​

void

onText() ​
ts
onText(text): void;
Parameters ​
ParameterType
textstring
Returns ​

void

transcribe() ​
ts
transcribe(pcm, signal): Promise<string>;

Send complete raw PCM to a credential-holding relay.

Parameters ​
ParameterType
pcmUint8Array<ArrayBuffer>
signalAbortSignal
Returns ​

Promise<string>


VoiceService ​

Microphone lifecycle with independent transcription routing.

Extended by ​

Methods ​

setTranscribing() ​
ts
setTranscribing(enabled): void;

Keep VAD running, but cancel pending work and require a new utterance before routing audio.

Parameters ​
ParameterType
enabledboolean
Returns ​

void

speaking() ​
ts
speaking(active): void;
Parameters ​
ParameterType
activeboolean
Returns ​

void

start() ​
ts
start(): Promise<void>;
Returns ​

Promise<void>

stop() ​
ts
stop(): void;
Returns ​

void

Functions ​

voice() ​

ts
function voice(options): VoiceModule;

Build a Voxy lifecycle adapter. Each start after stop receives a new capture instance.

Parameters ​

ParameterTypeDescription
optionsVoiceOptionsCapture factory, relay and presentation callbacks.

Returns ​

VoiceModule

A host module with explicit start/stop controls.


wavToPcm16() ​

ts
function wavToPcm16(wav): Uint8Array<ArrayBuffer>;

Read a complete mono PCM16/16 kHz WAV utterance, rejecting other formats.

Parameters ​

ParameterTypeDescription
wavArrayBufferVoxy's utterance WAV bytes.

Returns ​

Uint8Array<ArrayBuffer>

Owned little-endian PCM bytes suitable for Parlay.