JaMugen commited on
Commit
018293c
·
1 Parent(s): 27126ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -12
app.py CHANGED
@@ -24,26 +24,25 @@ def main():
24
  url = st.text_input("Enter YouTube Video URL")
25
  captions_list = [] # Initialize empty list for captions
26
 
27
- if url:
28
  captions, translated_captions, original_file, translated_file = Milestone5API.download_video_transcript(url)
29
 
30
  if captions:
31
- # Parse captions from the API response for original captions
32
  for line in captions.split("\n"):
33
  if line.strip():
34
  lang, timestamp, text = line.split(" ", 2)
35
  if lang == "en:" or lang == "fr:":
36
  captions_list.append({"Timestamp": timestamp, "Language": lang, "Text": text})
37
-
38
- if translated_captions:
39
- captions_list = []
40
- for original_line, translated_line in zip(captions_list, translated_captions):
41
- lang, timestamp, text = original_line.split(" ", 2)
42
- lang_trans, timestamp_trans, text_trans = translated_line.split(" ", 2)
43
- if lang == "en:" or lang == "fr:": # Assuming lines starting with "fr:" or "en:"
44
- captions_list.append({"Timestamp": timestamp, "Language": lang, "Text": text, "Translated": text_trans})
45
-
46
- df = pd.DataFrame(captions_list)
47
 
48
  start_index = st.session_state.get('start_index', 0)
49
  end_index = start_index + 6
 
24
  url = st.text_input("Enter YouTube Video URL")
25
  captions_list = [] # Initialize empty list for captions
26
 
27
+ if url:
28
  captions, translated_captions, original_file, translated_file = Milestone5API.download_video_transcript(url)
29
 
30
  if captions:
31
+ captions_list = []
32
  for line in captions.split("\n"):
33
  if line.strip():
34
  lang, timestamp, text = line.split(" ", 2)
35
  if lang == "en:" or lang == "fr:":
36
  captions_list.append({"Timestamp": timestamp, "Language": lang, "Text": text})
37
+
38
+ if translated_captions:
39
+ for i, translated_line in enumerate(translated_captions):
40
+ lang_trans, timestamp_trans, text_trans = translated_line.split(" ", 2)
41
+ if lang_trans == "fr:" or lang_trans == "en:":
42
+ captions_list[i]["Translated"] = text_trans
43
+
44
+ df = pd.DataFrame(captions_list)
45
+
 
46
 
47
  start_index = st.session_state.get('start_index', 0)
48
  end_index = start_index + 6