Mishmosh commited on
Commit
90f1a74
1 Parent(s): 0a416bb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -11
app.py CHANGED
@@ -3,17 +3,14 @@
3
  # The code receives a PDF but doesnt' appear to process it.
4
  # I still need to add the gradio interface output to show the summarized text and play the sound file
5
  import gradio as gr
6
- def process_input(pdf_file):
7
- print("Received PDF File:", pdf_file.name)
8
- # Read the content of the uploaded PDF file
9
- pdf_content = pdf_file.read()
10
- # Save the received PDF content locally
11
- with open("received_pdf.pdf", "wb") as output_file:
12
- output_file.write(pdf_content)
13
- # Return the content of the processed PDF file
14
- return pdf_content
15
-
16
 
 
 
 
 
 
 
 
17
  iface = gr.Interface(
18
  fn=process_input,
19
  inputs=[
@@ -22,8 +19,33 @@ iface = gr.Interface(
22
  label="Hello. This app is called Abstract Summariser and gives a one sentence summary of the input PDF in both written and spoken form. Please upload a PDF file that contains an abstract.",
23
  ),
24
  ],
25
- outputs=None,
26
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  iface.launch(share=True)
28
  #iface.launch()
29
  #python app.py
@@ -336,3 +358,9 @@ with torch.no_grad():
336
  speech = model.generate_speech(inputs["input_ids"], speaker_embeddings, vocoder=vocoder)
337
  Audio(speech, rate=16000)
338
 
 
 
 
 
 
 
 
3
  # The code receives a PDF but doesnt' appear to process it.
4
  # I still need to add the gradio interface output to show the summarized text and play the sound file
5
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
6
 
7
+ # Interface for displaying the summarized text
8
+ summarized_textbox = gr.Textbox(type="text", label="Summarized Text")
9
+
10
+ # Interface for playing the speech
11
+ speech_audio = gr.Audio(type="file", label="Text-to-Speech Audio", element_id="audio_element")
12
+
13
+ # Interface to process input and display results
14
  iface = gr.Interface(
15
  fn=process_input,
16
  inputs=[
 
19
  label="Hello. This app is called Abstract Summariser and gives a one sentence summary of the input PDF in both written and spoken form. Please upload a PDF file that contains an abstract.",
20
  ),
21
  ],
22
+ outputs=[summarized_textbox, speech_audio], # Display the summarized text and audio
23
  )
24
+
25
+
26
+
27
+
28
+ def process_input(pdf_file):
29
+ print("Received PDF File:", pdf_file.name)
30
+ # Read the content of the uploaded PDF file
31
+ pdf_content = pdf_file.read()
32
+ # Save the received PDF content locally
33
+ with open("received_pdf.pdf", "wb") as output_file:
34
+ output_file.write(pdf_content)
35
+ # Return the content of the processed PDF file
36
+ return pdf_content
37
+
38
+ ###commented out latest version
39
+ #iface = gr.Interface(
40
+ # fn=process_input,
41
+ # inputs=[
42
+ # gr.File(
43
+ # type="binary",
44
+ # label="Hello. This app is called Abstract Summariser and gives a one sentence summary of the input PDF in both written and spoken form. Please upload a PDF file that contains an abstract.",
45
+ # ),
46
+ # ],
47
+ # outputs=None,
48
+ #)
49
  iface.launch(share=True)
50
  #iface.launch()
51
  #python app.py
 
358
  speech = model.generate_speech(inputs["input_ids"], speaker_embeddings, vocoder=vocoder)
359
  Audio(speech, rate=16000)
360
 
361
+ #new code
362
+ summarized_text = summarize_abstract(abstract_from_pdf)
363
+ # Set the value of the summarized_textbox
364
+ summarized_textbox.value = summarized_text
365
+
366
+ speech_audio.file = audio_path