Class: AbstractSpeech

(abstract) AbstractSpeech(speaker, text, speechmarksopt)

Class that can play back audio generated by AWS Polly and synchronized emit
speechmark messages.

Constructor

(abstract) new AbstractSpeech(speaker, text, speechmarksopt)

Parameters:
Name Type Attributes Default Description
speaker core/TextToSpeechFeature

The feature that owns the Speech and
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.

Members

(readonly) playing :boolean

Gets the playback state of the audio.

Type:
  • boolean

speechmarkOffset :number

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

Type:
  • number

(readonly) speechmarks :Array.<Object>

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

Type:
  • Array.<Object>

(readonly) text :string

Gets the text of the speech.

Type:
  • string

Methods

cancel()

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

pause(currentTime)

Pause the speech at the current time.

Parameters:
Name Type Description
currentTime number

Current global time when pause was called.

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.

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.

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.

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.