> 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).

# 配置角色音频

角色语音通过以下方式播放 `UConvaiAudioStreamer`，它扩展了 Unreal Engine 的 `UAudioComponent`。因此，所有标准的 Unreal 音频设置——音量倍数、空间音频、衰减——都可以直接在 Convai Chatbot 组件的 **Details** 面板中访问，同时还有一个用于中断淡出行为的 Convai 特定属性。

### 默认音频行为

| 设置     | 默认值   | 说明                                                  |
| ------ | ----- | --------------------------------------------------- |
| 播放音量   | `1.0` | 全音量。由继承的 **音量倍数** 在 **声音** 类别下。                     |
| 空间音频   | 已禁用   | `AttenuationSettings` 为 `null` ——语音以相同音量播放，不受距离影响。  |
| 中断淡出时长 | 可配置   | 请参见 [配置中断淡出时长](#configure-interrupt-fade-duration). |

### 调整播放音量

{% stepper %}
{% step %}

#### 打开角色蓝图

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

{% step %}

#### 选择 Convai Chatbot 组件

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

{% step %}

#### 展开 Sound 部分

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

{% step %}

#### 调整音量倍数

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

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

### 启用空间音频

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

{% stepper %}
{% step %}

#### 创建 Sound Attenuation 资源

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

{% step %}

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

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

{% step %}

#### 测试衰减

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

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

### 配置中断淡出时长

当 `InterruptSpeech` 在以下对象上调用 `UConvaiChatbotComponent`，角色语音会在可配置的时长内淡出，而不是突然中断。

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

要进行配置，请选择 **Convai 聊天机器人** 组件并找到 **打断语音淡出时长** 在 **Convai** 类别中 **Details** 面板。你还可以通过传递以下参数为每次调用覆盖淡出时长： `InVoiceFadeOutDuration` 直接传递给 `InterruptSpeech` 在蓝图中——该次调用的值优先于该次中断的组件默认值。

### 故障排查

#### 角色语音过于安静或听不见

**症状：** 角色的声音正在播放，但非常小声或根本听不到。

**原因：** **音量倍数** 在聊天机器人组件上的数值已降低到低于 `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 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/convai-unreal-engine-plugin/getting-started/configure-character-audio.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.
