Class: core/Speech

core/Speech(speaker, text, speechmarksopt, audioConfig)

new core/Speech(speaker, text, speechmarksopt, audioConfig)

Parameters:
Name Type Attributes Default Description
speaker TextToSpeech

The owner of the Speech that will emit speechmark
messages.

text string

The text of the speech.

speechmarks Array.<Object> <optional>
[]

An array of speechmark objects representing
the text and timing of the speech.

audioConfig Object

Object containing audio and url.

Properties
Name Type Description
audio external:Audio

Playable audio object.

Extends

Members

(readonly) audio :external:Audio

Gets the playable audio for the speech.

Type:

(readonly) playing :boolean

Gets the playback state of the audio.

Type:
  • boolean
Overrides:

speechmarkOffset :number

Gets and sets the number of seconds to offset speechmark emission.

Type:
  • number
Overrides:

(readonly) speechmarks :Array.<Object>

Gets a shallow copy of the speechmarks array for the speech.

Type:
  • Array.<Object>
Overrides:

(readonly) text :string

Gets the text of the speech.

Type:
  • string
Overrides:

volume :number

Gets the audio volume for the speech.

Type:
  • number

volume

Sets the audio volume for the speech.

Methods

cancel()

Cancels playback of the speech at the current time. Cancel the speech promise.

Overrides:

pause(currentTime)

Pause the speech at the current time.

Parameters:
Name Type Description
currentTime number

Current global time when pause was called.

Overrides:

play(currentTime, onFinishopt, onErroropt, onInterruptopt) → {Deferred}

Play the speech from the beginning.

Parameters:
Name Type Attributes Description
currentTime number

Current global time when play was called.

onFinish function <optional>

Optional function to execute once the speech
promise resolves.

onError function <optional>

Optional function to execute if the speech
encounters and error during playback.

onInterrupt function <optional>

Optional function to execute if the speech
is canceled.

Overrides:
Returns:

Resolves once the speech reaches the end of playback.

Type
Deferred

resume(currentTime, onFinishopt, onErroropt, onInterruptopt) → {Deferred}

Resume the speech at the current time.

Parameters:
Name Type Attributes Description
currentTime number

Current global time when resume was called.

onFinish function <optional>

Optional function to execute once the speech
promise resolves.

onError function <optional>

Optional function to execute if the speech
encounters and error during playback.

onInterrupt function <optional>

Optional function to execute if the speech
is canceled.

Overrides:
Returns:

Resolves once the speech reaches the end of playback.

Type
Deferred

stop()

Stop the speech and reset time to the beginning. Resolve the speech promise.

Overrides:

update(currentTime)

Emit speechmark messages as they are encountered in sync with audio.

Parameters:
Name Type Description
currentTime number

Current global time when update was called.

Overrides: