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

# XSpeechToTextBeginHypothesisString

> XSpeechToTextBeginHypothesisString

# XSpeechToTextBeginHypothesisString

開始一個假設，並在文字覆疊中顯示其字串。

<a id="syntaxSection" />

## 語法

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

<a id="parametersSection" />

### 參數

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

要與假設字串一起顯示的說話者名稱。

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

初始假設字串。

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

假設字串的來源類型。

*hypothesisId*   \_Out\_\
類型：uint32\_t\*

假設的識別碼。

<a id="retvalSection" />

### 傳回值

類型：HRESULT

HRESULT 成功或錯誤碼。

<a id="remarksSection" />

## 備註

假設是對說話者所說內容的猜測，通常由語音辨識器在說話者說到一半時產生。語音轉文字覆疊 API 可以在遊戲畫面上顯示假設字串。

語音轉文字覆疊 API 也支援輸入的文字。*type* 參數會識別假設字串的來源。

應用程式負責保留 *hypothesisId* 的值，直到假設完成或取消為止。

若要更新覆疊中的假設字串，請使用 [XSpeechToTextUpdateHypothesisString](/zh-TW/reference/system/xaccessibility/functions/xspeechtotextupdatehypothesisstring)。

若要取消假設並將其從覆疊中移除，請使用 [XSpeechToTextCancelHypothesisString](/zh-TW/reference/system/xaccessibility/functions/xspeechtotextcancelhypothesisstring)。

若要完成假設，請使用 [XSpeechToTextFinalizeHypothesisString](/zh-TW/reference/system/xaccessibility/functions/xspeechtotextfinalizehypothesisstring)。

在某些平台上，必須等到應用程式呼叫 `XSpeechToTextFinalizeHypothesisString` 之後，才會顯示假設字串。除非假設已取消，否則您的應用程式一律必須呼叫 `XSpeechToTextFinalizeHypothesisString`，以確保字串會顯示。

下列程式碼範例示範應用程式建立假設、更新假設，然後完成假設。

```cpp theme={null}
void RowanHypothesisSample() 
{ 
    UINT32 hypothesisId; 
    XSpeechToTextBeginHypothesisString("Rowan", "I am typing some text.", XSpeechToTextType::Text, &hypothesisId); 
 
    // Some time passes. 
 
    XSpeechToTextUpdateHypothesisString(hypothesisId, "I am still typing some text."); 
 
    // Some time passes. 
 
    XSpeechToTextFinalizeHypothesisString(hypothesisId, "I typed some text. I am done typing."); 
} 
```

下列程式碼範例示範應用程式建立假設、更新假設，然後取消假設。

```cpp theme={null}
void QuincyHypothesisSample() 
{ 
    UINT32 hypothesisId; 
    XSpeechToTextBeginHypothesisString("Quincy", "I am speaking some text.", XSpeechToTextType::Voice, &hypothesisId); 
 
    // Some time passes. 
 
    XSpeechToTextUpdateHypothesisString(hypothesisId, "I am still speaking some text."); 
 
    // Some time passes. 
 
    XSpeechToTextCancelHypothesisString(hypothesisId); 
} 
```

<a id="requirementsSection" />

## 需求

**標頭：** XAccessibility.h

**程式庫：** xgameruntime.lib

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

<a id="seealsoSection" />

## 另請參閱

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


## Related topics

- [XSpeechToTextBeginHypothesisString](/reference/system/xaccessibility/functions/xspeechtotextbeginhypothesisstring.md)
- [XSpeechToTextCancelHypothesisString](/reference/system/xaccessibility/functions/xspeechtotextcancelhypothesisstring.md)
- [XSpeechToTextUpdateHypothesisString](/reference/system/xaccessibility/functions/xspeechtotextupdatehypothesisstring.md)
- [XSpeechToTextFinalizeHypothesisString](/reference/system/xaccessibility/functions/xspeechtotextfinalizehypothesisstring.md)
