From 49c833dceeaaf45b8a73df4531ac8ee18f4ec5e9 Mon Sep 17 00:00:00 2001 From: Madhumitha Date: Sat, 4 May 2024 04:57:53 +0530 Subject: [PATCH] Add error handling to log_mel_spectrogram function --- whisper/audio.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/whisper/audio.py b/whisper/audio.py index cf6c66a..a1c0109 100644 --- a/whisper/audio.py +++ b/whisper/audio.py @@ -140,6 +140,9 @@ def log_mel_spectrogram( audio = load_audio(audio) audio = torch.from_numpy(audio) + if len(audio) < N_SAMPLES: # Check if audio length is less than expected + raise ValueError("Input audio length is shorter than the expected length.") + if device is not None: audio = audio.to(device) if padding > 0: