Audio Loader#
-
struct AudioPCM#
Decoded PCM container.
Always mono (multi-channel input is mixdown-averaged), float32 in the range [-1, 1]. Sample rate is the value passed to the decoder (miniaudio resamples to this rate on read).
- bool trt_edgellm::rt::audio::loadAudioFile(
- std::filesystem::path const &path,
- int32_t targetSampleRate,
- AudioPCM &out,
Load raw audio bytes (wav / mp3 / flac) into mono float32 PCM resampled to
targetSampleRate. Internally decodes the container ! via vendored miniaudio (auto-detects format from magic bytes) and ! mixes multi-channel to mono. ! !http(s)://URLs are not handled here — bytes are expected to be a ! complete container blob already. ! !
! Load a local audio file (wav / mp3 / flac) into mono float32 PCM ! resampled to
targetSampleRate. ! ! Used by the CLI / offline path. The HTTP server uses loadAudioBytes. ! !- Parameters:
bytes – Pointer to the encoded audio bytes. !
size – Length of
bytesin bytes. !targetSampleRate – Output sample rate (e.g. 16000 for Whisper). !
out – Populated on success; on failure
outis left in an ! unspecified state (do not consume its contents). !path – Local filesystem path. !
targetSampleRate – Output sample rate. !
out – Populated on success; on failure
outis left in an unspecified state (do not consume its contents).
- Returns:
true on success, false on decode failure. bool loadAudioBytes(uint8_t const* bytes, size_t size, int32_t targetSampleRate, AudioPCM& out);
- Returns:
true on success, false on open/decode failure.