Antoniskaraolis commited on
Commit
7fd7e61
1 Parent(s): 7a3d3ad

Delete app_textoutput.py

Browse files
Files changed (1) hide show
  1. app_textoutput.py +0 -36
app_textoutput.py DELETED
@@ -1,36 +0,0 @@
1
- # https://huggingface.co/spaces/Antoniskaraolis/AI_Audio_Processing
2
-
3
- # Here are the imports
4
- import gradio as gr
5
- from PyPDF2 import PdfReader
6
- from transformers import pipeline
7
- from gtts import gTTS
8
- import os
9
-
10
- # Here is the code
11
- def extract_abstract_from_pdf(file):
12
- reader = PdfReader(file.name)
13
- first_page = reader.pages[0]
14
- text = first_page.extract_text()
15
- return text
16
-
17
- def summarize_text(text, model_name='sshleifer/distilbart-cnn-12-6'):
18
- summarizer = pipeline("summarization", model=model_name)
19
- summary = summarizer(text, max_length=75, min_length=20, do_sample=False)
20
- first_sentence = summary[0]['summary_text'].split('.')[0] + '.'
21
- return first_sentence
22
-
23
- def process_pdf(file):
24
- abstract = extract_abstract_from_pdf(file)
25
- summary = summarize_text(abstract)
26
- return summary
27
-
28
- iface = gr.Interface(
29
- fn=process_pdf,
30
- inputs=gr.File(label="Upload PDF"),
31
- outputs="text",
32
- title="PDF Abstract Summarizer",
33
- description="This app summarizes the abstract from a PDF. Please upload a PDF with an abstract."
34
- )
35
-
36
- iface.launch()