Skip to content

Commit

Permalink
Fix webvtt subtitle writing
Browse files Browse the repository at this point in the history
  • Loading branch information
jhj0517 committed Dec 19, 2024
1 parent 46990fb commit 4fef683
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions modules/utils/subtitle_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,11 @@ class WriteVTT(SubtitlesWriter):
def write_result(
self, result: dict, file: TextIO, options: Optional[dict] = None, **kwargs
):
print("WEBVTT\n", file=file)
for start, end, text in self.iterate_result(result, options, **kwargs):
print(f"{start} --> {end}\n{text}\n", file=file, flush=True)
print("WEBVTT\n", file=file, flush=True)
for i, (start, end, text) in enumerate(
self.iterate_result(result, options, **kwargs), start=1
):
print(f"{i}\n{start} --> {end}\n{text}\n", file=file, flush=True)

def to_segments(self, file_path: str) -> List[Segment]:
segments = []
Expand All @@ -268,7 +270,7 @@ def to_segments(self, file_path: str) -> List[Segment]:
index = lines[0]
time_line = lines[1].split(" --> ")
start, end = time_str_to_seconds(time_line[0], self.decimal_marker), time_str_to_seconds(time_line[1], self.decimal_marker)
sentence = ' '.join(lines[1:])
sentence = ' '.join(lines[2:])

segments.append(Segment(
start=start,
Expand Down

0 comments on commit 4fef683

Please sign in to comment.