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

View File

@@ -868,8 +868,7 @@ int main(int argc, char ** argv) {
// remove temp file
std::remove(temp_filename.c_str());
} else {
if (!::read_audio_data(audio_file.content, pcmf32, pcmf32s, params.diarize))
{
if (!::read_audio_data(audio_file.content.data(), audio_file.content.size(), pcmf32, pcmf32s, params.diarize)) {
fprintf(stderr, "error: failed to read audio data\n");
const std::string error_resp = "{\"error\":\"failed to read audio data\"}";
res.status = 400;