> ## 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

在遊戲畫面上顯示文字。

## 語法

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

### 參數

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

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

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

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

*type*   \_In\_\
類型：[XSpeechToTextType](/zh-TW/reference/system/xaccessibility/enums/xspeechtotexttype)

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

### 傳回值

類型：HRESULT

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

## 備註

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

若要讓此函式成功，必須啟用隱藏式字幕。
使用者必須在遊戲的 UI 中啟用隱藏式字幕功能。
如果使用者已啟用隱藏式字幕，您的遊戲可以呼叫 [XClosedCaptionSetEnabled](/zh-TW/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 主機

## 概念文件

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

## 另請參閱

[XAccessibility](/zh-TW/reference/system/xaccessibility/xaccessibility_members)

[XSpeechToTextType](/zh-TW/reference/system/xaccessibility/enums/xspeechtotexttype)

[XClosedCaptionSetEnabled](/zh-TW/reference/system/xaccessibility/functions/xclosedcaptionsetenabled)


## Related topics

- [XSpeechToTextSendString](/reference/system/xaccessibility/functions/xspeechtotextsendstring.md)
- [XSpeechToTextType](/reference/system/xaccessibility/enums/xspeechtotexttype.md)
