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

Co-authored-by: Jong Wook Kim <jongwook@openai.com>
This commit is contained in:
Jordi Mas 2023-10-10 19:01:01 +02:00 committed by GitHub
parent 0a60fcaa9b
commit b38a1f20f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -145,7 +145,7 @@ class SubtitlesWriter(ResultWriter):
if len(subtitle) > 0: if len(subtitle) > 0:
yield subtitle yield subtitle
if "words" in result["segments"][0]: if len(result["segments"]) > 0 and "words" in result["segments"][0]:
for subtitle in iterate_subtitles(): for subtitle in iterate_subtitles():
subtitle_start = self.format_timestamp(subtitle[0]["start"]) subtitle_start = self.format_timestamp(subtitle[0]["start"])
subtitle_end = self.format_timestamp(subtitle[-1]["end"]) subtitle_end = self.format_timestamp(subtitle[-1]["end"])