> 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/convai-unreal-engine-plugin/getting-started/configure-character-audio.md).

# 配置角色音频

调整角色语音播放音量，启用空间音频衰减，并在 Convai Chatbot 组件上配置打断淡出时长。

角色语音通过 `UConvaiAudioStreamer`播放，它扩展了 Unreal Engine 的 `UAudioComponent`。因此，所有标准 Unreal 音频设置——音量乘数、空间音频、衰减——都可以直接在 Convai Chatbot 组件的 **详情** 面板中使用，此外还有一个用于设置中断淡出行为的 Convai 专属属性。

### 默认音频行为

| 设置     | 默认值   | 备注                                                  |
| ------ | ----- | --------------------------------------------------- |
| 播放音量   | `1.0` | 全音量。通过继承的 **音量乘数** （位于 **声音** 类别中）控制。               |
| 空间音频   | 已禁用   | `AttenuationSettings` 为 `null` ——无论距离远近，语音音量都相同。    |
| 中断淡出时长 | 可配置   | 请参阅 [配置中断淡出时长](#configure-interrupt-fade-duration). |

### 调整播放音量

{% stepper %}
{% step %}

#### 打开角色蓝图

在蓝图编辑器中打开角色蓝图。
{% endstep %}

{% step %}

#### 选择 Convai Chatbot 组件

在 **Convai Chatbot** 组件面板中选择该组件。 **组件** 面板。
{% endstep %}

{% step %}

#### 展开声音部分

在 **详情** 面板中，展开 **声音** 部分（继承自 `UAudioComponent`).
{% endstep %}

{% step %}

#### 调整音量乘数

将 **音量乘数** 设置为所需的级别。 `1.0` 表示全音量； `0.0` 表示静音。
{% endstep %}
{% endstepper %}

{% hint style="info" %}
要在运行时通过蓝图将角色语音静音或取消静音，请调用 `SetVolumeMultiplier(0.0)` 或 `SetVolumeMultiplier(1.0)` 请参阅 Convai 聊天机器人组件参考。此设置仅调整播放音量，不会影响角色是否接收或处理语音。
{% endhint %}

### 启用空间音频

默认情况下，角色语音不会随距离增加而衰减。要添加基于距离的衰减，请执行以下操作：

{% stepper %}
{% step %}

#### 创建 Sound Attenuation 资源

在 **内容浏览器**中右键单击，然后选择 **Sounds > Sound Attenuation**。为其命名（例如， `SA_ConvaiCharacter`）。打开该资源，并根据场景比例配置衰减形状、衰减距离和音量曲线。
{% endstep %}

{% step %}

#### 将衰减资源分配给聊天机器人组件

打开角色蓝图并选择 **Convai 聊天机器人** 组件。在 **细节** 面板中，展开 **衰减** 部分（继承自 `UAudioComponent`）。启用 **覆盖衰减** 并分配你的 `SA_ConvaiCharacter` 资源。
{% endstep %}

{% step %}

#### 测试衰减效果

进入播放模式，走近角色，再逐渐远离。语音音量应根据衰减曲线随距离变化。
{% endstep %}
{% endstepper %}

{% hint style="success" %}
空间音频正常工作时，角色的声音会随距离增加而减弱。如果音量没有变化，请确认组件已启用 **覆盖衰减** ，并确认衰减资源的内半径小于预期的交互距离。
{% endhint %}

### 配置中断淡出时长

当在 `InterruptSpeech` 上调用 `UConvaiChatbotComponent`时，角色语音会在可配置的时长内淡出，而不是突然停止。

| 属性                              | 类别       | 说明                                        |
| ------------------------------- | -------- | ----------------------------------------- |
| `InterruptVoiceFadeOutDuration` | `Convai` | 语音被中断时，音频淡出至静音所需的秒数。值越短，响应感越强；值越长，听起来越自然。 |

要进行配置，请选择 **Convai 聊天机器人** 组件，并在 **中断语音淡出时长** 的 **Convai** 类别中找到该设置，该类别位于 **细节** 面板中。你也可以在每次调用时传入 `InVoiceFadeOutDuration` ，直接覆盖淡出时长 `InterruptSpeech` （在蓝图中）——对于该次中断，单次调用的值优先于组件默认值。

### 故障排查

#### 角色语音音量过低或听不见

**症状：** 角色语音会播放，但音量很低或完全听不见。

**原因：** **音量乘数** 在聊天机器人组件中的值已降低到 `1.0`以下，或者配置的空间衰减资源在较短距离内将衰减降至零。

**解决方法：** 选中 **Convai Chatbot** 组件并检查 **音量乘数** 类别下的 **声音** 设置。将其重置为 `1.0`。如果启用了衰减，请检查衰减曲线，并增大内半径和外半径。

**验证：** 进入播放模式，确认角色语音的音量正常且清晰可闻。

#### 角色语音不会随距离衰减

**症状：** 无论玩家与角色相距多远，听到的音量都相同。

**原因：** 默认情况下，空间衰减处于禁用状态（`AttenuationSettings = null`).

**解决方法：** 按照上文 [启用空间音频](#enable-spatial-audio) 中的步骤操作。

**验证：** 在播放模式下走近或远离角色，确认音量会随距离变化。

#### 语音中断时会突然停止，而不是逐渐淡出

**症状：** 调用 `InterruptSpeech` 时，角色音频会立即停止，没有淡出效果。

**原因：** `InterruptVoiceFadeOutDuration` 设置为 `0` 或非常小的值。

**解决方法：** 选中 **Convai Chatbot** 组件并增大 **中断语音淡出时长** 类别下的 **Convai** 设置。

**验证：** 触发 `InterruptSpeech` 在角色说话期间触发，并确认音频会在配置的时长内逐渐淡出。

### 后续步骤

{% content-ref url="/pages/9b983ed32e78e3fecceef1f1ca84663abe05edca" %}
[配置对话输入](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/getting-started/configure-conversation-input.md)
{% endcontent-ref %}


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/getting-started/configure-character-audio.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
