Skip to main content

Code Examples

Description

This example demonstrates how to initialize, authenticate, and start a Duix real-time avatar session using the Web SDK.
It includes event listeners for ASR (speech recognition), subtitles, and conversation lifecycle events.
Note: The CDN demo version may not be the latest. For production use, install the SDK via npm to ensure compatibility and security.

Example: Basic HTML Integration

Usage Notes

Tip:
Always generate the sign securely on your backend. Never expose API credentials or tokens in client-side code.
Note:
Some mobile browsers block autoplay of audio or video without user interaction.
If the avatar does not render immediately, trigger duix.start() within a user gesture event such as onclick or onTap.
Warning:
This demo omits advanced error handling, concurrency control, and resource cleanup.
For production use, wrap SDK calls in try/catch blocks, manage sessions through your backend, and call duix.stop() when the conversation ends to release resources properly.