Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import streamlit as st
|
2 |
import os
|
3 |
-
|
4 |
import whisper
|
5 |
from transformers import pipeline
|
6 |
|
@@ -8,7 +8,7 @@ from transformers import pipeline
|
|
8 |
def extract_audio(video_path, audio_path="audio.wav"):
|
9 |
if os.path.exists(audio_path):
|
10 |
os.remove(audio_path)
|
11 |
-
video = VideoFileClip(video_path)
|
12 |
video.audio.write_audiofile(audio_path)
|
13 |
return audio_path
|
14 |
|
@@ -40,31 +40,34 @@ def answer_question(question, context):
|
|
40 |
return result["answer"]
|
41 |
|
42 |
# Streamlit App
|
43 |
-
st.title("Lecture Video Processor")
|
44 |
|
45 |
-
uploaded_file = st.file_uploader("Upload a video file", type=["mp4", "mov", "avi", "mkv"])
|
46 |
|
47 |
if uploaded_file:
|
48 |
video_path = uploaded_file.name
|
49 |
with open(video_path, "wb") as f:
|
50 |
f.write(uploaded_file.read())
|
51 |
|
52 |
-
st.
|
|
|
|
|
53 |
audio_path = extract_audio(video_path)
|
|
|
54 |
|
55 |
-
st.info("Transcribing audio...")
|
56 |
transcript = transcribe_audio(audio_path)
|
57 |
-
st.text_area("Transcript", transcript, height=200)
|
58 |
|
59 |
-
st.info("Summarizing transcript...")
|
60 |
video_summary = summarize_text(transcript)
|
61 |
-
st.text_area("Summary", video_summary, height=150)
|
62 |
|
63 |
-
st.info("Generating study notes...")
|
64 |
study_notes = generate_study_notes(video_summary)
|
65 |
-
st.text_area("Study Notes", study_notes, height=150)
|
66 |
|
67 |
-
question = st.text_input("Ask a question about the video:")
|
68 |
if question:
|
69 |
answer = answer_question(question, video_summary)
|
70 |
-
st.write("Answer:", answer)
|
|
|
1 |
import streamlit as st
|
2 |
import os
|
3 |
+
import moviepy.editor as mp
|
4 |
import whisper
|
5 |
from transformers import pipeline
|
6 |
|
|
|
8 |
def extract_audio(video_path, audio_path="audio.wav"):
|
9 |
if os.path.exists(audio_path):
|
10 |
os.remove(audio_path)
|
11 |
+
video = mp.VideoFileClip(video_path)
|
12 |
video.audio.write_audiofile(audio_path)
|
13 |
return audio_path
|
14 |
|
|
|
40 |
return result["answer"]
|
41 |
|
42 |
# Streamlit App
|
43 |
+
st.title("Lecture Video Processor π₯π")
|
44 |
|
45 |
+
uploaded_file = st.file_uploader("π€ Upload a video file", type=["mp4", "mov", "avi", "mkv"])
|
46 |
|
47 |
if uploaded_file:
|
48 |
video_path = uploaded_file.name
|
49 |
with open(video_path, "wb") as f:
|
50 |
f.write(uploaded_file.read())
|
51 |
|
52 |
+
st.success("β
Video uploaded successfully!")
|
53 |
+
|
54 |
+
st.info("π Extracting audio...")
|
55 |
audio_path = extract_audio(video_path)
|
56 |
+
st.success("β
Audio extracted!")
|
57 |
|
58 |
+
st.info("ποΈ Transcribing audio...")
|
59 |
transcript = transcribe_audio(audio_path)
|
60 |
+
st.text_area("π Transcript", transcript, height=200)
|
61 |
|
62 |
+
st.info("π Summarizing transcript...")
|
63 |
video_summary = summarize_text(transcript)
|
64 |
+
st.text_area("π Summary", video_summary, height=150)
|
65 |
|
66 |
+
st.info("π Generating study notes...")
|
67 |
study_notes = generate_study_notes(video_summary)
|
68 |
+
st.text_area("π Study Notes", study_notes, height=150)
|
69 |
|
70 |
+
question = st.text_input("β Ask a question about the video:")
|
71 |
if question:
|
72 |
answer = answer_question(question, video_summary)
|
73 |
+
st.write("π‘ Answer:", answer)
|