import gradio as gr from helper_fns import process_files, get_summarization_method, generate_output from summarizer import summarize_file from helper_fns import text_to_speech with gr.Blocks() as demo: with gr.Row(): with gr.Column(): files = gr.UploadButton( label='Upload File For Summarization', file_count='multiple', file_types=["pdf", "docx", "pptx"] ) summarization_method_radio = gr.Radio(choices=['map_reduce', 'stuff', 'refine'], value='map_reduce', label='Select Summarization Method', interactive=False) generate_summaries_button = gr.Button(value='Generate Summaries', interactive=False, elem_id='summary_button') files.upload(process_files, None, outputs=[generate_summaries_button, summarization_method_radio]) summarization_method_radio.input(fn = get_summarization_method, inputs=summarization_method_radio) with gr.Column(): summary_text = gr.Textbox(label='Summarized Text: ', interactive=False) summary_audio = gr.Audio(label='Summarized audio', sources='upload', type='filepath', interactive=False, autoplay=False) generate_summaries_button.click( fn = generate_output, inputs=[summarization_method_radio, files], outputs=[summary_text, summary_audio] ) demo.launch()