Commit a46fadb3 for whisper.cpp
commit a46fadb36a9bbaf40021c5135fb3ee34cca6a42b
Author: Lefteris @SomniusX <lefteros@outlook.com>
Date: Mon Oct 19 17:11:07 2026 +0300
whisper : narrow the DTW median filter instead of asserting on short windows (#4096)
When a 30 s window advances only a few frames, the attention passed to
median_filter has fewer audio tokens than the filter's width, and
WHISPER_ASSERT(filter_width < a->ne[2]) aborts the whole program in the
middle of a transcription. Narrow the filter to the largest odd width
that fits (down to 1, no filtering) instead.
diff --git a/src/whisper.cpp b/src/whisper.cpp
index 1675f33a..7653179f 100644
--- a/src/whisper.cpp
+++ b/src/whisper.cpp
@@ -9133,7 +9133,15 @@ static void median_filter(struct ggml_tensor * dst , const struct ggml_tensor *
return;
}
int filter_width = ((median_filter_user_data *) userdata)->filter_width;
- WHISPER_ASSERT(filter_width < a->ne[2]);
+ // A window that advanced only a few frames has fewer audio tokens than
+ // the filter is wide: narrow the filter instead of aborting (1: none).
+ if (filter_width >= a->ne[2]) {
+ filter_width = (a->ne[2] % 2) ? (int) a->ne[2] - 2 : (int) a->ne[2] - 1;
+ if (filter_width < 1) {
+ filter_width = 1;
+ }
+ }
+ WHISPER_ASSERT(filter_width < a->ne[2] || filter_width == 1);
WHISPER_ASSERT(filter_width % 2);
WHISPER_ASSERT(ggml_n_dims(a) == 3);
WHISPER_ASSERT(a->type == GGML_TYPE_F32);