From 474c92e722ce77aee2060cd08629b9afb008d81b Mon Sep 17 00:00:00 2001 From: Abhinay Krishna Date: Tue, 4 Aug 2026 16:05:56 -0400 Subject: [PATCH] mtmd: correcting duplicate empty audio chunks for short inputs (#26536) * correcting duplicate empty audio chunks for short inputs * tests.sh code restored --- tools/mtmd/mtmd-audio.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/mtmd/mtmd-audio.cpp b/tools/mtmd/mtmd-audio.cpp index 7fbc18ea93..ca4b64efa4 100644 --- a/tools/mtmd/mtmd-audio.cpp +++ b/tools/mtmd/mtmd-audio.cpp @@ -556,10 +556,8 @@ bool mtmd_audio_preprocessor_whisper::preprocess(const float * s } std::vector smpl; - // if input is too short, pad with zeros - // this is to avoid potential issues with stage1/2 padding in log_mel_spectrogram - // TODO: maybe handle this better - size_t min_samples = (size_t) hparams.audio_sample_rate * (hparams.audio_chunk_len + 1); // +1 second margin + // reflection padding needs one sample plus half an FFT window + size_t min_samples = (size_t) hparams.audio_n_fft / 2 + 1; if (n_samples < min_samples) { smpl.resize(min_samples, 0.0f); std::memcpy(smpl.data(), samples, n_samples * sizeof(float));