JaMugen commited on
Commit
0e5118a
·
1 Parent(s): 7f78df0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -15
app.py CHANGED
@@ -27,25 +27,19 @@ def main():
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
- if i < len(captions_list): # Ensure captions_list has enough elements
41
- lang_trans, timestamp_trans, text_trans = translated_line.split(" ", 2)
42
- if lang_trans == "fr:" or lang_trans == "en:":
43
- captions_list[i]["Translated"] = text_trans
44
- else:
45
- break # Stop if captions_list ends before translated_captions
46
 
47
  df = pd.DataFrame(captions_list)
48
 
 
 
 
49
 
50
  start_index = st.session_state.get('start_index', 0)
51
  end_index = start_index + 6
 
27
  if url:
28
  captions, translated_captions, original_file, translated_file = Milestone5API.download_video_transcript(url)
29
 
30
+ if captions and translated_captions:
31
  captions_list = []
32
+ for line, translated_line in zip(captions.split("\n"), translated_captions):
33
+ lang, timestamp, text = line.split(" ", 2)
34
+ lang_trans, _, text_trans = translated_line.split(" ", 2)
35
+ if lang in ["en:", "fr:"] and lang_trans in ["en:", "fr:"]:
36
+ captions_list.append({"Timestamp": timestamp, "Original": text, "Translated": text_trans})
 
 
 
 
 
 
 
 
 
37
 
38
  df = pd.DataFrame(captions_list)
39
 
40
+ # Display DataFrame
41
+ st.write(df)
42
+
43
 
44
  start_index = st.session_state.get('start_index', 0)
45
  end_index = start_index + 6