Skip to content
1 min read · 252 words

@nhtio/adk/batteries/media/engines/audio_decode

A cross-environment audio-decoding @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).

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.

Interfaces

InterfaceDescription
AudioBufferLikeThe 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.
AudioDecodeEngineOptionsOptions for audioDecodeEngine.

Type Aliases

Type AliasDescription
AudioDecodeFnThe decode function shape the audio-decode package exports.

Functions

FunctionDescription
audioDecodeEngineConstruct the audio-decode-backed engine.