Skip to content

@aosengine/conversation ​

Interfaces ​

ConversationCharacter ​

Story configuration is host-owned; game code names only a character id.

Properties ​

prefabs? ​
ts
optional prefabs?: Readonly<Record<string, readonly SpeechChunk[] | undefined>>;

This character's prepared performances, selected by the service.

storyId ​
ts
storyId: string;
url ​
ts
url: string;

ConversationModule ​

Session control. Ending an interview retains its session and story revision.

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 ​

ask() ​
ts
ask(text): boolean;
Parameters ​
ParameterType
textstring
Returns ​

boolean

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

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

void

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

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

void

start() ​
ts
start(character): void;
Parameters ​
ParameterType
characterstring
Returns ​

void

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


ConversationOptions ​

Optional conversation dependencies and callbacks.

Properties ​

characters ​
ts
characters: Readonly<Record<string, ConversationCharacter | undefined>>;
player ​
ts
player: SpeechPlayer;
prefabs? ​
ts
optional prefabs?: Readonly<Record<string, readonly SpeechChunk[] | undefined>>;

Prepared performances keyed by Convorcher prefab id; no story mutations.

Methods ​

connect()? ​
ts
optional connect(url): ConversationSocket;
Parameters ​
ParameterType
urlstring
Returns ​

ConversationSocket

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

void

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

void

onStory() ​
ts
onStory(character, snapshot): void;
Parameters ​
ParameterType
characterstring
snapshotStorySnapshot
Returns ​

void


ConversationSocket ​

Browser connection surface; injectable for service replay tests.

Properties ​

onclose ​
ts
onclose: ((event) => void) | null;
onerror ​
ts
onerror: ((event) => void) | null;
onmessage ​
ts
onmessage: ((event) => void) | null;
onopen ​
ts
onopen: ((event) => void) | null;
readyState ​
ts
readyState: number;

Methods ​

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

void

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

void


FaceFrame ​

Face frames, with seconds relative to their audio chunk: 52 weights in ARKit-52 order, or, when the session asked the conversation service for the head model's own face (a2f=isaac-gnm), its 383 expression codes.

Properties ​

blendshapeWeights ​
ts
blendshapeWeights: readonly number[];
timeCode ​
ts
timeCode: number;

GnmVoice ​

The voice model's published information, which turns a native frame's codes into head coefficients: coefficient = scale x (code - offset), held within limit (see parseGnmVoice).

Properties ​

limit? ​
ts
optional limit?: Float32Array<ArrayBufferLike>;

Per coefficient, GNM_CLAMP_STD x |std x scale| (std: the spread the voice model was trained with). Past it the head model's lips cross and the splats on them tear, so each coefficient is held inside. Absent when the file carries no std.

offset ​
ts
offset: Float32Array;
scale ​
ts
scale: Float32Array;

SpeechChunk ​

One bounded speech performance, already decoded from the service wire format.

Properties ​

frames ​
ts
frames: readonly FaceFrame[];
gesture? ​
ts
optional gesture?: string;
pcm ​
ts
pcm: Uint8Array;
text ​
ts
text: string;

SpeechPlayer ​

Audio-clock speech queue; update reuses a single facial vector.

Methods ​

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

void

enqueue() ​
ts
enqueue(chunk): void;
Parameters ​
ParameterType
chunkSpeechChunk
Returns ​

void

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

void

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

void


SpeechPlayerOptions ​

Options for createSpeechPlayer.

Properties ​

gnmVoice? ​
ts
optional gnmVoice?: GnmVoice | (() => GnmVoice | null);

Take native frames: the parsed voice information (parseGnmVoice), or a getter while it loads (null then: the audio plays and the face rests). Without it a 383-wide chunk is refused, as it always was.


SpeechPresentation ​

Presentation callbacks run on the audio clock.

Methods ​

expression() ​
ts
expression(weights, space): void;

The face now. space says what weights holds: 52 ARKit weights in [0, 1] (arkit52), or, from native frames, the head's 387 gnm coefficients (the character bridge takes both as they are: characters.setExpression(entity, space, weights)). A presentation that only drives ARKit may ignore space: a player made without gnmVoice never sends gnm.

Parameters ​
ParameterType
weightsFloat32Array
spaceSpeechFaceSpace
Returns ​

void

gesture() ​
ts
gesture(id): void;
Parameters ​
ParameterType
idstring
Returns ​

void

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

void

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

void

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

void


StorySnapshot ​

Stable full-state message emitted by Convorcher after analysis and on join.

Properties ​

