sairaarif89 commited on
Commit
53e2c95
Β·
verified Β·
1 Parent(s): 751edc8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -13
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import streamlit as st
2
  import os
3
- from moviepy.editor import VideoFileClip
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.info("Extracting audio...")
 
 
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)