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

# XSpeechToTextSendString

> XSpeechToTextSendString

# XSpeechToTextSendString

在遊戲畫面上顯示文字。

## 語法

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

### 參數

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

作為文字來源的說話者名稱。

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

要在遊戲畫面上顯示的文字。

*type*   \_In\_\
類型：[XSpeechToTextType](https://docs.xbox.com/zh-TW/reference/system/xaccessibility/enums/xspeechtotexttype.md)

代表文字來源類型的列舉值：轉錄的遊戲語音聊天、遊戲內語音字幕、遊戲內文字朗讀或遊戲內文字聊天。遊戲會使用 *type* 參數的值，在遊戲畫面上的文字旁顯示麥克風圖示或鍵盤。

### 傳回值

類型：HRESULT

如果成功，則傳回 HRESULT。否則傳回錯誤碼。\
如需錯誤碼的清單，請參閱[錯誤碼](https://docs.xbox.com/zh-TW/reference/errorcodes.md)。

## 備註

> [!NOTE]
>
> 在時間敏感執行緒上呼叫此函式並不安全。如需詳細資訊，請參閱[時間敏感執行緒](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)。

若要讓此函式成功，必須啟用隱藏式字幕。
使用者必須在遊戲的 UI 中啟用隱藏式字幕功能。
如果使用者已啟用隱藏式字幕，您的遊戲可以呼叫 [XClosedCaptionSetEnabled](https://docs.xbox.com/zh-TW/reference/system/xaccessibility/functions/xclosedcaptionsetenabled.md) 來標記隱藏式字幕的狀態。

下列範例示範如何在語音轉文字視窗上顯示文字。

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

## 需求

**標頭：** XAccessibility.h

**程式庫：** xgameruntime.lib

**支援的平台：** Windows、XBOX One 系列主機和 XBOX Series 主機

## 概念文件

* [時間敏感執行緒](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## 另請參閱

[XAccessibility](https://docs.xbox.com/zh-TW/reference/system/xaccessibility/xaccessibility_members.md)

[XSpeechToTextType](https://docs.xbox.com/zh-TW/reference/system/xaccessibility/enums/xspeechtotexttype.md)

[XClosedCaptionSetEnabled](https://docs.xbox.com/zh-TW/reference/system/xaccessibility/functions/xclosedcaptionsetenabled.md)


## Related topics

- [XSpeechToTextType](https://docs.xbox.com/zh-TW/reference/system/xaccessibility/enums/xspeechtotexttype.md)
- [XSpeechToTextPositionHint](https://docs.xbox.com/zh-TW/reference/system/xaccessibility/enums/xspeechtotextpositionhint.md)
- [XAccessibility (API 內容)](https://docs.xbox.com/zh-TW/reference/system/xaccessibility/xaccessibility_members.md)
- [XSpeechToTextUpdateHypothesisString](https://docs.xbox.com/zh-TW/reference/system/xaccessibility/functions/xspeechtotextupdatehypothesisstring.md)
- [XSpeechToTextBeginHypothesisString](https://docs.xbox.com/zh-TW/reference/system/xaccessibility/functions/xspeechtotextbeginhypothesisstring.md)
