"""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