Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,13 +10,17 @@ def install_libraries():
|
|
| 10 |
print("Error during installation:", e)
|
| 11 |
|
| 12 |
install_libraries()
|
| 13 |
-
|
| 14 |
def main():
|
|
|
|
|
|
|
|
|
|
| 15 |
# Title
|
| 16 |
st.title("Translate YouTube Video to French")
|
| 17 |
|
| 18 |
url = st.text_input("Enter YouTube Video URL")
|
| 19 |
captions_list = [] # Initialize empty list for captions
|
|
|
|
| 20 |
if url:
|
| 21 |
captions = Milestone5API.download_video_transcript(url)
|
| 22 |
if captions:
|
|
@@ -30,21 +34,33 @@ def main():
|
|
| 30 |
|
| 31 |
start_index = st.session_state.get('start_index', 0)
|
| 32 |
end_index = start_index + 6
|
| 33 |
-
|
| 34 |
-
#
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
for i in range(start_index, min(end_index, len(captions_list))):
|
| 39 |
-
st.write(
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
# Navigation buttons
|
| 42 |
col1, col2, col3 = st.columns([1, 8, 1])
|
| 43 |
if col1.button("Previous") and start_index > 0:
|
| 44 |
start_index -= 6
|
| 45 |
end_index -= 6
|
| 46 |
st.session_state['start_index'] = start_index
|
| 47 |
-
|
| 48 |
if col3.button("Next") and end_index < len(captions_list):
|
| 49 |
start_index += 6
|
| 50 |
end_index += 6
|
|
|
|
| 10 |
print("Error during installation:", e)
|
| 11 |
|
| 12 |
install_libraries()
|
| 13 |
+
|
| 14 |
def main():
|
| 15 |
+
# Importing after ensuring dependencies are installed
|
| 16 |
+
import Milestone5API
|
| 17 |
+
|
| 18 |
# Title
|
| 19 |
st.title("Translate YouTube Video to French")
|
| 20 |
|
| 21 |
url = st.text_input("Enter YouTube Video URL")
|
| 22 |
captions_list = [] # Initialize empty list for captions
|
| 23 |
+
|
| 24 |
if url:
|
| 25 |
captions = Milestone5API.download_video_transcript(url)
|
| 26 |
if captions:
|
|
|
|
| 34 |
|
| 35 |
start_index = st.session_state.get('start_index', 0)
|
| 36 |
end_index = start_index + 6
|
| 37 |
+
|
| 38 |
+
# Define CSS styles for table cells
|
| 39 |
+
timestamp_style = "padding: 8px; background-color: red; color: grey;"
|
| 40 |
+
original_style = "padding: 8px; background-color: black; color: white;"
|
| 41 |
+
|
| 42 |
+
st.write(
|
| 43 |
+
"<style> table { width: 100%; } th, td { border: 1px solid black; } </style>",
|
| 44 |
+
unsafe_allow_html=True,
|
| 45 |
+
)
|
| 46 |
+
st.write("<table><tr><th>Timestamp</th><th>Original</th></tr>", unsafe_allow_html=True)
|
| 47 |
+
|
| 48 |
for i in range(start_index, min(end_index, len(captions_list))):
|
| 49 |
+
st.write(
|
| 50 |
+
f"<tr><td style='{timestamp_style}'>{captions_list[i]['Timestamp']}</td>"
|
| 51 |
+
f"<td style='{original_style}'>{captions_list[i]['Original']}</td></tr>",
|
| 52 |
+
unsafe_allow_html=True,
|
| 53 |
+
)
|
| 54 |
+
|
| 55 |
+
st.write("</table>", unsafe_allow_html=True)
|
| 56 |
+
|
| 57 |
# Navigation buttons
|
| 58 |
col1, col2, col3 = st.columns([1, 8, 1])
|
| 59 |
if col1.button("Previous") and start_index > 0:
|
| 60 |
start_index -= 6
|
| 61 |
end_index -= 6
|
| 62 |
st.session_state['start_index'] = start_index
|
| 63 |
+
|
| 64 |
if col3.button("Next") and end_index < len(captions_list):
|
| 65 |
start_index += 6
|
| 66 |
end_index += 6
|