Spaces:
Sleeping
Sleeping
File size: 2,492 Bytes
4ce49c4 91e586d 4ce49c4 56a57a9 4ce49c4 91e586d 4ce49c4 |
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 |
"""UI component and layout for the PDF Explainer app."""
import gradio as gr
from gradio_pdf import PDF
from .styles import get_fullscreen_css
def build_interface(process_pdf_fn):
"""Builds and returns the Gradio interface."""
with gr.Blocks(title="π PDF Text Extractor", theme=gr.themes.Soft()) as demo:
gr.HTML(get_fullscreen_css())
gr.Markdown("# π PDF Text Extractor")
gr.Markdown("Upload a PDF on the left to automatically extract and view text on the right.")
with gr.Row(equal_height=True):
with gr.Column(scale=1):
gr.Markdown("### π PDF Document")
pdf_input = PDF(
label="Upload and View PDF",
height=600,
interactive=True
)
status_output = gr.Textbox(
label="Status",
lines=2,
placeholder="Upload a PDF to see status...",
interactive=False
)
with gr.Column(scale=1):
gr.Markdown("### π Extracted Content")
with gr.Tabs():
with gr.TabItem("Extracted Text"):
text_output = gr.Textbox(
label="Extracted Text",
lines=20,
placeholder="Upload a PDF to automatically extract text...",
show_copy_button=True,
interactive=False
)
with gr.TabItem("Explanation Script"):
explanation_output = gr.Textbox(
label="Generated Explanation Script",
lines=15,
placeholder="Explanations will be automatically generated after text extraction...",
show_copy_button=True,
interactive=False )
gr.Markdown("### π Audio Generation")
audio_output = gr.Audio(
label="Generated Explanation Audio",
interactive=False,
visible=False,
)
pdf_input.upload(
fn=process_pdf_fn,
inputs=[pdf_input],
outputs=[text_output, status_output, explanation_output, audio_output, audio_output]
)
return demo
|