Skip to main content

Overview

The Duix SDK exposes a set of core methods for initializing, controlling, and interacting with the real-time digital human. All asynchronous methods return a Promise resolving to { err, data }.

init(options: object): Promise

Initializes the SDK with configuration parameters and prepares the rendering environment.
Parameters

start(options: object): Promise

Begins rendering the digital human and starts the real-time interaction.
Note: Always call start() after the initialSuccess event to ensure all resources are ready:
Parameters

setVideoMuted(flag: boolean)

Toggles video playback mute state. true = muted, false = unmuted.

break()

Immediately interrupts the current speech or response playback.

speak(options: object): Promise

Drives the digital human to speak using text or an audio URL.
Parameters

answer(options: object): Promise

Asks a question and drives the digital human to respond with speech.
Parameters

getAnswer(options: object): Promise

Fetches a platform-generated response to a question without directly playing it.
Parameters Return data

startRecord(): Promise

Start recording.

stopRecord(): Promise

Stops recording and returns a Promise resolving with the speech recognition result.

openAsr(): Promise

Enables real-time automatic speech recognition (ASR). Should be called after the show event.

closeAsr(): Promise

Disables real-time speech recognition.

createCamera():Promise

Turn on the camera.

destroyCamera():Promise

Turn off the camera and release occupied resources.

stop()

Terminates the current session and releases all resources. Call this during page unload or refresh to avoid lingering RTC connections.

getLocalStream()

Returns the local audio stream (useful for visualizations or waveform analysis).

getRemoteStream()

Returns the remote audio and video stream (for custom rendering or media processing).

resume()

Resumes playback. Useful for mobile browsers that may block autoplay even after user interaction. Call this in response to error code 4009.

on(eventName, callback)

Registers an event listener for SDK events.
Parameters

Return format

All Promise-based methods resolve to a unified object format:
If err is non-null, the call failed. Use console.error(err) for diagnostic details.