Class: core/LipsyncFeature

core/LipsyncFeature(host, visemeOptionsopt, talkingOptionsopt, visemeLeadTimeopt)

Lipsync controls two types of movement: idle animation that should play while
speech is playing and viseme animations corresponding to Polly visemes whose
weights should be turned on and off as they are encountered in the Polly SSML
transcript. Layers owned by this feature will be enabled while speech is playing
and disabled once it stops.

Constructor

new core/LipsyncFeature(host, visemeOptionsopt, talkingOptionsopt, visemeLeadTimeopt)

Parameters:
Name Type Attributes Default Description
host core/HostObject

Host that owns the feature.

visemeOptions Object <optional>

Options for the viseme layers.

Properties
Name Type Attributes Default Description
blendTime number <optional>
0.15

Default amount of time it
will take to manipulate each freeBlend weight on the viseme states.

decayRate Object <optional>
{amount: .5, seconds: .5}

An object
describing the 0-1 factor viseme weight will decay if the viseme duration is
longer than the blendTime and the number of seconds it would take to decay
by that factor.

easingFn number <optional>
Quadratic.InOut

Default easing function
to use when manipulating viseme freeBlend weights.

.layers Array.<Object> <optional>
[]

An array of layer options
objects to register as viseme layers.

talkingOptions Object <optional>

Options for the talking layers.

Properties
Name Type Attributes Default Description
blendTime number <optional>
0.75

Default amount of time to
enable and disable the talking idle layers

easingFn number <optional>
Quadratic.InOut

Default easing
function to use when manipulating weights on the talking idle layers.

layers Array.<Object> <optional>
[]

An array of layer options
objects to register as talking layers.

visemeLeadTime number <optional>
.067

The amount of time to instruct the
TextToSpeechFeature to emit speechmarks before each one's actual timestamp
is reached. This will set the 'speechMarkOffset' variable on the TextToSpeechFeature.

Implements:

Extends

Members

(readonly) host

Gets the host that manages the feature.

Overrides:

(readonly) owner

Gets the engine owner object of the host.

Overrides:

visemeLeadTime :number

Gets and sets the amount of time in seconds to negatively offset speechmark
emission by.

Type:
  • number

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:
Implements:

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:

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:

registerTalkingLayer(layerName, optionsopt)

Start keeping track of an animation layer that contains a looping animation
to be played during speech.

Parameters:
Name Type Attributes Description
layerName string

Name of the layer to keep track of.

options Object <optional>

Options for the layer.

Properties
Name Type Attributes Default Description
animation string <optional>
'stand_talk'

Name of the animation on the
layer that will be played during speech.

blendTime number <optional>
LipsyncFeature.DEFAULT_LAYER_OPTIONS.blendTime

Default amount of time to use when manipulating the layer's weights.

easingFn function <optional>

Default easing function to use when
manipulating the layer's weights.

registerVisemeLayer(layerName, optionsopt, decayRateopt)

Start keeping track of an animation layer that owns a freeBlend animation
with blendWeights corresponding to visemes.

Parameters:
Name Type Attributes Default Description
layerName string

Name of the layer to keep track of.

options Object <optional>

Options for the layer.

Properties
Name Type Attributes Default Description
animation string <optional>
'visemes'

Name of the animation on the
layer that will be played during speech. This animation must be of type
freeBlend.

decayRate Object <optional>
Properties
Name Type Attributes Default Description
amount number <optional>
0.5

The percentage to decrease the viseme's
peak value by over time once the peak value has been reached.

seconds number <optional>
0.5

The amount of time in seconds to
decrease the viseme's weight once it has reached its peak value.

options.blendTime number <optional>
LipsyncFeature.DEFAULT_LAYER_OPTIONS.blendTime

Default amount of time to use when manipulating animation blendWeights.

options.easingFn function <optional>

Default easing function to use when
manipulating animation blendWeights.

options.visemeMap Object <optional>
DefaultVisemeMap

Object containing key/value pairs of
Polly viseme names mapped to objects containing the name of the corresponding
animation blendWeight and any other animation options to use such as viseme
specific blend times and easing functions.

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)

Executes each time the host is updated.

Parameters:
Name Type Description
deltaTime number

Amount of time since the last host update was
called.

Overrides: