Skip to main content

Class: VoicePlayout

Decides when each decoded frame of one speaker starts playing.

Frames arrive in bursts (the network, a busy main thread) and must leave as an unbroken stream, so each one is queued a short delay ahead of the clock and the next starts exactly where it ends. When the queue runs dry in the middle of an utterance the delay was too short for this connection: it grows, and eases back once things have been calm. When a burst puts the queue too far ahead, frames are dropped until it is back, so a conversation never drifts seconds behind.

Constructors​

constructor​

• new VoicePlayout(options?): VoicePlayout

Parameters​

NameType
optionsPartial<VoicePlayoutOptions>

Returns​

VoicePlayout

Properties​

droppedFrames​

• droppedFrames: number = 0

Frames dropped to catch up with the clock.


underruns​

• underruns: number = 0

How many times the queue ran dry mid-utterance.

Accessors​

currentDelay​

• get currentDelay(): number

The delay new utterances currently start with, in seconds.

Returns​

number

Methods​

reset​

▸ reset(): void

Forget the queue: the next frame starts a new utterance.

Returns​

void


schedule​

▸ schedule(now, duration, lostBefore?): number

When a frame duration seconds long that was decoded at clock time now should start, or null to drop it. lostBefore frames were lost ahead of it and leave that much silence.

Parameters​

NameTypeDefault value
nownumberundefined
durationnumberundefined
lostBeforenumber0

Returns​

number