File size: 1,878 Bytes
0e6d852
 
 
 
 
 
 
51ff413
0e6d852
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51ff413
0e6d852
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""

    This class implments a Gradio interface to generate an audio summary 
    from the abstract of a PDF article.

"""

import gradio as gr
from gradio_pdf import PDF
from pdf_processor import summarize_abstract
from audio_processor import generate_audio

# Given a PDF file path, this function returns an audio summary of the abstract
def abstract_to_audio(pdf_path):
    """ This function retuns the audio generated from the summary of the abstract of PDF file.
    
    Args: (pdf_path  : str)
    """
    summarized_abstract = summarize_abstract(pdf_path)
    audio, sampling_rate = generate_audio(summarized_abstract)
    return sampling_rate, audio.T


with gr.Blocks() as abstract_audio:
   gr.Markdown("""
               # PDF abstract audio summarize
               Create an audio summary of the Abstract of the uploaded article.""")
   
   with gr.Row():
       pdf_input = PDF(label="PDF File ...", interactive=True)
       audio_output = gr.Audio(label="Audio Summary ...")
      
   audio_abstract_button = gr.Button("Generate audio summary") 
   audio_abstract_button.click(abstract_to_audio, inputs=pdf_input, outputs=audio_output)

   gr.Examples(
            examples=["Article 11 Hidden Technical Debt in Machine Learning Systems.pdf"],
            inputs=pdf_input,
            outputs=audio_output,
            fn=abstract_to_audio,
            cache_examples=False,
   )
   with gr.Accordion("Information: "):
       gr.Markdown("This application creates an audio summary of the Abstract of the uploaded article. \n"
                   "Make sure that the uploaded article is in the expected format......\n" 
                   "Please note that the summarization is implemented using facebook/bart-large-cnn with maxlength= 50 to provide a meaningful summary and not \n"
                   "only the first sentence.")
       
abstract_audio.launch()