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

从语音合成流中检索数据。

## 语法

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

### 参数

*speechSynthesisStream*   \_In\_\
类型：XSpeechSynthesizerStreamHandle

包含数据缓冲区的语音合成流。

*bufferSize*   \_In\_\
类型：size\_t

[XSpeechSynthesizerGetStreamDataSize](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizergetstreamdatasize) 返回的缓冲区大小（以字节为单位）。

*buffer*   \_Out\_writes\_to\_(bufferSize,*bufferUsed)\
类型：void*

指向将接收数据的数据缓冲区的指针。

*bufferUsed*   \_Out\_opt\_\
类型：size\_t\*

在 *buffer* 中接收的数据的大小（以字节为单位）。

### 返回值

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

如果成功，则返回 **S\_OK**；否则返回错误代码。有关错误代码列表，请参阅[错误代码](/reference/errorcodes)。如果因为 *speechSynthesisStream* 未设为有效的语音合成器流句柄而函数失败，则返回值将设为 **HRESULT\_FROM\_WIN32(ERROR\_NOT\_FOUND)**。

## 备注

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

使用此函数从通过调用 [XSpeechSynthesizerCreateStreamFromText](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizercreatestreamfromtext) 函数创建的语音合成器流的数据缓冲区中检索合成语音的音频数据。音频数据以 WAVE 容器（`audio/wav` MIME 类型）格式返回。

有关演示如何使用 **XSpeechSynthesizerGetStreamData** 函数的示例，请参阅 [XSpeechSynthesizerCreate](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizercreate)。

## 要求

**头文件：** XSpeechSynthesizer.h

**库：** xgameruntime.lib

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

## 概念文档

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

## 另请参阅

[XAccessibility](/reference/system/xaccessibility/xaccessibility_members)\
[XSpeechSynthesizerGetStreamDataSize](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizergetstreamdatasize)\
[XSpeechSynthesizer](/reference/system/xspeechsynthesizer/xspeechsynthesizer_members)


## Related topics

- [XSpeechSynthesizerGetStreamDataSize](/zh-CN/reference/system/xspeechsynthesizer/functions/xspeechsynthesizergetstreamdatasize.md)
- [XSpeechSynthesizer](/zh-CN/reference/system/xspeechsynthesizer/xspeechsynthesizer_members.md)
- [文本转语音](/zh-CN/build/console-features/text-to-speech/text-to-speech.md)
- [XSpeechSynthesizerCreate](/zh-CN/reference/system/xspeechsynthesizer/functions/xspeechsynthesizercreate.md)
- [XSpeechSynthesizerCreateStreamFromSsml](/zh-CN/reference/system/xspeechsynthesizer/functions/xspeechsynthesizercreatestreamfromssml.md)
