File size: 1,951 Bytes
9bad7f1
4f48d78
1d0824d
 
9bad7f1
c3fdbd7
9bad7f1
 
 
 
0f1d7f7
9bad7f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1d0824d
 
 
 
 
9bad7f1
 
c3fdbd7
9bad7f1
b3e9e6d
9bad7f1
 
 
 
 
 
 
 
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
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()