JaMugen commited on
Commit
f96ea69
·
1 Parent(s): e878da1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -14
app.py CHANGED
@@ -2,7 +2,6 @@ import streamlit as st
2
  import subprocess
3
  import pandas as pd
4
 
5
- # Function to install libraries
6
  def install_libraries():
7
  try:
8
  subprocess.check_call(['pip', 'install', 'pytube'])
@@ -14,19 +13,14 @@ def install_libraries():
14
  install_libraries()
15
 
16
  def main():
17
- # Importing after ensuring dependencies are installed
18
- import Milestone5API
19
-
20
- # Title
21
  st.title("Translate YouTube Video to French")
22
 
23
  url = st.text_input("Enter YouTube Video URL")
24
- captions_list = [] # Initialize empty list for captions
25
 
26
  if url:
27
  captions = Milestone5API.download_video_transcript(url)
28
  if captions:
29
- # Parse captions from the API response
30
  for line in captions.split("\n"):
31
  if line.strip():
32
  timestamp, text = line.split(" ", 1)
@@ -37,28 +31,21 @@ def main():
37
  start_index = st.session_state.get('start_index', 0)
38
  end_index = start_index + 6
39
 
40
- # Create DataFrame from captions_list
41
  df = pd.DataFrame(captions_list)
42
 
43
- # Display caption table with st.table
44
  st.write("## Caption Table")
45
 
46
- # Read the content of the CSS file
47
  with open("styles.css", "r") as f:
48
  css = f.read()
49
 
50
- # Embed the CSS into Streamlit
51
  st.markdown(f"<style>{css}</style>", unsafe_allow_html=True)
52
 
53
- # Display styled table using st.table
54
  st.table(df[['Timestamp', 'Original']].iloc[start_index:end_index])
55
 
56
- # Larger previous button
57
  col1, col2, col3 = st.columns([1, 8, 1])
58
  with col1:
59
  st.button("Previous", key='prev_button')
60
 
61
- # Next button and navigation logic
62
  with col3:
63
  if col3.button("Next") and end_index < len(captions_list):
64
  start_index += 6
 
2
  import subprocess
3
  import pandas as pd
4
 
 
5
  def install_libraries():
6
  try:
7
  subprocess.check_call(['pip', 'install', 'pytube'])
 
13
  install_libraries()
14
 
15
  def main():
 
 
 
 
16
  st.title("Translate YouTube Video to French")
17
 
18
  url = st.text_input("Enter YouTube Video URL")
19
+ captions_list = []
20
 
21
  if url:
22
  captions = Milestone5API.download_video_transcript(url)
23
  if captions:
 
24
  for line in captions.split("\n"):
25
  if line.strip():
26
  timestamp, text = line.split(" ", 1)
 
31
  start_index = st.session_state.get('start_index', 0)
32
  end_index = start_index + 6
33
 
 
34
  df = pd.DataFrame(captions_list)
35
 
 
36
  st.write("## Caption Table")
37
 
 
38
  with open("styles.css", "r") as f:
39
  css = f.read()
40
 
 
41
  st.markdown(f"<style>{css}</style>", unsafe_allow_html=True)
42
 
 
43
  st.table(df[['Timestamp', 'Original']].iloc[start_index:end_index])
44
 
 
45
  col1, col2, col3 = st.columns([1, 8, 1])
46
  with col1:
47
  st.button("Previous", key='prev_button')
48
 
 
49
  with col3:
50
  if col3.button("Next") and end_index < len(captions_list):
51
  start_index += 6