> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XSpeechToTextSendString

> XSpeechToTextSendString

# XSpeechToTextSendString

在游戏 title 屏幕上显示文本。

## 语法

```cpp theme={null}
HRESULT XSpeechToTextSendString(  
         const char* speakerName,  
         const char* content,  
         XSpeechToTextType type  
)  
```

### 参数

*speakerName*   \_In\_z\_\
类型：char\*

作为文本来源的说话者的名称。

*content*   \_In\_z\_\
类型：char\*

要显示在游戏 title 屏幕上的文本。

*type*   \_In\_\
类型：[XSpeechToTextType](/reference/system/xaccessibility/enums/xspeechtotexttype)

一个枚举值，表示文本的源类型：经转录的游戏语音聊天、游戏内语音字幕、游戏内文本朗读或游戏内文本聊天。游戏 title 使用 *type* 参数的值来决定在游戏屏幕上文本旁边显示麦克风图标还是键盘图标。

### 返回值

类型：HRESULT

成功时返回 HRESULT。否则返回错误代码。\
有关错误代码的列表，请参阅 [错误代码](/reference/errorcodes)。

## 备注

<Note>此函数不能在时间敏感线程上安全调用。有关详细信息，请参阅 [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)。</Note>

要使此函数调用成功，必须启用隐藏式字幕。
用户必须在游戏 title 的 UI 中启用隐藏式字幕功能。
如果用户启用了隐藏式字幕，则你的游戏 title 可以通过调用 [XClosedCaptionSetEnabled](/reference/system/xaccessibility/functions/xclosedcaptionsetenabled) 来标记隐藏式字幕的状态。

以下示例演示了如何在语音转文本窗口上显示文本。

```cpp theme={null}
auto hr = XSpeechToTextSendString("Sandy", "This is my text.", XSpeechToTextType::Text);
)  
```

## 要求

**头文件：** XAccessibility.h

**库：** xgameruntime.lib

**支持的平台：** Windows、XBOX One 系列主机和 XBOX Series 主机

## 概念性文档

* [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## 另请参阅

[XAccessibility](/reference/system/xaccessibility/xaccessibility_members)

[XSpeechToTextType](/reference/system/xaccessibility/enums/xspeechtotexttype)

[XClosedCaptionSetEnabled](/reference/system/xaccessibility/functions/xclosedcaptionsetenabled)


## Related topics

- [XSpeechToTextType](/zh-CN/reference/system/xaccessibility/enums/xspeechtotexttype.md)
- [XSpeechToTextPositionHint](/zh-CN/reference/system/xaccessibility/enums/xspeechtotextpositionhint.md)
- [XAccessibility](/zh-CN/reference/system/xaccessibility/xaccessibility_members.md)
- [XSpeechToTextUpdateHypothesisString](/zh-CN/reference/system/xaccessibility/functions/xspeechtotextupdatehypothesisstring.md)
- [XSpeechToTextBeginHypothesisString](/zh-CN/reference/system/xaccessibility/functions/xspeechtotextbeginhypothesisstring.md)
