> 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 组件的 **Details** 面板中使用，同时还有一个用于中断淡出行为的 Convai 特定属性。

### 默认音频行为

| 设置     | 默认       | 备注                                                  |
| ------ | -------- | --------------------------------------------------- |
| 播放音量   | `1.0`    | 全音量。由继承的 **音量倍增** ，位于 **声音** 类别。                    |
| 空间音频   | Disabled | `AttenuationSettings` 是 `null` ——无论距离多远，语音都以相同音量播放。 |
| 中断淡出时长 | 可配置      | 参见 [配置中断淡出时长](#configure-interrupt-fade-duration).  |

### 调整播放音量

{% stepper %}
{% step %}

#### 打开角色蓝图

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

{% step %}

#### 选择 Convai Chatbot 组件

选中 **Convai 聊天机器人** 组件，在 **组件** 面板。
{% endstep %}

{% step %}

#### 展开 Sound 部分

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

{% step %}

#### 调整音量倍增

设置 **音量倍增** 到所需级别。 `1.0` 为全音量； `0.0` 为静音。
{% endstep %}
{% endstepper %}

{% hint style="info" %}
要在运行时通过 Blueprint 将角色语音静音或取消静音，请调用 `SetVolumeMultiplier(0.0)` 或 `SetVolumeMultiplier(1.0)` 在 Convai Chatbot 组件引用上。此操作只会调整播放音量——不会影响角色是否接收或处理语音。
{% endhint %}

### 启用空间音频

默认情况下，角色语音不会随距离衰减。若要添加基于距离的衰减：

{% stepper %}
{% step %}

#### 创建 Sound Attenuation 资源

在 **内容浏览器**，右键单击并选择 **Sounds > Sound Attenuation**。将其命名（例如， `SA_ConvaiCharacter`）。打开它并配置衰减形状、衰减距离和音量曲线，以匹配你的场景比例。
{% endstep %}

{% step %}

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

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

{% step %}

#### 测试衰减

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

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

### 配置中断淡出时长

当 `InterruptSpeech` 被调用于 `UConvaiChatbotComponent`，角色语音会在可配置时长内淡出，而不是突然中断。

| 属性                              | 类别       | 说明                                     |
| ------------------------------- | -------- | -------------------------------------- |
| `InterruptVoiceFadeOutDuration` | `Convai` | 语音在被中断后淡出至静音所需的秒数。较短的值响应更快；较长的值听起来更自然。 |

要进行配置，请选择 **Convai 聊天机器人** 组件并找到 **中断语音淡出持续时间** ，位于 **Convai** 类别中的 **Details** 面板。你还可以通过传入 `InVoiceFadeOutDuration` 直接传给 `InterruptSpeech` 在 Blueprint 中——每次调用的值会优先于该中断的组件默认值。

### 故障排除

#### 角色语音太小声或听不见

**症状：** 角色的声音会播放，但非常小声，或者完全听不见。

**原因：** **音量倍增** 聊天机器人组件上的设置已降低到低于 `1.0`，或者空间衰减资源的衰减在较短距离内就降为零。

**修复：** 选中 **Convai 聊天机器人** 组件并检查 **音量倍增** ，位于 **声音** 类别。将其重置为 `1.0`。如果已启用衰减，请检查衰减曲线并扩大内半径和外半径。

**验证：** 进入播放模式并确认角色的声音可以以正常音量听到。

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

**症状：** 无论玩家离角色多远，都以相同音量可听见。

**原因：** 空间衰减默认是禁用的（`AttenuationSettings = null`).

**修复：** 按照 [启用空间音频](#enable-spatial-audio) 上面的步骤。

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

#### 中断时语音突然停止而不是淡出

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

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

**修复：** 选中 **Convai 聊天机器人** 组件并增加 **中断语音淡出持续时间** ，位于 **Convai** 类别。

**验证：** 触发器 `InterruptSpeech` 在角色语音播放期间，并确认音频会在配置的时长内淡出。

### 下一步

{% content-ref url="/pages/9b983ed32e78e3fecceef1f1ca84663abe05edca" %}
[配置对话输入](/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.
