@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
| Parameter | Type |
|---|---|
event | K |
handler | (value) => void |
Returns
void
on()
ts
on<K>(event, handler): void;Type Parameters
| Type Parameter |
|---|
K extends keyof CaptureEvents |
Parameters
| Parameter | Type |
|---|---|
event | K |
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
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
Methods
beginFrame()?
ts
optional beginFrame(): void;Run before the frame's fixed steps. Input capture lives here.
Returns
void
Inherited from
dispose()
ts
dispose(): void;Release everything this module took.
Returns
void
Inherited from
endFrame()?
ts
optional endFrame(): void;Run after rendering. Input's end-of-frame bookkeeping lives here.
Returns
void
Inherited from
fixedUpdate()?
ts
optional fixedUpdate(dt): void;Run once per fixed step.
Parameters
| Parameter | Type | Description |
|---|---|---|
dt | number | Always ctx.config.fixedDt, whatever time.timeScale is; time scale changes how many steps a frame runs, not their length. |
Returns
void
Inherited from
init()
ts
init(ctx): void | object | Promise<void | object>;Acquire resources.
Parameters
| Parameter | Type | Description |
|---|---|---|
ctx | EngineContext | The host surface. |
Returns
void | object | Promise<void | object>
Nothing, or the service to publish under id.
Inherited from
setTranscribing()
ts
setTranscribing(enabled): void;Keep VAD running, but cancel pending work and require a new utterance before routing audio.
Parameters
| Parameter | Type |
|---|---|
enabled | boolean |
Returns
void
Inherited from
speaking()
ts
speaking(active): void;Parameters
| Parameter | Type |
|---|---|
active | boolean |
Returns
void
Inherited from
start()
ts
start(): Promise<void>;Returns
Promise<void>
Inherited from
stop()
ts
stop(): void;Returns
void
Inherited from
update()?
ts
optional update(dt, alpha): void;Run once per frame, after the fixed steps and before rendering.
Parameters
| Parameter | Type | Description |
|---|---|---|
dt | number | Clamped wall-clock seconds since the previous frame, scaled by time.timeScale. |
alpha | number | Interpolation factor in [0, 1) for smoothing transforms. |
Returns
void
Inherited from
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
| Parameter | Type |
|---|---|
message | string |
Returns
void
onInterrupt()
ts
onInterrupt(): void;Returns
void
onStatus()
ts
onStatus(status): void;Parameters
| Parameter | Type |
|---|---|
status | string |
Returns
void
onText()
ts
onText(text): void;Parameters
| Parameter | Type |
|---|---|
text | string |
Returns
void
transcribe()
ts
transcribe(pcm, signal): Promise<string>;Send complete raw PCM to a credential-holding relay.
Parameters
| Parameter | Type |
|---|---|
pcm | Uint8Array<ArrayBuffer> |
signal | AbortSignal |
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
| Parameter | Type |
|---|---|
enabled | boolean |
Returns
void
speaking()
ts
speaking(active): void;Parameters
| Parameter | Type |
|---|---|
active | boolean |
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
| Parameter | Type | Description |
|---|---|---|
options | VoiceOptions | Capture factory, relay and presentation callbacks. |
Returns
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
| Parameter | Type | Description |
|---|---|---|
wav | ArrayBuffer | Voxy's utterance WAV bytes. |
Returns
Uint8Array<ArrayBuffer>
Owned little-endian PCM bytes suitable for Parlay.