Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -24,22 +24,21 @@ 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 translated_captions:
|
| 31 |
# Parse translated captions from the API response
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
if line.strip():
|
| 35 |
_, timestamp, text = line.partition(": ")[2].split(" ", 2)
|
| 36 |
-
captions_list.append({"Timestamp": timestamp, "
|
| 37 |
|
| 38 |
if captions_list:
|
| 39 |
st.write("## Translated Captions")
|
| 40 |
st.write("Timestamp - Translated Text")
|
| 41 |
for caption in captions_list:
|
| 42 |
-
st.write(f"{caption['Timestamp']} - {caption['
|
| 43 |
else:
|
| 44 |
st.write("No translated captions available")
|
| 45 |
|
|
|
|
| 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 translated_captions:
|
| 31 |
# Parse translated captions from the API response
|
| 32 |
+
for line in translated_captions:
|
| 33 |
+
if line.strip().startswith("fr:"):
|
|
|
|
| 34 |
_, timestamp, text = line.partition(": ")[2].split(" ", 2)
|
| 35 |
+
captions_list.append({"Timestamp": timestamp, "Translated": text})
|
| 36 |
|
| 37 |
if captions_list:
|
| 38 |
st.write("## Translated Captions")
|
| 39 |
st.write("Timestamp - Translated Text")
|
| 40 |
for caption in captions_list:
|
| 41 |
+
st.write(f"{caption['Timestamp']} - {caption['Translated']}")
|
| 42 |
else:
|
| 43 |
st.write("No translated captions available")
|
| 44 |
|