common : fix server /inference fails to decode in-memory audio (regression) (#3818)

* common: add memory buffer overload of read_audio_data

whisper-server /inference without --convert passed the uploaded file
bytes to read_audio_data as a filename, so ma_decoder_init_file tried
to open a path starting with "RIFF" and failed. every request returned
HTTP 400 "Invalid request" on builds without WHISPER_FFMPEG, which is
the default.

factor the PCM extraction into a shared helper and add an overload that
decodes straight from a memory buffer via ma_decoder_init_memory, which
the function already used for the stdin path. server now calls it with
the upload content. the filename overload behavior is unchanged.
This commit is contained in:
Pascal
2026-05-22 08:27:35 +02:00
committed by GitHub
parent 8443cf05e3
commit 0ccd896f5b
3 changed files with 57 additions and 33 deletions
+8
View File
@@ -14,6 +14,14 @@ bool read_audio_data(
std::vector<std::vector<float>> & pcmf32s,
bool stereo);
// decode audio bytes already held in memory (uploaded file, network buffer)
bool read_audio_data(
const char * buffer,
size_t buffer_size,
std::vector<float> & pcmf32,
std::vector<std::vector<float>> & pcmf32s,
bool stereo);
// convert timestamp to string, 6000 -> 01:00.000
std::string to_timestamp(int64_t t, bool comma = false);