> 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/unreal-engine/blueprints-reference/convai-chatbot.md).

# Convai 聊天机器人

**Convai 聊天机器人** 是一个 Actor 组件，负责处理并获取来自 [**Convai 玩家**](/api-docs/zh/cha-jian-yu-ji-cheng/unreal-engine/blueprints-reference/convai-player.md) 组件的语音音频响应。它会播放音频响应，并提供多种用于转录、动作、文本响应等的有用事件。

## 属性和函数

<figure><img src="/files/e9a61a23a25e4fc0f874da3ae85d3573accb2bfb" alt=""><figcaption><p>Convai 聊天机器人属性和函数</p></figcaption></figure>

### 角色变量

| 属性                 | 类型                 | 说明                                                                         |
| ------------------ | ------------------ | -------------------------------------------------------------------------- |
| 角色 ID              | FString            | 您希望分配给该组件的角色 ID。                                                           |
| 打断语音淡出时长           | Float              | 被打断后，语音响应逐渐淡出直至停止所需的秒数。                                                    |
| 语言代码               | FString            | 读取 Language Code 的值。                                                       |
| Ready Player Me 链接 | FString            | 读取 Ready Player Me Link 的值。                                                |
| 会话 ID              | FString            | 用于跟踪之前对话的记忆，设为 -1 表示没有之前的对话。（该属性会随着你与角色交流而改变）你可以保存某次对话的会话 ID，稍后再将其设回以恢复对话。 |
| 语音类型               | FString            | 读取变量 VoiceType 的值。                                                         |
| 环境                 | UConvaiEnvironment | 包含场景中所有相关对象和角色，包括（玩家），以及角色可执行的所有动作。                                        |
| 头像图片链接             | FString            | 读取 Avatoar Image Link 的值。                                                  |
| 角色名称               | FString            | 读取变量 CharacterName 的值。                                                     |
| 背景故事               | FString            | 读取变量 Backstory 的值。                                                         |

### 对话状态

| 函数          | 返回    | 说明                                     |
| ----------- | ----- | -------------------------------------- |
| `是否处于对话中()` | `布尔值` | 返回 **为 True，** 如果角色正在被交谈、正在说话，或正在处理响应。 |
| `是否正在说话( )` | `布尔值` | 返回 **为 True，** 如果角色当前正在说话。             |
| `是否正在思考()`  | `布尔值` | 返回 **为 True，** 如果角色仍在处理中，且尚未收到完整响应。    |
| `是否正在监听 ()` | `布尔值` | 返回 **为 True，** 如果角色当前正在监听玩家。           |

### 口型同步

| 函数               | 返回      | 说明                                |
| ---------------- | ------- | --------------------------------- |
| `支持口型同步()`       | `布尔值`   | 返回 `True`，如果 LipSync 组件可用并已附加到角色。 |
| `获取 Viseme 名称()` | `字符串数组` | 返回 viseme 名称列表。                   |
| `获取 Visemes()`   | `浮点数数组` | 返回最近预测的 viseme 分数。                |

## 对话管理

| 函数       | 返回  | 说明                                   |
| -------- | --- | ------------------------------------ |
| `打断语音()` | `无` | 以提供的淡出时长打断当前语音。                      |
| `重置对话()` | `无` | 重置与角色的对话并移除之前的记忆。这相当于将会话 ID 属性设为 -1。 |

### 事件

<figure><img src="/files/16ad37039f413befca3df09d8fea1666ae40edab" alt=""><figcaption><p><strong>Convai 聊天机器人</strong> 组件事件示意图</p></figcaption></figure>

### 事件名称和说明。

<table><thead><tr><th width="262">事件名称</th><th>说明</th></tr></thead><tbody><tr><td>On Actions Received</td><td>当从角色接收到新动作时调用。</td></tr><tr><td>收到文本时</td><td>当从角色接收到新文本时调用。</td></tr><tr><td>收到转录时</td><td>当有新的转录可用时调用。</td></tr><tr><td>开始说话时</td><td>当角色开始说话时调用。</td></tr><tr><td>说话结束时</td><td>当角色停止说话时调用。</td></tr><tr><td>失败时</td><td>当发生错误时调用。</td></tr></tbody></table>

### 事件参数

<table><thead><tr><th width="260">参数</th><th>说明</th></tr></thead><tbody><tr><td>机器人文本</td><td>接收到的文本</td></tr><tr><td>音频时长</td><td>接收到的语音文本的时长。如果只接收到文本而没有音频，则为零。</td></tr><tr><td>是否为最终</td><td>如果这是接收到的最后一段文本/转录，则为 True。</td></tr><tr><td>转录</td><td>接收到的转录。</td></tr><tr><td>转录是否就绪</td><td>如果接收到的转录已就绪且不再变化，则为 True；如果转录仍处于中间状态并且还会变化，则为 false。</td></tr></tbody></table>


---

# 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/unreal-engine/blueprints-reference/convai-chatbot.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.
