PRIYANSHUDHAKED's picture
Create app.py
20906a9 verified
import streamlit as st
import tempfile
from video_processor import process_video
from qa_engine import get_answer
from database import insert_video_data, search_similar_videos
st.title("Intelligent Video Q&A App with Gemini Vision Pro")
uploaded_file = st.file_uploader("Choose a video file", type=["mp4", "avi", "mov"])
if uploaded_file is not None:
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp4") as tmp_file:
tmp_file.write(uploaded_file.getvalue())
video_path = tmp_file.name
summary_words = st.slider("Number of words in summary", 50, 500, 200)
if st.button("Process Video"):
with st.spinner("Processing video with Gemini Vision Pro..."):
video_data = process_video(video_path, summary_words)
insert_video_data(video_data)
st.success("Video processed successfully!")
st.subheader("Video Summary")
st.write(video_data['summary'])
st.subheader("Extracted Code")
st.code(video_data['extracted_code'])
st.subheader("Similar Videos")
similar_videos = search_similar_videos(video_data['summary'])
for video in similar_videos:
st.write(f"- {video['title']}")
question = st.text_input("Ask a question about the video:")
if question and 'video_data' in locals():
answer = get_answer(question, video_data)
st.write("Answer:", answer)