From c6083c6b97854ccd9e173decb29610176a3b3fdb Mon Sep 17 00:00:00 2001 From: Purfview <69023953+Purfview@users.noreply.github.com> Date: Thu, 25 Dec 2025 02:14:39 +0000 Subject: [PATCH 1/3] VAD Fix: explicit safe context, reduced RAM usage VAD Fix: explicit safe context (no view mutation). Reduced VAD RAM usage. --- faster_whisper/vad.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/faster_whisper/vad.py b/faster_whisper/vad.py index 31858384..9d473cd4 100644 --- a/faster_whisper/vad.py +++ b/faster_whisper/vad.py @@ -357,18 +357,16 @@ def __call__( h = np.zeros((1, 1, 128), dtype="float32") c = np.zeros((1, 1, 128), dtype="float32") - context = np.zeros( - (1, context_size_samples), - dtype="float32", - ) - batched_audio = audio.reshape(-1, num_samples) - context = batched_audio[..., -context_size_samples:] - context[-1] = 0 - context = np.roll(context, 1, 0) - batched_audio = np.concatenate([context, batched_audio], 1) + frames = audio.reshape(-1, num_samples) + num_frames = frames.shape[0] + frame_width = num_samples + context_size_samples - batched_audio = batched_audio.reshape(-1, num_samples + context_size_samples) + batched_audio = np.empty((num_frames, frame_width), dtype=np.float32) + batched_audio[:, context_size_samples:] = frames + if num_frames > 1: + batched_audio[1:, :context_size_samples] = frames[:-1, -context_size_samples:] + batched_audio[0, :context_size_samples] = 0.0 encoder_batch_size = 10000 num_segments = batched_audio.shape[0] From 9887bdafe7ec38576c7163722c2068c210818031 Mon Sep 17 00:00:00 2001 From: Purfview <69023953+Purfview@users.noreply.github.com> Date: Thu, 25 Dec 2025 02:43:14 +0000 Subject: [PATCH 2/3] Fix formatting --- faster_whisper/vad.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/faster_whisper/vad.py b/faster_whisper/vad.py index 9d473cd4..fb71714c 100644 --- a/faster_whisper/vad.py +++ b/faster_whisper/vad.py @@ -360,7 +360,7 @@ def __call__( frames = audio.reshape(-1, num_samples) num_frames = frames.shape[0] - frame_width = num_samples + context_size_samples + frame_width = num_samples + context_size_samples batched_audio = np.empty((num_frames, frame_width), dtype=np.float32) batched_audio[:, context_size_samples:] = frames From 87be3ba85d057bc1b8ab4d9a998c54dbdde307fd Mon Sep 17 00:00:00 2001 From: Purfview <69023953+Purfview@users.noreply.github.com> Date: Thu, 25 Dec 2025 02:53:39 +0000 Subject: [PATCH 3/3] Fix formatting 2 --- faster_whisper/vad.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/faster_whisper/vad.py b/faster_whisper/vad.py index fb71714c..35d0cb58 100644 --- a/faster_whisper/vad.py +++ b/faster_whisper/vad.py @@ -365,7 +365,9 @@ def __call__( batched_audio = np.empty((num_frames, frame_width), dtype=np.float32) batched_audio[:, context_size_samples:] = frames if num_frames > 1: - batched_audio[1:, :context_size_samples] = frames[:-1, -context_size_samples:] + batched_audio[1:, :context_size_samples] = frames[ + :-1, -context_size_samples: + ] batched_audio[0, :context_size_samples] = 0.0 encoder_batch_size = 10000