Skip to content

Commit

Permalink
Update subtitle_manager.py
Browse files Browse the repository at this point in the history
WebVTT change WEBVTT
  • Loading branch information
borahanarslan authored Oct 29, 2024
1 parent 99b3c46 commit dbfaffc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions modules/utils/subtitle_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get_srt(segments):


def get_vtt(segments):
output = "WebVTT\n\n"
output = "WEBVTT\n\n"
for i, segment in enumerate(segments):
output += f"{timeformat_vtt(segment['start'])} --> {timeformat_vtt(segment['end'])}\n"
if segment['text'].startswith(' '):
Expand Down Expand Up @@ -76,15 +76,15 @@ def parse_srt(file_path):


def parse_vtt(file_path):
"""Reads WebVTT file and returns as dict"""
"""Reads WEBVTT file and returns as dict"""
with open(file_path, 'r', encoding='utf-8') as file:
webvtt_data = file.read()

data = []
blocks = webvtt_data.split('\n\n')

for block in blocks:
if block.strip() != '' and not block.strip().startswith("WebVTT"):
if block.strip() != '' and not block.strip().startswith("WEBVTT"):
lines = block.strip().split('\n')
timestamp = lines[0]
sentence = ' '.join(lines[1:])
Expand All @@ -107,7 +107,7 @@ def get_serialized_srt(dicts):


def get_serialized_vtt(dicts):
output = "WebVTT\n\n"
output = "WEBVTT\n\n"
for dic in dicts:
output += f'{dic["timestamp"]}\n'
output += f'{dic["sentence"]}\n\n'
Expand Down

0 comments on commit dbfaffc

Please sign in to comment.