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

# XSpeechSynthesizerCloseHandle

> XSpeechSynthesizerCloseHandle

# XSpeechSynthesizerCloseHandle

关闭语音合成器并释放已分配的系统资源。

## 语法

```cpp theme={null}
HRESULT XSpeechSynthesizerCloseHandle(  
         XSpeechSynthesizerHandle speechSynthesizer  
)  
```

### 参数

*speechSynthesizer*   \_In\_opt\_\
类型：XSpeechSynthesizerHandle

要关闭的语音合成器。

### 返回值

类型：[HRESULT](https://learn.microsoft.com/openspecs/windows_protocols/ms-erref/0642cb2f-2075-4469-918c-4441e69c548a)

如果成功，则返回 **S\_OK**；否则返回错误代码。有关错误代码列表，请参阅[错误代码](https://docs.xbox.com/zh-CN/reference/errorcodes.md)。

## 备注

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

* 使用此函数关闭通过调用 [XSpeechSynthesizerCreate](https://docs.xbox.com/zh-CN/reference/system/xspeechsynthesizer/functions/xspeechsynthesizercreate.md) 函数创建的语音合成器。

* 为防止内存泄漏，在完成使用该句柄的所有操作后，请调用此函数关闭语音合成器句柄。

* 有关演示如何使用 **XSpeechSynthesizerCloseHandle** 函数的示例，请参阅 [XSpeechSynthesizerCreate](https://docs.xbox.com/zh-CN/reference/system/xspeechsynthesizer/functions/xspeechsynthesizercreate.md)。

## 要求

**头文件：** XSpeechSynthesizer.h

**库：** xgameruntime.lib

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

## 概念文档

* [文本转语音](https://docs.xbox.com/zh-CN/build/console-features/text-to-speech/text-to-speech.md)
* [时间敏感型线程](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## 另请参阅

[XAccessibility](https://docs.xbox.com/zh-CN/reference/system/xaccessibility/xaccessibility_members.md)\
[XSpeechSynthesizerCreate](https://docs.xbox.com/zh-CN/reference/system/xspeechsynthesizer/functions/xspeechsynthesizercreate.md)\
[XSpeechSynthesizerCloseStreamHandle](https://docs.xbox.com/zh-CN/reference/system/xspeechsynthesizer/functions/xspeechsynthesizerclosestreamhandle.md)\
[XSpeechSynthesizer](https://docs.xbox.com/zh-CN/reference/system/xspeechsynthesizer/xspeechsynthesizer_members.md)


## Related topics

- [XSpeechSynthesizerCloseStreamHandle](https://docs.xbox.com/zh-CN/reference/system/xspeechsynthesizer/functions/xspeechsynthesizerclosestreamhandle.md)
- [XSpeechSynthesizerCreate](https://docs.xbox.com/zh-CN/reference/system/xspeechsynthesizer/functions/xspeechsynthesizercreate.md)
- [XSpeechSynthesizer（API 内容）](https://docs.xbox.com/zh-CN/reference/system/xspeechsynthesizer/xspeechsynthesizer_members.md)
- [在 Unity 项目中使用 GDK API 的 C# 包装器](https://docs.xbox.com/zh-CN/build/gdk-and-engines/unity/unity-api-wrappers.md)
- [XSpeechSynthesizerCreateStreamFromSsml](https://docs.xbox.com/zh-CN/reference/system/xspeechsynthesizer/functions/xspeechsynthesizercreatestreamfromssml.md)
