For the complete documentation index, see llms.txt. This page is also available as Markdown.

实时口型同步

在原生 JavaScript/TypeScript 应用中集成实时面部动画。

启用唇形同步

创建一个带有唇形同步配置的客户端:

import { ConvaiClient } from '@convai/web-sdk/vanilla';

const client = new ConvaiClient({
  apiKey: 'your-api-key',
  characterId: 'your-character-id',
  enableLipsync: true,          // 启用 blendshape 流式传输
  blendshapeFormat: 'mha',      // 'arkit' 或 'mha'(默认:'mha')
});

// 连接后开始接收 blendshape
await client.connect();

配置选项

ConvaiConfig

interface ConvaiConfig {
  // ... 其他选项
  
  /**
   * 启用唇形同步/面部动画 blendshape(默认:false)。
   * 启用后,会以 60fps 流式传输实时 blendshape 数据。
   */
  enableLipsync?: boolean;
  
  /**
   * 要从服务器接收的 blendshape 格式(默认:'mha')。
   * 'arkit' - 61 个元素(52 个 blendshape + 9 个旋转值)
   * 'mha' - 251 个元素(MetaHuman 格式)
   */
  blendshapeFormat?: 'arkit' | 'mha';
}

所有选项示例

创建唇形同步播放器

实现一个播放器类来处理动画循环:

BlendQueue 函数:

最后更新于

这有帮助吗?