Skip to main content
This class encapsulates a request for text-to-speech synthesis, containing either text content or a data stream of text, along with an optional voice configuration that can override the default voice settings.

Implements

  • TTSRequestInterface

Constructor

new TTSRequest(
    request: TTSRequestInterface
): TTSRequest
Creates a new TTSRequest instance.

Parameters

request (TTSRequestInterface) The TTS request to wrap.

Returns

TTSRequest Overrides: AbstractApiDataType.constructor

Properties

contentType

readonly contentType: TTSContentType
The type of content to synthesize. Implementation of: TTSRequestInterface.contentType

stream (optional)

readonly stream?: TextStream
The data stream of text to synthesize. Implementation of: TTSRequestInterface.stream

text (optional)

readonly text?: string
The text content to synthesize. Implementation of: TTSRequestInterface.text

voice (optional)

readonly voice?: VoiceInterface
The voice configuration to use for synthesis. Implementation of: TTSRequestInterface.voice

Methods

getText

getText(): string
Gets the text content if available.

Returns

string - The text content or undefined

getVoice

getVoice(): VoiceInterface
Gets the voice configuration if available.

Returns

VoiceInterface - The voice configuration or undefined

hasStreamContent

hasStreamContent(): boolean
Checks if the request has stream content.

Returns

boolean - True if the request contains stream content

hasTextContent

hasTextContent(): boolean
Checks if the request has text content.

Returns

boolean - True if the request contains text content

withStream

Static
static withStream(
    stream: any,
    voice?: VoiceInterface
): TTSRequest
Creates a TTSRequest with stream content.

Parameters

stream (any) The stream content to synthesize voice (VoiceInterface) (optional) Optional voice configuration

Returns

TTSRequest - A new TTSRequest instance

withText

Static
static withText(
    text: string,
    voice?: VoiceInterface
): TTSRequest
Creates a TTSRequest with text content.

Parameters

text (string) The text content to synthesize voice (VoiceInterface) (optional) Optional voice configuration

Returns

TTSRequest - A new TTSRequest instance