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

# XSpeechSynthesizerCreateStreamFromText

> XSpeechSynthesizerCreateStreamFromText

# XSpeechSynthesizerCreateStreamFromText

指定されたプレーン テキストから音声合成ストリームを作成します。

## Syntax

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

### Parameters

*speechSynthesizer*   \_In\_\
型: XSpeechSynthesizerHandle

使用する音声合成器。

*text*   \_In\_z\_\
型: char\*

音声を生成するために使用するプレーン テキスト。

*speechSynthesisStream*   \_Out\_\
型: XSpeechSynthesizerStreamHandle\*

*text* で指定されたプレーン テキストから生成された音声を表す音声合成ストリーム。

### Return value

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

成功した場合は **S\_OK** を返します。そうでない場合はエラー コードを返します。エラー コードの一覧については、[エラー コード](/reference/errorcodes) を参照してください。音声合成器ストリームが最大データ サイズより大きいために関数が失敗した場合、戻り値は **E\_BOUNDS** に設定されます。

## Remarks

<Note>この関数はタイム センシティブ スレッドで呼び出すのは安全ではありません。詳細については、[タイム センシティブ スレッド](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads) を参照してください。</Note>

* この関数を使用して、プレーン テキストから音声を合成し、WAVE コンテナー (`audio/wav` MIME タイプ) 形式でオーディオ データを生成します。この関数を使用して音声合成器ストリームを作成し、プレーン テキストから音声を合成した後、[XSpeechSynthesizerGetStreamDataSize](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizergetstreamdatasize) および [XSpeechSynthesizerGetStreamData](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizergetstreamdata) 関数を使用して、音声合成器ストリームからオーディオ データを取得します。オーディオ データを取得した後、[XSpeechSynthesizerCloseStreamHandle](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizerclosestreamhandle) 関数を使用して音声合成器ストリームを閉じます。

* 音声合成器ストリームの最大データ サイズは 0xffffffff バイト、つまり 4 ギガバイトから 1 バイトを引いたサイズです。最大データ サイズより大きい音声合成器ストリームを作成しようとするとエラーが発生します。

* メモリ リークを防ぐため、ハンドルを使用するすべての操作が完了した後、[XSpeechSynthesizerCloseStreamHandle](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizerclosestreamhandle) 関数を呼び出して音声合成器ストリーム ハンドルを閉じてください。この関数を呼び出す前に、未完了の非同期操作をすべて完了させておく必要があります。

* **XSpeechSynthesizerCreateStreamFromText** 関数の使用方法を示す例については、[XSpeechSynthesizerCreate](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizercreate) を参照してください。

## Requirements

**ヘッダー:** XSpeechSynthesizer.h

**ライブラリ:** xgameruntime.lib

**サポートされているプラットフォーム:** Windows、XBOX One ファミリー本体および XBOX Series 本体

## Conceptual documentation

* [テキスト読み上げ](/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)

## See also

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


## Related topics

- [XSpeechSynthesizerGetStreamDataSize](/ja-jp/reference/system/xspeechsynthesizer/functions/xspeechsynthesizergetstreamdatasize.md)
- [XSpeechSynthesizerVoiceInformation](/ja-jp/reference/system/xspeechsynthesizer/structs/xspeechsynthesizervoiceinformation.md)
- [XSpeechSynthesizerSetCustomVoice](/ja-jp/reference/system/xspeechsynthesizer/functions/xspeechsynthesizersetcustomvoice.md)
- [XSpeechSynthesizerSetDefaultVoice](/ja-jp/reference/system/xspeechsynthesizer/functions/xspeechsynthesizersetdefaultvoice.md)
- [テキスト読み上げ](/ja-jp/build/console-features/text-to-speech/text-to-speech.md)
