소스 검색

Fix exception when an audio file with no speech is provided (#1396)

Co-authored-by: Jong Wook Kim <jongwook@openai.com>
Jordi Mas 1 년 전
부모
커밋
b38a1f20f4
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      whisper/utils.py

+ 1 - 1
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"])