> ## 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](/zh-TW/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**；否則傳回錯誤碼。如需錯誤碼清單，請參閱[錯誤碼](/zh-TW/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](/zh-TW/reference/system/xspeechsynthesizer/functions/xspeechsynthesizercreatestreamfromtext) 函式所建立之語音合成器資料流的資料緩衝區，擷取合成語音的音訊資料。音訊資料會以 WAVE 容器 (`audio/wav` MIME 類型) 格式傳回。

如需示範如何使用 **XSpeechSynthesizerGetStreamData** 函式的範例，請參閱 [XSpeechSynthesizerCreate](/zh-TW/reference/system/xspeechsynthesizer/functions/xspeechsynthesizercreate)。

## 需求

**標頭：** XSpeechSynthesizer.h

**程式庫：** xgameruntime.lib

**支援的平台：** Windows、XBOX One 系列主機和 XBOX Series 主機

## 概念文件

* [文字轉換語音](/zh-TW/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](/zh-TW/reference/system/xaccessibility/xaccessibility_members)\
[XSpeechSynthesizerGetStreamDataSize](/zh-TW/reference/system/xspeechsynthesizer/functions/xspeechsynthesizergetstreamdatasize)\
[XSpeechSynthesizer](/zh-TW/reference/system/xspeechsynthesizer/xspeechsynthesizer_members)


## Related topics

- [XSpeechSynthesizerGetStreamData](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizergetstreamdata.md)
- [XSpeechSynthesizerGetStreamDataSize](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizergetstreamdatasize.md)
