Freigeben über


XSpeechSynthesizerCreateStreamFromText

Creates a speech synthesis stream from the specified plain text.

Syntax

HRESULT XSpeechSynthesizerCreateStreamFromText(  
         XSpeechSynthesizerHandle speechSynthesizer,  
         const char* text,  
         XSpeechSynthesizerStreamHandle* speechSynthesisStream  
)  

Parameters

speechSynthesizer   _In_
Type: XSpeechSynthesizerHandle

The speech synthesizer to use.

text   _In_z_
Type: char*

The plain text from which to generate speech.

speechSynthesisStream   _Out_
Type: XSpeechSynthesizerStreamHandle*

A speech synthesis stream that represents the speech generated from the plain text specified in text.

Return value

Type: HRESULT

Returns S_OK if successful; otherwise, returns an error code. For a list of error codes, see Error Codes. If the function fails because the speech synthesizer stream is larger than the maximum data size, the return value is set to E_BOUNDS.

Remarks

Note

This function isn't safe to call on a time-sensitive thread. For more information, see Time-sensitive threads.

  • Use this function to synthesize speech from plain text and to generate audio data in the WAVE container (audio/wav MIME type) format. After using this function to create a speech synthesizer stream and to synthesize speech from plain text, use the XSpeechSynthesizerGetStreamDataSize and XSpeechSynthesizerGetStreamData functions to retrieve the audio data from the speech synthesizer stream. Use the XSpeechSynthesizerCloseStreamHandle function to close the speech synthesizer stream after you've retrieved the audio data.

  • The maximum data size of a speech synthesizer stream is 0xffffffff bytes: four gigabytes minus one byte. An error occurs if you attempt to create a speech synthesizer stream larger than the maximum data size.

  • To prevent memory leaks, call the XSpeechSynthesizerCloseStreamHandle function to close a speech synthesizer stream handle after you've completed all operations that are using the handle. All outstanding asynchronous operations must be completed before this function is called.

  • For an example that demonstrates how to use the XSpeechSynthesizerCreateStreamFromText function, see XSpeechSynthesizerCreate.

Requirements

Header: XSpeechSynthesizer.h

Library: xgameruntime.lib

Supported platforms: Windows, Xbox One family consoles and Xbox Series consoles

See also

XAccessibility
XSpeechSynthesizerCloseStreamHandle
XSpeechSynthesizer