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

Closes the speech synthesizer and releases allocated system resources.

## Syntax

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

### Parameters

*speechSynthesizer*   \_In\_opt\_\
Type: XSpeechSynthesizerHandle

The speech synthesizer to close.

### Return value

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

Returns **S\_OK** if successful; otherwise, returns an error code. For a list of error codes, see [Error Codes](https://docs.xbox.com/reference/errorcodes.md).

## Remarks

> [!NOTE]
>
> This function isn't safe to call on a time-sensitive thread. For more information, see [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads).

* Use this function to close a speech synthesizer created by calling the [XSpeechSynthesizerCreate](https://docs.xbox.com/reference/system/xspeechsynthesizer/functions/xspeechsynthesizercreate.md) function.

* To prevent memory leaks, call this function to close a speech synthesizer handle after you've completed all operations that are using the handle.

* For an example that demonstrates how to use the **XSpeechSynthesizerCloseHandle** function, see [XSpeechSynthesizerCreate](https://docs.xbox.com/reference/system/xspeechsynthesizer/functions/xspeechsynthesizercreate.md).

## Requirements

**Header:** XSpeechSynthesizer.h

**Library:** xgameruntime.lib

**Supported platforms:** Windows, XBOX One family consoles and XBOX Series consoles

## Conceptual documentation

* [Text-to-speech](https://docs.xbox.com/build/console-features/text-to-speech/text-to-speech.md)
* [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## See also

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


## Related topics

- [XSpeechSynthesizerCloseStreamHandle](https://docs.xbox.com/reference/system/xspeechsynthesizer/functions/xspeechsynthesizerclosestreamhandle.md)
- [XSpeechSynthesizerCreate](https://docs.xbox.com/reference/system/xspeechsynthesizer/functions/xspeechsynthesizercreate.md)
- [XSpeechSynthesizer (API contents)](https://docs.xbox.com/reference/system/xspeechsynthesizer/xspeechsynthesizer_members.md)
- [Using C# wrappers for GDK APIs in your Unity project](https://docs.xbox.com/build/gdk-and-engines/unity/unity-api-wrappers.md)
- [XSpeechSynthesizerCreateStreamFromSsml](https://docs.xbox.com/reference/system/xspeechsynthesizer/functions/xspeechsynthesizercreatestreamfromssml.md)
