start(): Promise<void> | Connects and resolves when the first video frame is on screen. Retries only network failures, with exponential backoff, and rejects at once on anything else. See Errors and retries. Throws if the client was already stopped. |
stop(): Promise<void> | Ends the session and closes the connection. The client can’t be started again. |
sendAudioData(audioData: Uint8Array) | Sends PCM16, 16 kHz, mono audio. It plays after any audio already queued. Throws if the connection isn’t open. |
sendAudioDataImmediate(audioData: Uint8Array) | Drops any queued audio and plays this chunk right away. |
ClearBuffer() | Drops any queued audio, so the avatar stops talking. Use it when the user interrupts. |
listenToMediastreamTrack(track: MediaStreamTrack) | Streams an audio track, such as a microphone or a TTS WebRTC track, to Simli. |
listenToAudioElement(audioEl: HTMLAudioElement) | Streams what an <audio> element plays to Simli, and mutes that element locally: you hear the avatar through audioElement instead. An element can only be captured once. |
setCamera(camera: CameraSetting | null, options?: { lerpSeconds?: number }) | Trinity-2 only. Replaces the camera, or goes back to the avatar’s own framing with null. Glides over lerpSeconds seconds if it’s above 0, otherwise cuts. Throws on a value that isn’t a finite number, and if the connection isn’t open. See Trinity-2. |
setBackground(backgroundId: string | null) | Trinity-2 only. Shows one of your uploaded backgrounds behind the avatar, or the avatar’s own with null. It applies a moment later, once loaded, and the last call wins. Throws if the id isn’t a 36-character UUID. |
setForeground(foregroundId: string | null) | Trinity-2 only. Lays one of your uploaded foregrounds over the avatar, or removes it with null. Otherwise it works like setBackground. |
on(event, callback) | Registers an event handler. Register handlers before start(). They stay registered across retries. |
off(event, callback) | Removes an event handler. Throws if that event never had a handler. |