SpeechSynthesizer class

Defines the class SpeechSynthesizer for text to speech. Added in version 1.11.0

Constructors

SpeechSynthesizer(SpeechConfig, AudioConfig)

SpeechSynthesizer constructor.

Properties

authorizationToken

Gets the authorization token used to communicate with the service. Gets/Sets the authorization token used to communicate with the service.

autoDetectSourceLanguage

Indicates if auto detect source language is enabled

internalData
properties

The collection of properties and their values defined for this SpeechSynthesizer.

SynthesisCanceled

Defines event handler for synthesis cancelled events.

synthesisCompleted

Defines event handler for synthesis completed events.

synthesisStarted

Defines event handler for synthesis start events.

synthesizing

Defines event handler for synthesizing events.

wordBoundary

Defines event handler for word boundary events

Methods

buildSsml(string)
close()

Dispose of associated resources.

dispose(boolean)

This method performs cleanup of resources. The Boolean parameter disposing indicates whether the method is called from Dispose (if disposing is true) or from the finalizer (if disposing is false). Derived classes should override this method to dispose resource if needed.

FromConfig(SpeechConfig, AutoDetectSourceLanguageConfig, AudioConfig)

SpeechSynthesizer constructor.

speakSsmlAsync(string, (e: SpeechSynthesisResult) => void, (e: string) => void, AudioOutputStream | PushAudioOutputStreamCallback | PathLike)

Executes speech synthesis on SSML. The task returns the synthesis result.

speakTextAsync(string, (e: SpeechSynthesisResult) => void, (e: string) => void, AudioOutputStream | PushAudioOutputStreamCallback | PathLike)

Executes speech synthesis on plain text. The task returns the synthesis result.

Constructor Details

SpeechSynthesizer(SpeechConfig, AudioConfig)

SpeechSynthesizer constructor.

new SpeechSynthesizer(speechConfig: SpeechConfig, audioConfig?: AudioConfig)

Parameters

speechConfig
SpeechConfig

An set of initial properties for this synthesizer

audioConfig
AudioConfig

An optional audio configuration associated with the synthesizer

Property Details

authorizationToken

Gets the authorization token used to communicate with the service. Gets/Sets the authorization token used to communicate with the service.

string authorizationToken

Property Value

string

Authorization token.

autoDetectSourceLanguage

Indicates if auto detect source language is enabled

boolean autoDetectSourceLanguage

Property Value

boolean

if auto detect source language is enabled

internalData

object internalData

Property Value

object

properties

The collection of properties and their values defined for this SpeechSynthesizer.

PropertyCollection properties

Property Value

The collection of properties and their values defined for this SpeechSynthesizer.

SynthesisCanceled

Defines event handler for synthesis cancelled events.

public SynthesisCanceled: (sender: SpeechSynthesizer, event: SpeechSynthesisEventArgs) => void

Property Value

(sender: SpeechSynthesizer, event: SpeechSynthesisEventArgs) => void

synthesisCompleted

Defines event handler for synthesis completed events.

public synthesisCompleted: (sender: SpeechSynthesizer, event: SpeechSynthesisEventArgs) => void

Property Value

(sender: SpeechSynthesizer, event: SpeechSynthesisEventArgs) => void

synthesisStarted

Defines event handler for synthesis start events.

public synthesisStarted: (sender: SpeechSynthesizer, event: SpeechSynthesisEventArgs) => void

Property Value

(sender: SpeechSynthesizer, event: SpeechSynthesisEventArgs) => void

synthesizing

Defines event handler for synthesizing events.

public synthesizing: (sender: SpeechSynthesizer, event: SpeechSynthesisEventArgs) => void

Property Value

(sender: SpeechSynthesizer, event: SpeechSynthesisEventArgs) => void

wordBoundary

Defines event handler for word boundary events

public wordBoundary: (sender: SpeechSynthesizer, event: SpeechSynthesisWordBoundaryEventArgs) => void

Property Value

(sender: SpeechSynthesizer, event: SpeechSynthesisWordBoundaryEventArgs) => void

Method Details

buildSsml(string)

function buildSsml(text: string)

Parameters

text

string

Returns

string

close()

Dispose of associated resources.

function close()

dispose(boolean)

This method performs cleanup of resources. The Boolean parameter disposing indicates whether the method is called from Dispose (if disposing is true) or from the finalizer (if disposing is false). Derived classes should override this method to dispose resource if needed.

function dispose(disposing: boolean)

Parameters

disposing

boolean

Flag to request disposal.

FromConfig(SpeechConfig, AutoDetectSourceLanguageConfig, AudioConfig)

SpeechSynthesizer constructor.

static function FromConfig(speechConfig: SpeechConfig, autoDetectSourceLanguageConfig: AutoDetectSourceLanguageConfig, audioConfig?: AudioConfig)

Parameters

speechConfig
SpeechConfig

an set of initial properties for this synthesizer

autoDetectSourceLanguageConfig
AutoDetectSourceLanguageConfig

An source language detection configuration associated with the synthesizer

audioConfig
AudioConfig

An optional audio configuration associated with the synthesizer

Returns

speakSsmlAsync(string, (e: SpeechSynthesisResult) => void, (e: string) => void, AudioOutputStream | PushAudioOutputStreamCallback | PathLike)

Executes speech synthesis on SSML. The task returns the synthesis result.

function speakSsmlAsync(ssml: string, cb?: (e: SpeechSynthesisResult) => void, err?: (e: string) => void, stream?: AudioOutputStream | PushAudioOutputStreamCallback | PathLike)

Parameters

ssml

string

SSML to be synthesized.

cb

(e: SpeechSynthesisResult) => void

Callback that received the SpeechSynthesisResult.

err

(e: string) => void

Callback invoked in case of an error.

stream

AudioOutputStream | PushAudioOutputStreamCallback | PathLike

AudioOutputStream to receive the synthesized audio.

speakTextAsync(string, (e: SpeechSynthesisResult) => void, (e: string) => void, AudioOutputStream | PushAudioOutputStreamCallback | PathLike)

Executes speech synthesis on plain text. The task returns the synthesis result.

function speakTextAsync(text: string, cb?: (e: SpeechSynthesisResult) => void, err?: (e: string) => void, stream?: AudioOutputStream | PushAudioOutputStreamCallback | PathLike)

Parameters

text

string

Text to be synthesized.

cb

(e: SpeechSynthesisResult) => void

Callback that received the SpeechSynthesisResult.

err

(e: string) => void

Callback invoked in case of an error.

stream

AudioOutputStream | PushAudioOutputStreamCallback | PathLike

AudioOutputStream to receive the synthesized audio.