bisoye's picture
Update app.py
3982f38 verified
raw
history blame
2.11 kB
import gradio as gr
from helper_fns import process_files, get_summarization_method
from summarizer import summarize_file
from helper_fns import text_to_speech
def generate_output(method, file):
summary_text = summarize_file(method, file)
audio_summary = text_to_speech(summary_text)
return summary_text, audio_summary
with gr.Blocks() as demo:
with gr.Row():
with gr.Column():
files = gr.UploadButton(
label='Upload Files 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, audio_file]
)
demo.launch()