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

# XSpeechSynthesizerCreateStreamFromSsml

> XSpeechSynthesizerCreateStreamFromSsml

# XSpeechSynthesizerCreateStreamFromSsml

從指定的 SSML 建立語音合成資料流。

## 語法

```cpp theme={null}
HRESULT XSpeechSynthesizerCreateStreamFromSsml(  
         XSpeechSynthesizerHandle speechSynthesizer,  
         const char* ssml,  
         XSpeechSynthesizerStreamHandle* speechSynthesisStream  
)  
```

### 參數

*speechSynthesizer*   \_In\_\
類型：XSpeechSynthesizerHandle

要使用的語音合成器。

*ssml*   \_In\_z\_\
類型：char\*

要朗讀的 SSML 修飾文字。如需 SSML 標記的詳細資料，請參閱 [W3C 建議](https://go.microsoft.com/fwlink/p/?LinkID=201763)。

<Note>此 API 要求呼叫者使用 SSML 1.0 版。</Note>

*speechSynthesisStream*   \_Out\_\
類型：XSpeechSynthesizerStreamHandle\*

語音合成資料流，代表從 *text* 中指定之純文字所產生的語音。

### 傳回值

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

如果成功，則傳回 **S\_OK**；否則傳回錯誤碼。如需錯誤碼的清單，請參閱[錯誤碼](/zh-TW/reference/errorcodes)。如果函式因語音合成器資料流大於資料大小上限而失敗，傳回值會設為 **E\_BOUNDS**。

## 備註

<Note>在時間敏感執行緒上呼叫此函式並不安全。如需詳細資訊，請參閱[時間敏感執行緒](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)。</Note>

* 使用此函式從純文字合成語音，並產生 WAVE 容器 (`audio/wav` MIME 類型) 格式的音訊資料。使用此函式建立語音合成器資料流並從純文字合成語音之後，請使用 [XSpeechSynthesizerGetStreamDataSize](/zh-TW/reference/system/xspeechsynthesizer/functions/xspeechsynthesizergetstreamdatasize) 和 [XSpeechSynthesizerGetStreamData](/zh-TW/reference/system/xspeechsynthesizer/functions/xspeechsynthesizergetstreamdata) 函式，從語音合成器資料流擷取音訊資料。擷取音訊資料之後，請使用 [XSpeechSynthesizerCloseStreamHandle](/zh-TW/reference/system/xspeechsynthesizer/functions/xspeechsynthesizerclosestreamhandle) 函式關閉語音合成器資料流。

* 語音合成器資料流的資料大小上限為 0xffffffff 位元組：4 GB 減去 1 位元組。如果您嘗試建立大於資料大小上限的語音合成器資料流，就會發生錯誤。

* 若要防止記憶體流失，請在完成所有使用語音合成器資料流控制代碼的作業之後，呼叫 [XSpeechSynthesizerCloseStreamHandle](/zh-TW/reference/system/xspeechsynthesizer/functions/xspeechsynthesizerclosestreamhandle) 函式來關閉該控制代碼。在呼叫此函式之前，必須完成所有未完成的非同步作業。

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

## 需求

**標頭：** XSpeechSynthesizer.h

**程式庫：** xgameruntime.lib

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

## 另請參閱

[XAccessibility](/zh-TW/reference/system/xaccessibility/xaccessibility_members)\
[XSpeechSynthesizerCloseStreamHandle](/zh-TW/reference/system/xspeechsynthesizer/functions/xspeechsynthesizerclosestreamhandle)\
[XSpeechSynthesizer](/zh-TW/reference/system/xspeechsynthesizer/xspeechsynthesizer_members)


## Related topics

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