Borahan commited on
Commit
dbfaffc
·
unverified ·
1 Parent(s): 99b3c46

Update subtitle_manager.py

Browse files
Files changed (1) hide show
  1. modules/utils/subtitle_manager.py +4 -4
modules/utils/subtitle_manager.py CHANGED
@@ -34,7 +34,7 @@ def get_srt(segments):
34
 
35
 
36
  def get_vtt(segments):
37
- output = "WebVTT\n\n"
38
  for i, segment in enumerate(segments):
39
  output += f"{timeformat_vtt(segment['start'])} --> {timeformat_vtt(segment['end'])}\n"
40
  if segment['text'].startswith(' '):
@@ -76,7 +76,7 @@ def parse_srt(file_path):
76
 
77
 
78
  def parse_vtt(file_path):
79
- """Reads WebVTT file and returns as dict"""
80
  with open(file_path, 'r', encoding='utf-8') as file:
81
  webvtt_data = file.read()
82
 
@@ -84,7 +84,7 @@ def parse_vtt(file_path):
84
  blocks = webvtt_data.split('\n\n')
85
 
86
  for block in blocks:
87
- if block.strip() != '' and not block.strip().startswith("WebVTT"):
88
  lines = block.strip().split('\n')
89
  timestamp = lines[0]
90
  sentence = ' '.join(lines[1:])
@@ -107,7 +107,7 @@ def get_serialized_srt(dicts):
107
 
108
 
109
  def get_serialized_vtt(dicts):
110
- output = "WebVTT\n\n"
111
  for dic in dicts:
112
  output += f'{dic["timestamp"]}\n'
113
  output += f'{dic["sentence"]}\n\n'
 
34
 
35
 
36
  def get_vtt(segments):
37
+ output = "WEBVTT\n\n"
38
  for i, segment in enumerate(segments):
39
  output += f"{timeformat_vtt(segment['start'])} --> {timeformat_vtt(segment['end'])}\n"
40
  if segment['text'].startswith(' '):
 
76
 
77
 
78
  def parse_vtt(file_path):
79
+ """Reads WEBVTT file and returns as dict"""
80
  with open(file_path, 'r', encoding='utf-8') as file:
81
  webvtt_data = file.read()
82
 
 
84
  blocks = webvtt_data.split('\n\n')
85
 
86
  for block in blocks:
87
+ if block.strip() != '' and not block.strip().startswith("WEBVTT"):
88
  lines = block.strip().split('\n')
89
  timestamp = lines[0]
90
  sentence = ' '.join(lines[1:])
 
107
 
108
 
109
  def get_serialized_vtt(dicts):
110
+ output = "WEBVTT\n\n"
111
  for dic in dicts:
112
  output += f'{dic["timestamp"]}\n'
113
  output += f'{dic["sentence"]}\n\n'