gianb commited on
Commit
9033ce8
1 Parent(s): d9d9a70

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -14,11 +14,13 @@ from datasets import load_dataset
14
 
15
  from pdfminer.high_level import extract_pages, extract_text
16
 
 
 
17
  summarization = pipeline ('summarization', model = "pszemraj/long-t5-tglobal-base-16384-book-summary")
18
 
19
  def summarize_and_speech(pdf_file):
20
- with open(pdf_file.name, 'rb') as file:
21
- pdf_reader = PyPDF2.PdfFileReader(file)
22
  abstract_text = pdf_reader.pages[0].extract_text()
23
  summary = summarization(abstract_text, max_length=13, min_length=10)[0]['summary_text']
24
 
 
14
 
15
  from pdfminer.high_level import extract_pages, extract_text
16
 
17
+ import io
18
+
19
  summarization = pipeline ('summarization', model = "pszemraj/long-t5-tglobal-base-16384-book-summary")
20
 
21
  def summarize_and_speech(pdf_file):
22
+ pdf_bytes_io = io.BytesIO(pdf_file)
23
+ pdf_reader = PyPDF2.PdfFileReader(pdf_bytes_io)
24
  abstract_text = pdf_reader.pages[0].extract_text()
25
  summary = summarization(abstract_text, max_length=13, min_length=10)[0]['summary_text']
26