/** * A cross-environment audio-decoding {@link @nhtio/adk/batteries/media/contracts!MediaEngine} * backed by the `audio-decode` package (pure JS/WASM codecs — no ffmpeg, no native bindings; * works in Node and browsers). * * @module @nhtio/adk/batteries/media/engines/audio_decode * * @remarks * Declares two convert capabilities: audio containers to the virtual `pcm` token (mp3 / * m4a-aac / ogg-vorbis / opus / flac / wav), downmixed to mono; and a generation edge — * `EMPTY_MIME` → wav. Audio bytes are just bytes in a documented envelope: the generated * seed is a canonical 44-byte RIFF/WAVE header plus one second of 16-bit mono silence at * 44100 Hz, written by a dependency-free helper (generation never loads the decode peer). * The PCM output reports the SOURCE sample rate in `meta.sampleRate` — the pipeline's * transcribe step resamples to the 16 kHz transcription engines expect. For exotic * containers, compose an ffmpeg-backed engine instead; the capability declaration is the * seam. * * `audio-decode` is an optional peer dependency, lazily imported on first actual use. */ import type { MediaEngine } from "../contracts"; /** * The decoded shapes audio-decode resolves to. Some codecs return an AudioBuffer-compatible * object (`numberOfChannels` + `getChannelData`); others (e.g. the wav path in Node) return a * plain `{ channelData: Float32Array[], sampleRate }` record. The engine normalizes both. */ export interface AudioBufferLike { /** Channel count when the AudioBuffer-compatible shape is returned. */ numberOfChannels?: number; /** Sample rate of the decoded audio, in Hz. Present on both shapes. */ sampleRate: number; /** Per-channel sample accessor on the AudioBuffer-compatible shape. */ getChannelData?(channel: number): Float32Array; /** Raw per-channel sample arrays on the plain-record shape. */ channelData?: Float32Array[]; } /** The decode function shape the `audio-decode` package exports. */ export type AudioDecodeFn = (bytes: Uint8Array | ArrayBuffer) => Promise; /** Options for {@link audioDecodeEngine}. */ export interface AudioDecodeEngineOptions { /** Override the module resolution. Default: `import('audio-decode')`. */ audioDecode?: () => AudioDecodeFn | { default: AudioDecodeFn; } | Promise; } /** * Construct the audio-decode-backed engine. * * @param options - Optional module resolver override. * @returns The engine. */ export declare const audioDecodeEngine: (options?: AudioDecodeEngineOptions) => MediaEngine;