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

# XSpeechSynthesizerGetStreamData

> XSpeechSynthesizerGetStreamData

# XSpeechSynthesizerGetStreamData

Retrieves the data from a speech synthesis stream.

## Syntax

```cpp theme={null}
HRESULT XSpeechSynthesizerGetStreamData(  
         XSpeechSynthesizerStreamHandle speechSynthesisStream,  
         size_t bufferSize,  
         void* buffer,  
         size_t* bufferUsed  
)  
```

### Parameters

*speechSynthesisStream*   \_In\_\
Type: XSpeechSynthesizerStreamHandle

The speech synthesis stream that contains the data buffer.

*bufferSize*   \_In\_\
Type: size\_t

The size of the buffer, in bytes, returned by [XSpeechSynthesizerGetStreamDataSize](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizergetstreamdatasize).

*buffer*   \_Out\_writes\_to\_(bufferSize,*bufferUsed)\
Type: void*

A pointer to the data buffer that will receive the data.

*bufferUsed*   \_Out\_opt\_\
Type: size\_t\*

The size of the data received in *buffer*, in bytes.

### 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). If the function fails because *speechSynthesisStream* isn't set to a valid speech synthesizer stream handle, the return value is set to **HRESULT\_FROM\_WIN32(ERROR\_NOT\_FOUND)**.

## 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 retrieve the audio data for synthesized speech, from the data buffer of a speech synthesizer stream created by calling the [XSpeechSynthesizerCreateStreamFromText](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizercreatestreamfromtext) function. The audio data is returned in the WAVE container (`audio/wav` MIME type) format.

For an example that demonstrates how to use the **XSpeechSynthesizerGetStreamData** 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)\
[XSpeechSynthesizerGetStreamDataSize](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizergetstreamdatasize)\
[XSpeechSynthesizer](/reference/system/xspeechsynthesizer/xspeechsynthesizer_members)


## Related topics

- [XSpeechSynthesizerGetStreamDataSize](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizergetstreamdatasize.md)
- [XSpeechSynthesizer](/reference/system/xspeechsynthesizer/xspeechsynthesizer_members.md)
- [XSpeechSynthesizerCreate](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizercreate.md)
- [Text-to-speech](/build/console-features/text-to-speech/text-to-speech.md)
- [XSpeechSynthesizerCreateStreamFromSsml](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizercreatestreamfromssml.md)
