Skip to content

TurnTakingController

Manages pause/resume of audio capture during TTS playback.

Defined in: src/core/collaborators/TurnTakingController.ts:45

Manages pause/resume of audio capture during TTS playback.

Remarks

Encapsulates the logic for:

  • Deciding whether to pause capture based on turn-taking configuration
  • Executing pause: stop queue draining, pause input, disconnect STT
  • Executing resume: resume input, reconnect STT, re-inject cached header, restart queue draining

Constructors

Constructor

new TurnTakingController(config, logger): TurnTakingController;

Defined in: src/core/collaborators/TurnTakingController.ts:48

Parameters

ParameterType
configTurnTakingConfig | undefined
loggerLogger

Returns

TurnTakingController

Methods

pauseCapture()

pauseCapture(
   stt, 
   input, 
   inputQueue, 
isMultiRoleInput): Promise<void>;

Defined in: src/core/collaborators/TurnTakingController.ts:75

Pause audio capture: stop queue draining, pause input, disconnect STT.

Parameters

ParameterTypeDescription
sttSTTProviderThe STT provider.
inputAudioInputProviderThe audio input provider.
inputQueueAudioBufferQueueThe input audio buffer queue.
isMultiRoleInputbooleanWhether input and STT are the same provider instance.

Returns

Promise<void>


recoverCapture()

recoverCapture(
   stt, 
   input, 
   inputQueue, 
   headerCache, 
   isMultiRoleInput, 
captureWasPaused): Promise<void>;

Defined in: src/core/collaborators/TurnTakingController.ts:138

Attempt to recover STT capture after an error.

Parameters

ParameterTypeDescription
sttSTTProviderThe STT provider.
inputAudioInputProviderThe audio input provider.
inputQueueAudioBufferQueueThe input audio buffer queue.
headerCacheAudioHeaderCacheThe audio header cache.
isMultiRoleInputbooleanWhether input and STT are the same provider instance.
captureWasPausedbooleanWhether capture was in paused state (needs resume, not restart).

Returns

Promise<void>

Remarks

Re-connects STT and restarts queue draining, starting from a clean state. Used in error recovery paths within processTTS and finalizeLiveTTS.


resumeCapture()

resumeCapture(
   stt, 
   input, 
   inputQueue, 
   headerCache, 
isMultiRoleInput): Promise<void>;

Defined in: src/core/collaborators/TurnTakingController.ts:100

Resume audio capture: resume input, reconnect STT, re-inject cached header, restart queue draining.

Parameters

ParameterTypeDescription
sttSTTProviderThe STT provider.
inputAudioInputProviderThe audio input provider.
inputQueueAudioBufferQueueThe input audio buffer queue.
headerCacheAudioHeaderCacheThe audio header cache for WebSocket reconnection.
isMultiRoleInputbooleanWhether input and STT are the same provider instance.

Returns

Promise<void>


shouldPause()

shouldPause(stt, tts): boolean;

Defined in: src/core/collaborators/TurnTakingController.ts:63

Determine whether audio capture should be paused during playback for the given provider combination.

Parameters

ParameterTypeDescription
sttSTTProviderThe STT provider instance.
ttsTTSProviderThe TTS provider instance.

Returns

boolean

true if capture should be paused, false for full-duplex.

© 2026 CompositeVoice. All rights reserved.

Font size
Contrast
Motion
Transparency