import streamlit as st from pathlib import Path import tempfile import subprocess import textwrap st.set_page_config(page_title="Lec2Note2 – Lecture-to-Notes", layout="wide") st.title("📝 Lec2Note2 – Automatic Lecture Notes Generator") st.markdown( textwrap.dedent( """ Upload a lecture **video** and receive a fully-formatted **Markdown** study note – complete with key images and structured sections. The processing pipeline performs ASR transcription, vision & semantic segmentation, then invokes an LLM to produce rich notes. """ ) ) video_file = st.file_uploader("🎬 Upload MP4/MKV/AVI", type=["mp4", "mkv", "avi"]) run_btn = st.button("🚀 Generate Notes", disabled=video_file is None) if run_btn and video_file: # Save upload to a temporary file tmp_dir = tempfile.TemporaryDirectory() vid_path = Path(tmp_dir.name) / video_file.name with vid_path.open("wb") as f: f.write(video_file.read()) output_md = vid_path.with_suffix(".md") st.info("Processing started. This may take several minutes depending on video length …") progress_txt = st.empty() # Run pipeline via subprocess to avoid blocking UI; capture logs with st.spinner("Running Lec2Note2 pipeline …"): result = subprocess.run( [ "python", "-m", "lec2note.scripts.run_pipeline", "--video", str(vid_path), "--output", str(output_md), ], text=True, capture_output=True, ) if result.returncode != 0: st.error("❌ Pipeline failed. See logs below.") with st.expander("Show logs"): st.code(result.stderr + "\n" + result.stdout) else: st.success("✅ Notes generated!") md_content = output_md.read_text() st.markdown(md_content) st.download_button( label="💾 Download notes.md", data=md_content, file_name="lecture_notes.md", mime="text/markdown", ) tmp_dir.cleanup()