Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -19,11 +19,12 @@ client = OpenAI(
|
|
19 |
# Streamlit App UI
|
20 |
st.title("π₯ AI-Powered Video Summarization")
|
21 |
# Define custom CSS
|
|
|
22 |
st.markdown(
|
23 |
"""
|
24 |
<style>
|
25 |
-
|
26 |
-
font-size:
|
27 |
font-weight: bold;
|
28 |
color: black;
|
29 |
}
|
@@ -31,6 +32,7 @@ st.markdown(
|
|
31 |
""",
|
32 |
unsafe_allow_html=True
|
33 |
)
|
|
|
34 |
def set_background(image_file):
|
35 |
with open(image_file, "rb") as image:
|
36 |
encoded_string = base64.b64encode(image.read()).decode()
|
@@ -55,7 +57,7 @@ def set_background(image_file):
|
|
55 |
set_background("background.jpg")
|
56 |
|
57 |
|
58 |
-
uploaded_file = st.file_uploader("
|
59 |
|
60 |
if uploaded_file:
|
61 |
video_path = "input_video.mp4"
|
@@ -65,7 +67,7 @@ if uploaded_file:
|
|
65 |
st.video(video_path)
|
66 |
|
67 |
# Scene Detection & Frame Extraction
|
68 |
-
st.write("
|
69 |
|
70 |
def extract_key_frames(video_path, output_folder="frames"):
|
71 |
os.makedirs(output_folder, exist_ok=True)
|
@@ -90,7 +92,7 @@ if uploaded_file:
|
|
90 |
extract_key_frames(video_path)
|
91 |
|
92 |
# Caption Generation
|
93 |
-
st.write("
|
94 |
|
95 |
def generate_caption(image_path):
|
96 |
image = Image.open(image_path).convert("RGB")
|
@@ -107,7 +109,7 @@ if uploaded_file:
|
|
107 |
# st.write("π Generated Captions:", captions)
|
108 |
|
109 |
# Summarization
|
110 |
-
st.write("
|
111 |
|
112 |
def summarize_captions(captions):
|
113 |
prompt = f"Summarize the following sequence of video frames into a meaningful story under 800 characters:\n\n{captions}"
|
@@ -125,7 +127,7 @@ if uploaded_file:
|
|
125 |
st.write("π Video Summary:", summary)
|
126 |
|
127 |
# Text-to-Speech
|
128 |
-
st.write("
|
129 |
|
130 |
def text_to_speech(text, output_audio="summary_audio.mp3"):
|
131 |
tts = gTTS(text, lang="en")
|
|
|
19 |
# Streamlit App UI
|
20 |
st.title("π₯ AI-Powered Video Summarization")
|
21 |
# Define custom CSS
|
22 |
+
# Custom CSS for larger, darker text
|
23 |
st.markdown(
|
24 |
"""
|
25 |
<style>
|
26 |
+
.big-font {
|
27 |
+
font-size: 30px !important;
|
28 |
font-weight: bold;
|
29 |
color: black;
|
30 |
}
|
|
|
32 |
""",
|
33 |
unsafe_allow_html=True
|
34 |
)
|
35 |
+
|
36 |
def set_background(image_file):
|
37 |
with open(image_file, "rb") as image:
|
38 |
encoded_string = base64.b64encode(image.read()).decode()
|
|
|
57 |
set_background("background.jpg")
|
58 |
|
59 |
|
60 |
+
uploaded_file = st.file_uploader("π€ Upload a Video File", type=["mp4"])
|
61 |
|
62 |
if uploaded_file:
|
63 |
video_path = "input_video.mp4"
|
|
|
67 |
st.video(video_path)
|
68 |
|
69 |
# Scene Detection & Frame Extraction
|
70 |
+
st.write("π Detecting scene changes and extracting key frames...")
|
71 |
|
72 |
def extract_key_frames(video_path, output_folder="frames"):
|
73 |
os.makedirs(output_folder, exist_ok=True)
|
|
|
92 |
extract_key_frames(video_path)
|
93 |
|
94 |
# Caption Generation
|
95 |
+
st.write("π Generating captions for extracted frames...")
|
96 |
|
97 |
def generate_caption(image_path):
|
98 |
image = Image.open(image_path).convert("RGB")
|
|
|
109 |
# st.write("π Generated Captions:", captions)
|
110 |
|
111 |
# Summarization
|
112 |
+
st.write("π Summarizing captions using AI...")
|
113 |
|
114 |
def summarize_captions(captions):
|
115 |
prompt = f"Summarize the following sequence of video frames into a meaningful story under 800 characters:\n\n{captions}"
|
|
|
127 |
st.write("π Video Summary:", summary)
|
128 |
|
129 |
# Text-to-Speech
|
130 |
+
st.write("π Generating voice narration...")
|
131 |
|
132 |
def text_to_speech(text, output_audio="summary_audio.mp3"):
|
133 |
tts = gTTS(text, lang="en")
|