From f59f0859fbb64180f52c44cc9e3b8741e6dae2a3 Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Sat, 28 Sep 2024 09:16:37 -0700 Subject: [PATCH] Fix audio channel mixing in new slurp code --- whisper.cpp/slurp.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/whisper.cpp/slurp.cpp b/whisper.cpp/slurp.cpp index b40b05f963..1bac217838 100644 --- a/whisper.cpp/slurp.cpp +++ b/whisper.cpp/slurp.cpp @@ -4,6 +4,7 @@ #include "slurp.h" #include "miniaudio.h" #include "llamafile/log.h" +#include static int get_audio_file_channels(const char *fname) { ma_decoder decoder; @@ -96,7 +97,7 @@ bool slurp_audio_file(const char *fname, for (int i = 0; i < got; ++i) { float left = frames[i*2+0]; float right = frames[i*2+1]; - pcmf32.push_back(left + right); + pcmf32.push_back(sqrtf((left*left + right*right) / 2)); pcmf32s[0].push_back(left); pcmf32s[1].push_back(right); }