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

# XSpeechSynthesizerCloseStreamHandle

> XSpeechSynthesizerCloseStreamHandle

# XSpeechSynthesizerCloseStreamHandle

Closes the speech synthesizer stream and releases allocated system resources.

## Syntax

```cpp theme={null}
HRESULT XSpeechSynthesizerCloseStreamHandle(  
         XSpeechSynthesizerStreamHandle speechSynthesisStream  
)  
```

### Parameters

*speechSynthesisStream*   \_In\_\
Type: XSpeechSynthesizerStreamHandle

The speech synthesis stream 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](/reference/errorcodes).

## 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).</Note>

Use this function to close a speech synthesizer stream created by calling the [XSpeechSynthesizerCreateStreamFromText](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizercreatestreamfromtext) function.

To prevent memory leaks, call this function to close a speech synthesizer stream handle after you've completed all operations that are using the handle. All outstanding asynchronous operations must be completed before this function is called.

For an example that demonstrates how to use the **XSpeechSynthesizerCloseStreamHandle** function, see [XSpeechSynthesizerCreate](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizercreate).

## Requirements

**Header:** XSpeechSynthesizer.h

**Library:** xgameruntime.lib

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

## Conceptual documentation

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

## See also

[XAccessibility](/reference/system/xaccessibility/xaccessibility_members)\
[XSpeechSynthesizerCloseHandle](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizerclosehandle)\
[XSpeechSynthesizer](/reference/system/xspeechsynthesizer/xspeechsynthesizer_members)
