jhj0517 commited on
Commit
99b3c46
·
unverified ·
2 Parent(s): 45c0fe8 8ac99d5

Merge pull request #360 from jhj0517/fix/vtt

Browse files
Files changed (1) hide show
  1. modules/utils/subtitle_manager.py +2 -6
modules/utils/subtitle_manager.py CHANGED
@@ -36,7 +36,6 @@ def get_srt(segments):
36
  def get_vtt(segments):
37
  output = "WebVTT\n\n"
38
  for i, segment in enumerate(segments):
39
- output += f"{i + 1}\n"
40
  output += f"{timeformat_vtt(segment['start'])} --> {timeformat_vtt(segment['end'])}\n"
41
  if segment['text'].startswith(' '):
42
  segment['text'] = segment['text'][1:]
@@ -87,12 +86,10 @@ def parse_vtt(file_path):
87
  for block in blocks:
88
  if block.strip() != '' and not block.strip().startswith("WebVTT"):
89
  lines = block.strip().split('\n')
90
- index = lines[0]
91
- timestamp = lines[1]
92
- sentence = ' '.join(lines[2:])
93
 
94
  data.append({
95
- "index": index,
96
  "timestamp": timestamp,
97
  "sentence": sentence
98
  })
@@ -112,7 +109,6 @@ def get_serialized_srt(dicts):
112
  def get_serialized_vtt(dicts):
113
  output = "WebVTT\n\n"
114
  for dic in dicts:
115
- output += f'{dic["index"]}\n'
116
  output += f'{dic["timestamp"]}\n'
117
  output += f'{dic["sentence"]}\n\n'
118
  return output
 
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(' '):
41
  segment['text'] = segment['text'][1:]
 
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:])
 
91
 
92
  data.append({
 
93
  "timestamp": timestamp,
94
  "sentence": sentence
95
  })
 
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'
114
  return output