Spaces:
Sleeping
Sleeping
Download app.py from ISWARYAISH/ai-notesmaker: direct link, hf CLI and curl.
- Browser
- Download file 1.81 kB
-
https://huggingface.co/spaces/ISWARYAISH/ai-notesmaker/resolve/main/app.py
- Command line
-
hf download hf://spaces/ISWARYAISH/ai-notesmaker/app.py
-
curl -L -o app.py https://huggingface.co/spaces/ISWARYAISH/ai-notesmaker/resolve/main/app.py
1.81 kB
| import gradio as gr | |
| import whisper | |
| import tempfile | |
| from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer | |
| from reportlab.lib.styles import getSampleStyleSheet | |
| # Load Whisper model once | |
| model = whisper.load_model("base") | |
| def transcribe_lecture(file): | |
| if file is None: | |
| return "Please upload a file.", None | |
| try: | |
| result = model.transcribe(file.name) | |
| transcript = result["text"] | |
| pdf_path = tempfile.NamedTemporaryFile( | |
| delete=False, | |
| suffix=".pdf" | |
| ).name | |
| doc = SimpleDocTemplate(pdf_path) | |
| styles = getSampleStyleSheet() | |
| content = [ | |
| Paragraph("NeuroNotes AI Transcript", styles["Title"]), | |
| Spacer(1, 12), | |
| Paragraph(transcript, styles["BodyText"]) | |
| ] | |
| doc.build(content) | |
| return transcript, pdf_path | |
| except Exception as e: | |
| return f"Error: {str(e)}", None | |
| with gr.Blocks( | |
| title="NeuroNotes AI" | |
| ) as demo: | |
| gr.Markdown( | |
| """ | |
| # 🧠 NeuroNotes AI | |
| Upload classroom audio or video lectures. | |
| Features: | |
| - Speech-to-Text | |
| - Transcript Generation | |
| - PDF Export | |
| No API key required. | |
| """ | |
| ) | |
| lecture_file = gr.File( | |
| label="Upload Audio or Video", | |
| file_types=[ | |
| ".mp3", | |
| ".wav", | |
| ".m4a", | |
| ".mp4", | |
| ".mov", | |
| ".avi", | |
| ".mkv" | |
| ] | |
| ) | |
| generate_btn = gr.Button("Generate Transcript") | |
| transcript_output = gr.Textbox( | |
| label="Transcript", | |
| lines=20 | |
| ) | |
| pdf_output = gr.File( | |
| label="Download PDF" | |
| ) | |
| generate_btn.click( | |
| fn=transcribe_lecture, | |
| inputs=lecture_file, | |
| outputs=[ | |
| transcript_output, | |
| pdf_output | |
| ] | |
| ) | |
| demo.launch() |