Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 28 |
captions, translated_captions, original_file, translated_file = Milestone5API.download_video_transcript(url)
|
| 29 |
|
| 30 |
if captions:
|
| 31 |
-
|
| 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 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 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
|