LittleLirow commited on
Commit
e3bc9da
1 Parent(s): 67dce58

Fix last timestamp value

Browse files
Files changed (1) hide show
  1. subtitles.py +4 -1
subtitles.py CHANGED
@@ -24,6 +24,7 @@ def audio2subtitle(rev_ai_token, fps=10):
24
  timestamp_re = r"(\d+:\d+:\d+,\d+)"
25
  string_re = r"^[a-zA-Z][^>]+$"
26
  last_num_re = r"\d+"
 
27
 
28
  deforum_str = ""
29
 
@@ -32,6 +33,7 @@ def audio2subtitle(rev_ai_token, fps=10):
32
  timestamps = re.findall(timestamp_re, line)
33
  if timestamps:
34
  timestamp = re.split(":|,", timestamps[0])
 
35
  deforum_str += timestamp2frame(timestamp)
36
  deforum_str += ": "
37
  strings = re.findall(string_re, line)
@@ -43,6 +45,7 @@ def audio2subtitle(rev_ai_token, fps=10):
43
  deforum_str = deforum_str.replace("\n", "").strip()
44
  deforum_str = re.sub(r"\|\s+(?=[a-zA-Z])", r"", deforum_str)
45
  deforum_str = deforum_str[:-1]
46
- last_timestamp = re.findall(last_num_re, deforum_str)[-1]
 
47
 
48
  return deforum_str, int(last_timestamp)
 
24
  timestamp_re = r"(\d+:\d+:\d+,\d+)"
25
  string_re = r"^[a-zA-Z][^>]+$"
26
  last_num_re = r"\d+"
27
+ last_timestamp = ""
28
 
29
  deforum_str = ""
30
 
 
33
  timestamps = re.findall(timestamp_re, line)
34
  if timestamps:
35
  timestamp = re.split(":|,", timestamps[0])
36
+ last_timestamp = re.split(":|,", timestamps[1])
37
  deforum_str += timestamp2frame(timestamp)
38
  deforum_str += ": "
39
  strings = re.findall(string_re, line)
 
45
  deforum_str = deforum_str.replace("\n", "").strip()
46
  deforum_str = re.sub(r"\|\s+(?=[a-zA-Z])", r"", deforum_str)
47
  deforum_str = deforum_str[:-1]
48
+
49
+ last_timestamp = timestamp2frame(last_timestamp)
50
 
51
  return deforum_str, int(last_timestamp)