> For the complete documentation index, see [llms.txt](https://docs.convai.com/api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin/adding-lip-sync-to-your-character.md).

# 为角色添加口型同步

## 唇形同步系统

Convai 会根据开发者选择使用的面部模型，从后端发送 Viseme 或 Blend Shape 帧，返回后 Convai SDK 会开箱即用地对其进行提取和解析，并将其提供给 **`Convai LipSync 组件`**，之后该组件依赖于 **`SkinMeshRenderer`**&#x7684; **`Blendshape 效应器`** 和 **`骨骼效应器`** 来为 Convai 驱动的 NPC 提供逼真的唇形同步。

### LipSync 系统的组成部分

#### Viseme 效应器列表

在这里，开发者会告诉 Convai SDK，Blendshape 数组的哪个索引会以多大的比例受哪个值影响。为了更好地解释其工作原理，我们用图示来理解。

<figure><img src="/files/deacd29c3087e334de1633895b6122ccb9cfc063" alt=""><figcaption></figcaption></figure>

这里的意思是，无论从服务器传来什么值，都会以 0.2 的倍率影响第 116 个索引处的 Blendshape，并以 0.5 的倍率影响第 114 个索引处的 Blendshape。引擎中的表现大致如下。

<figure><img src="/files/7744c7825c1ff44727761582a21ea5f1a85f7cfc" alt=""><figcaption></figcaption></figure>

所以，你可以创建自己的效应器列表，或者使用我们在 SDK 中提供的众多列表之一。

**如何创建你自己的 Viseme 效应器列表**

在项目面板内右键，然后前往 **`Create > Convai > Expression > Viseme Skin Effector`** 这将创建一个 **Viseme 效应器列表 Scriptable Object** 现在你就可以定义自己的值了。

<figure><img src="/files/96bbe2bbf4e207afe22fe1443ecfc1fa6470cbbd" alt=""><figcaption></figcaption></figure>

#### Viseme 骨骼效应器列表

在这里，开发者会告诉 Convai SDK，服务器传来的每个值会在多大程度上影响骨骼的旋转。为了更好地解释其工作原理，我们用图示来理解。

<figure><img src="/files/98f7989a4b8c47b79e53d0f88f31c03da78073bd" alt=""><figcaption></figcaption></figure>

这里，骨骼的旋转会受到从服务器传来的值与效应器中值相乘后的影响。例如，对于 TH，该值会以 0.2 的倍率影响骨骼旋转，等等。引擎中的表现大致如下。

<figure><img src="/files/7f9eea77826b6442bd3ee10e7ad22270a879bce9" alt=""><figcaption></figcaption></figure>

所以，你可以创建自己的骨骼效应器列表，或者使用我们在 SDK 中提供的众多列表之一。

我们使用这个公式来计算旋转

```csharp
UpdateJawBoneRotation(
new Vector3(
        0.0f, 
        0.0f, 
        -90.0f - CalculateBoneEffect(FacialExpressionData.JawBoneEffector) * 30f
    )
);
UpdateTongueBoneRotation(
new Vector3(
        0.0f,
        0.0f,
        CalculateBoneEffect(FacialExpressionData.TongueBoneEffector) * 80f - 5f
    )
);
```

**如何创建你自己的 Viseme 骨骼效应器列表**

在项目面板内右键，然后前往 **`Create > Convai > Expression > Viseme Bone Effector`** 这将创建一个 **Viseme 骨骼效应器列表 Scriptable Object** 现在你就可以定义自己的值了。

<figure><img src="/files/24ded3120b2945ee583b1fba98f4a8a020a48ce0" alt=""><figcaption></figcaption></figure>

#### Convai Lipsync 组件

当你将此组件附加到你的 Convai 角色上时，你会看到类似这样的内容。

<figure><img src="/files/90d11c86a1ded55d738c646da3ffcdf536db165b" alt=""><figcaption></figcaption></figure>

让我们了解这些内容是什么

1. 面部表情数据
   1. 头部 | 牙齿 | 舌头
      1. 渲染器：对应身体指定部分的 Skin Mesh Renderer
      2. Viseme 效应器列表：SkinMeshRenderer 的 Blendshape 将如何受到来自服务器的值影响。
   2. 下巴 | 舌头骨骼效应器
      1. 骨骼旋转会在多大程度上受到来自服务器的值影响？
   3. 下巴 | 舌头骨骼
      1. 分别控制下巴和舌头的骨骼引用
2. 权重混合强度
   1. 在延迟更新中，在两个帧之间插值的百分比。
3. 角色情绪
   1. 在这里了解更多关于角色情绪的信息 [角色情绪](/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin/utilities/character-emotion.md)

### 向你的 Convai 角色添加 Lipsync 的步骤

{% tabs %}
{% tab title=" 使用 Convai 的添加组件按钮" %}

1. 在层级中选择你的 Convai 驱动角色。
2. 在检查器面板中搜索 ConvaiNPC 组件，你会看到“添加组件”按钮。
3. 点击它，选择 Convai Lipsync 组件，然后点击应用

<figure><img src="/files/158145f53b420dc2e53913c0d12cbfeb432ce2d7" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="使用 Unity 的添加组件按钮 " %}

1. 在层级中选择你的 Convai 驱动角色。
2. 点击添加组件
3. 搜索 Convai Lipsync
4. 选择 Convai Lipsync 组件

<figure><img src="/files/42cb8a3837a4d0b0abf95a89ef12ae1a9bb30f1c" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

现在你可以根据自定义配置来配置该组件，或者使用 Convai 随 SDK 提供的众多预设之一

<figure><img src="/files/bb10311601fe8cd0fedb72ca20b77256c38325a8" alt=""><figcaption></figcaption></figure>

现在你的 lipsync 组件就可以在你的应用中使用了。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin/adding-lip-sync-to-your-character.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
