AudioChunk
A chunk of audio data flowing through the pipeline.
Defined in: src/core/types/audio.ts:307
A chunk of audio data flowing through the pipeline.
Remarks
Audio chunks are the fundamental unit of streaming audio in the SDK. They are emitted by TTS providers and consumed by the audio player. Each chunk contains raw audio bytes along with optional metadata and ordering information.
Example
// Receiving audio chunks from a TTS provider
ttsProvider.onAudio((chunk: AudioChunk) => {
console.log(`Received ${chunk.data.byteLength} bytes, seq=${chunk.sequence}`);
audioPlayer.enqueue(chunk);
});
See
- AudioMetadata for the format description of audio data
- TTSAudioEvent for the event that wraps this type
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
data | ArrayBuffer | Raw audio data as an ArrayBuffer. | src/core/types/audio.ts:309 |
metadata? | AudioMetadata | Format metadata for this specific chunk. Remarks When present, overrides the global metadata from the provider. Typically omitted when the format is consistent across all chunks. See AudioMetadata | src/core/types/audio.ts:320 |
sequence? | number | Sequence number for ordering chunks. Remarks Ensures correct playback order when chunks arrive out of sequence, which can occur with WebSocket-based providers under network jitter. | src/core/types/audio.ts:337 |
timestamp | number | Unix timestamp (in milliseconds) of when this chunk was created. Remarks Used for latency tracking and debugging the audio pipeline. | src/core/types/audio.ts:328 |