Spaces:
Sleeping
Sleeping
Commit
·
520e96b
1
Parent(s):
9b3a68b
Update app.py
Browse files
app.py
CHANGED
@@ -11,10 +11,11 @@ model = BartForConditionalGeneration.from_pretrained('facebook/bart-large-cnn')
|
|
11 |
synthesiser = pipeline("text-to-speech", "suno/bark")
|
12 |
|
13 |
# Function to extract abstract from PDF
|
14 |
-
def extract_abstract(
|
15 |
-
#
|
16 |
-
pdf_bytes =
|
17 |
|
|
|
18 |
doc = fitz.open(stream=pdf_bytes, filetype="pdf")
|
19 |
first_page = doc[0].get_text()
|
20 |
start_idx = first_page.lower().find("abstract")
|
@@ -25,8 +26,8 @@ def extract_abstract(pdf_content):
|
|
25 |
return "Abstract not found or 'Introduction' not found in the first page."
|
26 |
|
27 |
# Function to process text (summarize and convert to speech)
|
28 |
-
def process_text(
|
29 |
-
abstract_text = extract_abstract(
|
30 |
|
31 |
# Generate summary
|
32 |
inputs = tokenizer([abstract_text], max_length=1024, return_tensors='pt', truncation=True)
|
|
|
11 |
synthesiser = pipeline("text-to-speech", "suno/bark")
|
12 |
|
13 |
# Function to extract abstract from PDF
|
14 |
+
def extract_abstract(pdf_file):
|
15 |
+
# Read PDF file
|
16 |
+
pdf_bytes = pdf_file.read()
|
17 |
|
18 |
+
# Open PDF with fitz
|
19 |
doc = fitz.open(stream=pdf_bytes, filetype="pdf")
|
20 |
first_page = doc[0].get_text()
|
21 |
start_idx = first_page.lower().find("abstract")
|
|
|
26 |
return "Abstract not found or 'Introduction' not found in the first page."
|
27 |
|
28 |
# Function to process text (summarize and convert to speech)
|
29 |
+
def process_text(pdf_file):
|
30 |
+
abstract_text = extract_abstract(pdf_file)
|
31 |
|
32 |
# Generate summary
|
33 |
inputs = tokenizer([abstract_text], max_length=1024, return_tensors='pt', truncation=True)
|