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).

Public Members

std::vector<float> samples#
int32_t sampleRate = {16000}#
int32_t numChannels = {1}#
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 bytes in bytes. !

  • targetSampleRate – Output sample rate (e.g. 16000 for Whisper). !

  • out – Populated on success; on failure out is left in an ! unspecified state (do not consume its contents). !

  • path – Local filesystem path. !

  • targetSampleRate – Output sample rate. !

  • out – Populated on success; on failure out is 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.