completedObjectives ​
ts
completedObjectives: string[];
currentPhase ​
ts
currentPhase: string;
playerState ​
ts
playerState: Record<string, string>;
revision ​
ts
revision: number;
schemaVersion ​
ts
schemaVersion: 1;
sessionId ​
ts
sessionId: string;
storyId ​
ts
storyId: string;
transitionCause ​
ts
transitionCause: string;

Type Aliases ​

SpeechFaceSpace ​

ts
type SpeechFaceSpace = "arkit52" | "gnm";

What a face vector holds: ARKit-52 weights, or the head model's native gnm coefficients.

Variables ​

ARKIT_FRAME_WIDTH ​

ts
const ARKIT_FRAME_WIDTH: 52 = 52;

ARKit weights in one frame.


GNM_CLAMP_STD ​

ts
const GNM_CLAMP_STD: 3 = 3;

How many standard deviations of the voice model's training spread a coefficient may reach.


GNM_FRAME_WIDTH ​

ts
const GNM_FRAME_WIDTH: 383 = 383;

The head model's expression codes in one native frame (a2f=isaac-gnm).


GNM_SPACE_DIM ​

ts
const GNM_SPACE_DIM: 387 = 387;

The gnm expression space: the 383 coefficients, then a four-wide gaze tail the player leaves at zero.

Functions ​

acceptStorySnapshot() ​

ts
function acceptStorySnapshot(
   current, 
   next, 
   sessionId, 
   storyId
): StorySnapshot | null;

Idempotent reducer scoped to an expected session and story.

Parameters ​

ParameterTypeDescription
currentStorySnapshot | nullLast accepted snapshot.
nextStorySnapshotCandidate snapshot.
sessionIdstringExpected session.
storyIdstringExpected story.

Returns ​

StorySnapshot | null

The accepted snapshot, or the previous state.


conversation() ​

ts
function conversation(options): ConversationModule;

Build an optional session manager. Construction does not connect to any service.

Parameters ​

ParameterTypeDescription
optionsConversationOptionsExplicit character allow-list, playback and callbacks.

Returns ​

ConversationModule

An engine module. Call start only after an interview is requested.


createSpeechPlayer() ​

ts
function createSpeechPlayer(
   context, 
   presentation, 
   destination?, 
   options?
): SpeechPlayer;

Build a bounded PCM player. The caller creates/resumes the context in a user gesture.

Frames 52 wide play as ARKit-52 weights. Frames 383 wide (the head model's own face, a2f=isaac-gnm) play as the head's gnm coefficients when options.gnmVoice is given: coefficient = scale x (code - offset), held within GNM_CLAMP_STD x |std x scale|, interpolated at the frames' own times and eased in and out at the ends of a run of speech; without it they are refused.

Parameters ​

ParameterTypeDefault valueDescription
contextAudioContextundefinedShared or dedicated audio clock.
presentationSpeechPresentationundefinedSubtitles, gestures and facial rig.
destinationAudioNodecontext.destinationVoice bus; defaults to the context destination.
optionsSpeechPlayerOptions{}Native frames (gnmVoice).

Returns ​

SpeechPlayer

A player which owns only its sources, not the context.


faceSpaceOf() ​

ts
function faceSpaceOf(width, native): SpeechFaceSpace | null;

The space a chunk's frames drive, from their width.

Parameters ​

ParameterTypeDescription
widthnumberNumbers per frame.
nativebooleanWhether the player takes native frames (it was given gnmVoice).

Returns ​

SpeechFaceSpace | null

arkit52 for 52, gnm for 383 when native frames are taken; null for anything else (refused).


gnmCoefficients() ​

ts
function gnmCoefficients(
   codes, 
   voice, 
   out?
): Float32Array;

One native frame's codes as head coefficients, each held within the voice's limit, with a zero gaze tail.

Parameters ​

ParameterTypeDescription
codesArrayLike<number>The frame's 383 codes as the service sends them.
voiceGnmVoiceThe voice information.
outFloat32ArrayOutput of length GNM_SPACE_DIM, reused.

Returns ​

Float32Array

out.


parseGnmVoice() ​

ts
function parseGnmVoice(raw): GnmVoice | null;

Read a voice information file (gnm_voice.json: scale, offset and optionally std, 383 numbers each).

Parameters ​

ParameterTypeDescription
rawunknownThe parsed JSON.

Returns ​

GnmVoice | null

The voice, with limit when the file carries a valid std; null when it cannot be used.


parseStorySnapshot() ​

ts
function parseStorySnapshot(value): StorySnapshot | null;

Validate a bounded, versioned story snapshot.

Parameters ​

ParameterTypeDescription
valueunknownUntrusted message data.

Returns ​

StorySnapshot | null

Owned snapshot, or null for invalid data.