TTSBackpressure
A counting semaphore that provides backpressure between the LLM and TTS pipeline stages.
Defined in: src/core/pipeline/TTSBackpressure.ts:38
A counting semaphore that provides backpressure between the LLM and TTS pipeline stages.
See
CompositeVoiceConfig.pipeline for the maxPendingChunks config
Constructors
Constructor
new TTSBackpressure(maxPendingChunks): TTSBackpressure;
Defined in: src/core/pipeline/TTSBackpressure.ts:51
Creates a new backpressure controller.
Parameters
| Parameter | Type | Description |
|---|---|---|
maxPendingChunks | number | Maximum number of unacknowledged chunks before blocking. Must be a positive integer. |
Returns
TTSBackpressure
Accessors
pendingCount
Get Signature
get pendingCount(): number;
Defined in: src/core/pipeline/TTSBackpressure.ts:122
Current number of pending (unacknowledged) chunks.
Returns
number
Methods
acquire()
acquire(): void;
Defined in: src/core/pipeline/TTSBackpressure.ts:59
Increment the pending chunk count.
Returns
void
Remarks
Call this immediately after sending a text chunk to the TTS provider.
release()
release(): void;
Defined in: src/core/pipeline/TTSBackpressure.ts:73
Decrement the pending chunk count and unblock any waiting sender.
Returns
void
Remarks
Call this when the TTS provider acknowledges a chunk (e.g., emits an audio chunk or metadata). If the count drops below the limit and a sender is waiting, the sender is unblocked.
Safe to call even when pending is 0 (no-op).
reset()
reset(): void;
Defined in: src/core/pipeline/TTSBackpressure.ts:110
Reset the backpressure state.
Returns
void
Remarks
Clears the pending count and resolves any waiting sender. Call this when the pipeline is stopped, interrupted (barge-in), or reset.
waitForCapacity()
waitForCapacity(): Promise<void>;
Defined in: src/core/pipeline/TTSBackpressure.ts:94
Wait until there is capacity to send another chunk.
Returns
Promise<void>
A Promise that resolves when it is safe to send the next chunk.
Remarks
If the current pending count is below the limit, resolves immediately. Otherwise, returns a Promise that resolves when release brings the count below the limit.