AudioMetadata
Metadata describing the format of audio data received from a provider.
Defined in: src/core/types/audio.ts:254
Metadata describing the format of audio data received from a provider.
Remarks
Audio metadata is emitted by TTS providers (via onMetadata) to inform the audio player how to decode and play the incoming audio chunks. This is especially important for WebSocket-based TTS providers where the audio format may not be known until the connection is established.
Example
// Listening for audio metadata from a TTS provider
ttsProvider.onMetadata((metadata) => {
console.log(`Audio: ${metadata.sampleRate}Hz, ${metadata.encoding}, ${metadata.channels}ch`);
});
See
- AudioChunk for the audio data that accompanies this metadata
- AudioEncoding for supported encoding values
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
bitDepth? | number | Bit depth of each audio sample. Remarks Common values are 16 (for linear16) and 24 (for high-fidelity audio). May be undefined for compressed formats like opus or mp3. | src/core/types/audio.ts:275 |
channels | number | Number of audio channels (1 = mono, 2 = stereo). | src/core/types/audio.ts:266 |
encoding | AudioEncoding | Encoding format of the audio samples. See AudioEncoding | src/core/types/audio.ts:263 |
mimeType? | string | MIME type of the audio data, if available. Remarks Examples: 'audio/pcm', 'audio/mpeg', 'audio/opus'. Useful for creating Blob objects from raw audio data. | src/core/types/audio.ts:284 |
sampleRate | number | Sample rate of the audio in Hz (e.g., 16000, 24000, 44100). | src/core/types/audio.ts:256 |