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

# Convai Player

**Convai 玩家** 是一个负责捕获麦克风音频并将其流式传输到 Convai 角色的 Actor 组件。

{% hint style="info" %}
为了在多人游戏中使用语音聊天，此组件必须添加到玩家所控制的对象上，而不是 PlayerController 上。
{% endhint %}

<figure><img src="/files/05dead67639cb2074ea9ee6e249f5f9af9f03c83" alt=""><figcaption><p>Convai Player 函数</p></figcaption></figure>

### 文本转语音和语音转语音

<table><thead><tr><th width="328.3333333333333">函数</th><th>返回</th><th>说明</th></tr></thead><tbody><tr><td><code>是否正在录音()</code></td><td><code>布尔值</code></td><td>返回 <code>True</code> 如果已录制麦克风音频， <code>假</code> 否则。</td></tr><tr><td><code>是否在说话()</code></td><td><code>布尔值</code></td><td>如果麦克风音频正在被流式传输，则返回真，否则返回假。</td></tr><tr><td><code>开始录音()</code></td><td><code>无</code></td><td>开始录制麦克风音频，之后请使用“结束录音”函数。</td></tr><tr><td><code>结束录音()</code></td><td><code>USoundWave*</code></td><td>停止从麦克风录音，并输出录制的麦克风音频。</td></tr><tr><td><p><code>发送文本(</code></p><p><code>UConvaiChatbotComponent* ConvaiChatbotComponent,</code></p><p><code>FString Text,</code></p><p><code>UConvaiEnvironment* Environment, bool GenerateActions,</code></p><p><code>bool VoiceResponse,</code></p><p><code>bool RunOnServer,</code></p><p><code>bool UseServerAPI_Key</code></p><p><code>)</code></p></td><td><code>无</code></td><td>向角色发送文本。</td></tr><tr><td><p><code>开始说话(</code></p><p><code>UConvaiChatbotComponent* ConvaiChatbotComponent, UConvaiEnvironment* Environment, bool GenerateActions,</code></p><p><code>bool VoiceResponse,</code></p><p><code>bool RunOnServer,</code></p><p><code>bool StreamPlayerMic,</code></p><p><code>bool UseServerAPI_Key</code></p><p><code>)</code></p></td><td><code>无</code></td><td>开始将麦克风音频流式传输给角色。之后请使用“结束说话”函数，让角色知道你正在说话。</td></tr><tr><td><code>结束说话()</code></td><td><code>无</code></td><td>停止将麦克风音频流式传输给角色。</td></tr></tbody></table>

### 麦克风设置

| 函数              | 返回                | 说明           |
| --------------- | ----------------- | ------------ |
| `获取可用的捕获设备名称()` | `TArray<FString>` | 返回所有可用的捕获设备。 |
| `获取麦克风音量倍率()`   | `无`               | 获取麦克风音量倍率。   |
| `设置捕获设备名称()`    | `布尔值`             | 设置捕获设备名称。    |
| `设置麦克风音量倍率()`   | 无                 | 设置麦克风音量倍率。   |
| `获取当前捕获设备()`    | 无                 | 获取当前捕获设备的信息。 |

### StartTalking() 和 SendText() 参数

<table><thead><tr><th width="378">参数</th><th>说明</th></tr></thead><tbody><tr><td>UConvaiChatbotComponent* ConvaiChatbotComponent</td><td>要交谈的角色。</td></tr><tr><td>UConvaiEnvironment* Environment</td><td>包含场景中所有相关对象和角色，包括（玩家），以及角色可执行的所有动作。使用 <code>CreateConvaiEnvironment()</code> 函数来创建，然后使用诸如 <code>AddAction(), AddCharacter(), AddMainCharacter()</code> 来填充它。</td></tr><tr><td>FString Text</td><td>要发送给角色的文本。</td></tr><tr><td>bool GenerateActions</td><td>是否生成动作（必须提供且有效的 Environment）</td></tr><tr><td>bool VoiceResponse</td><td>如果为 true，则会生成语音回复，否则只会生成文本回复。</td></tr><tr><td>bool RunOnServer</td><td>如果为 true，则该函数会在服务器上运行，这可用于多人会话中，让其他玩家听到角色的语音回复。</td></tr><tr><td>bool StreamPlayerMic</td><td>如果为 true，则会在多人会话中将玩家的语音流式传输给其他玩家，这与语音聊天效果相同。</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-player.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.
