Class: threejs/TextToSpeechFeature

threejs/TextToSpeechFeature(host, optionsopt)

new threejs/TextToSpeechFeature(host, optionsopt)

Parameters:
Name Type Attributes Description
host app/HostObject

Host object managing the feature.

options Object <optional>

Options that will be sent to Polly for each speech.

Properties
Name Type Attributes Description
listener external:"THREE.AudioListener"

Three audio listener to use with
audio.

attachTo external:"THREE.Object3D" <optional>

Optional object to attach the speech
audio to.

Extends

Members

(readonly) currentSpeech :string

Gets the text of the currently playing speech.

Type:
  • string
Overrides:

(readonly) enabled :boolean

Gets whether or not the audio context is running and speech can be played.

Type:
  • boolean
Overrides:

(readonly) host

Gets the host that manages the feature.

Overrides:

minEndMarkDuration :number

Gets and sets the The minimum amount of time in seconds that the last
speechmark of each type in a speech can have its duration property set to.

Type:
  • number
Overrides:

(readonly) owner

Gets the engine owner object of the host.

Overrides:

speechmarkOffset :number

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

Type:
  • number
Overrides:

volume :number

Gets and sets the volume used for all audio clips played by the speaker.

Type:
  • number
Overrides:

(readonly) volumePending :boolean

Gets whether or not the speaker's volume value is currently being tweened.

Type:
  • boolean
Overrides:

Methods

discard()

Clean up once the feature is no longer in use. Remove the feature namespace
from the host and remove reference to the host.

Overrides:

emit(message, valueopt)

Emit feature messages from the host. Feature messages will be prefixed with
the class name of the feature.

Parameters:
Name Type Attributes Description
message string

The message to emit.

value any <optional>

Optional parameter to pass to listener callbacks.

Overrides:

getEngineUserAgentString()

Overrides:
Returns:

The useragent string for the engine you are using, e.g. 'babylonjs/5.1.0'

getVolume() → {number}

Gets the volume used for all audio clips played by the speaker.

Overrides:
Returns:
Type
number

installApi()

Adds a namespace to the host with the name of the feature to contain properties
and methods from the feature that users of the host need access to.

Overrides:
See:

listenTo(message, callback)

Listen to a feature message from the host object.

Parameters:
Name Type Description
message string

Message to listen for.

callback function

The callback to execute when the message is received.

Overrides:

pause()

If a speech is currently playing, pause it at the current time.

Overrides:

pauseVolume() → {boolean}

Pause interpolation happening on the speaker's volume property.

Overrides:
Returns:
Type
boolean

play(text, configopt) → {Deferred}

Stop any speeches currently playing and play a new speech from the beginning.

Parameters:
Name Type Attributes Description
text string

The text of the new speech to play.

config Object <optional>

Optional parameters for the speech.

Overrides:
Returns:
Type
Deferred

resume(textopt, configopt) → {Deferred}

Stop any speeches currently playing and resume a new speech from the current
time.

Parameters:
Name Type Attributes Description
text string <optional>

The text of the new speech to play. If undefined and
there is a current speech that is paused, the current speech will be resumed.

config Object <optional>

Optional parameters for the speech.

Overrides:
Returns:
Type
Deferred

resumeAudio() → {Deferred}

Try to resume the audio context. This will be automatically executed each time
speech is played or resumed. If using manually, it should be called after a
user interaction occurs.

Overrides:
Returns:
  • Resolves once the audio context has resumed.
Type
Deferred

resumeVolume() → {boolean}

Resume any interpolation happening on the speaker's volume property.

Overrides:
Returns:
Type
boolean

setVolume(volume, secondsopt, easingFnopt) → {Deferred}

Updates the volume used for all audio clips played by the speaker over time.

Parameters:
Name Type Attributes Default Description
volume number

Target volume value.

seconds number <optional>
0

Amount of time it will take to reach the target
volume.

easingFn function <optional>

Easing function used for interpolation.

Overrides:
Returns:
Type
Deferred

stop()

If a speech is currently playing, stop playback and reset time.

Overrides:

stopListening(message, callbackopt)

Stop listening to a message from the host object.

Parameters:
Name Type Attributes Description
message string

Message to stop listening for.

callback function <optional>

Optional callback to remove. If none is defined,
remove all callbacks for the message.

Overrides:

stopListeningByRegexp(regexp, callbackopt)

Stop listening to a message matching the given regular expression from the
host object.

Parameters:
Name Type Attributes Description
regexp Regexp

The regular expression to stop listening for.

callback function <optional>

Optional callback to remove. If none is defined,
remove all callbacks for the message.

Overrides:

stopListeningToAll()

Stop listening to all messages.

Overrides:

update(deltaTime)

Update the currently playing speech.

Parameters:
Name Type Description
deltaTime number

Time since the last update.

Overrides: