Spaces:
Build error
Build error
File size: 2,209 Bytes
579d7ac 8bc1706 579d7ac 8bc1706 579d7ac 8977eea 579d7ac 8bc1706 8977eea 8bc1706 8977eea 8bc1706 8977eea 8bc1706 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | import gradio as gr
from pypdf import PdfReader
from explanations import explanation1, explanation2, explanation3
from transcript_transformer import TranscriptTransformer
transformer = TranscriptTransformer()
def process_pdf(pdf_file):
pdf_reader = PdfReader(pdf_file.name)
text = ""
for page in pdf_reader.pages:
text += page.extract_text()
return text
def process_transcript(transcript_text: str, pdf_file, duration: int):
yield gr.update(value="Building the lecture..", visible=True)
# Use PDF content if provided, otherwise use transcript text
if pdf_file:
transcript = process_pdf(pdf_file)
else:
transcript = transcript_text
transformed_transcript = transformer.generate_lecture(transcript, duration)
yield gr.update(value=transformed_transcript, visible=True)
with gr.Blocks() as demo:
accordion1 = gr.Accordion("How prompts were engineered and refined?", open=False)
with accordion1:
gr.Markdown(explanation1)
accordion2 = gr.Accordion("Challenges faced", open=False)
with accordion2:
gr.Markdown(explanation2)
accordion3 = gr.Accordion("How the system can be extended or scaled?", open=False)
with accordion3:
gr.Markdown(explanation3)
gr.Interface(
fn=process_transcript,
inputs=[
gr.Textbox(
label="Input Transcript",
placeholder="Paste your transcript here...",
lines=10,
),
gr.File(
label="Or Upload PDF",
file_types=[".pdf"],
),
gr.Slider(
minimum=15,
maximum=60,
value=30,
step=15,
label="Lecture Duration (minutes)",
),
],
outputs=gr.Markdown(label="Transformed Teaching Transcript"),
title="Transcript to Teaching Material Transformer",
description="""Transform transcripts into teaching materials.
The output will be formatted as a complete lecture with clear sections,
examples, and interactive elements.""",
theme="default",
)
demo.launch()
|