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.
Name | Type | Required | Description |
---|---|---|---|
containerLable | string | Yes | Container selector. The digital human will be rendered in this DOM. |
sign | string | Yes | Authentication signature. How to get sign? |
conversationId | string | Yes | Platform conversation ID |
platform | string | Yes | Platform domain, use duix.com |
start(options: object): Promise
Begins rendering the digital human and starts the real-time interaction.Note: Always callParametersstart()
after theinitialSuccess
event to ensure all resources are ready:
key | Type | Required | Default | Description |
---|---|---|---|---|
muted | boolean | No | false | Start video muted. Due to autoplay policy restrictions, if the user hasn’t clicked anywhere yet, set this to true or playback may fail. You can unmute later via duix.setVideoMuted(false) |
openAsr | boolean | No | false | Enable real-time recognition immediately (equivalent to calling openAsr after start ) |
wipeGreen | boolean | No | false | Enable green screen removal. Requires a pure green background when creating the session |
userId | number | No | Unique user identifier | |
vadSilenceTime | number | No | 800 | ASR silence timeout (ms) |
enableLLM | number | No | 1 | Enable LLM auto-replies (0 = off, 1 = on) |
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.Name | Type | Required | Description |
---|---|---|---|
content | string | Yes | Text to speak |
audio | string | No | Audio URL to play. Can also use getAnswer() to obtain platform-configured responses. |
interrupt | boolean | No | If true, interrupts any ongoing speech before playback. |
answer(options: object): Promise
Asks a question and drives the digital human to respond with speech.Name | Type | Required | Description |
---|---|---|---|
question | string | Yes | Question text |
interrupt | boolean | No | If true, interrupts previous speech before answering. |
getAnswer(options: object): Promise
Fetches a platform-generated response to a question without directly playing it.Name | Type | Required | Description |
---|---|---|---|
question | string | Yes | Question text |
userId | number | No | Unique business user ID. If provided, the answer will enable memory |
Name | Type | Description |
---|---|---|
answer | string | Answer text |
audio | string | Answer audio URL |
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.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
Name | Type | Description |
---|---|---|
eventName | string | Name of the event to listen for. See the table below. |
callback | function | Callback function invoked with event data. |