From b38a1f20f4b23f3f3099af2c3e0ca95627276ddf Mon Sep 17 00:00:00 2001 From: Jordi Mas Date: Tue, 10 Oct 2023 19:01:01 +0200 Subject: [PATCH] Fix exception when an audio file with no speech is provided (#1396) Co-authored-by: Jong Wook Kim --- whisper/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/whisper/utils.py b/whisper/utils.py index ba5a10c..22260d0 100644 --- a/whisper/utils.py +++ b/whisper/utils.py @@ -145,7 +145,7 @@ class SubtitlesWriter(ResultWriter): if len(subtitle) > 0: yield subtitle - if "words" in result["segments"][0]: + if len(result["segments"]) > 0 and "words" in result["segments"][0]: for subtitle in iterate_subtitles(): subtitle_start = self.format_timestamp(subtitle[0]["start"]) subtitle_end = self.format_timestamp(subtitle[-1]["end"])