Spaces:
Running
Running
Commit
·
0cdfeaa
1
Parent(s):
962d09d
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,10 +11,7 @@ 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 |
-
# Access the byte content of the uploaded file
|
| 16 |
-
pdf_bytes = pdf_file["data"]
|
| 17 |
-
|
| 18 |
# Open PDF with fitz
|
| 19 |
doc = fitz.open(stream=pdf_bytes, filetype="pdf")
|
| 20 |
first_page = doc[0].get_text()
|
|
@@ -26,8 +23,10 @@ def extract_abstract(pdf_file):
|
|
| 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(
|
| 30 |
-
|
|
|
|
|
|
|
| 31 |
|
| 32 |
# Generate summary
|
| 33 |
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_bytes):
|
|
|
|
|
|
|
|
|
|
| 15 |
# Open PDF with fitz
|
| 16 |
doc = fitz.open(stream=pdf_bytes, filetype="pdf")
|
| 17 |
first_page = doc[0].get_text()
|
|
|
|
| 23 |
return "Abstract not found or 'Introduction' not found in the first page."
|
| 24 |
|
| 25 |
# Function to process text (summarize and convert to speech)
|
| 26 |
+
def process_text(uploaded_file):
|
| 27 |
+
# Extract the file data (byte content) from the uploaded file
|
| 28 |
+
pdf_bytes = uploaded_file["data"]
|
| 29 |
+
abstract_text = extract_abstract(pdf_bytes)
|
| 30 |
|
| 31 |
# Generate summary
|
| 32 |
inputs = tokenizer([abstract_text], max_length=1024, return_tensors='pt', truncation=True)
|