> ## 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](/reference/system/xaccessibility/enums/xspeechtotexttype)

假设字符串的源类型。

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

假设的 ID。

<a id="retvalSection" />

### 返回值

类型：HRESULT

HRESULT 成功或错误代码。

<a id="remarksSection" />

## 备注

假设（hypothesis）是对说话者所说内容的一种推测，通常由语音识别器在说话者说到短语中间时生成。语音转文本覆盖层 API 可以在游戏画面上显示假设字符串。

语音转文本覆盖层 API 还支持键入的文本。*type* 参数用于标识假设字符串的源。

应用负责在假设被最终确定或取消之前保留 *hypothesisId* 的值。

若要更新覆盖层中的假设字符串，请使用 [XSpeechToTextUpdateHypothesisString](/reference/system/xaccessibility/functions/xspeechtotextupdatehypothesisstring)。

若要取消假设并将其从覆盖层中移除，请使用 [XSpeechToTextCancelHypothesisString](/reference/system/xaccessibility/functions/xspeechtotextcancelhypothesisstring)。

若要最终确定假设，请使用 [XSpeechToTextFinalizeHypothesisString](/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](/reference/system/xaccessibility/xaccessibility_members)


## Related topics

- [XSpeechToTextCancelHypothesisString](/zh-CN/reference/system/xaccessibility/functions/xspeechtotextcancelhypothesisstring.md)
- [XSpeechToTextUpdateHypothesisString](/zh-CN/reference/system/xaccessibility/functions/xspeechtotextupdatehypothesisstring.md)
- [XSpeechToTextFinalizeHypothesisString](/zh-CN/reference/system/xaccessibility/functions/xspeechtotextfinalizehypothesisstring.md)
- [XAccessibility](/zh-CN/reference/system/xaccessibility/xaccessibility_members.md)
- [面向 GDK 的 Unity C# API 包装器](/zh-CN/build/gdk-and-engines/unity/unity-api-wrappers.md)
