Spaces:
Running
Running
Commit
·
41dd0e4
1
Parent(s):
674f46b
Update app.py
Browse files
app.py
CHANGED
@@ -24,17 +24,9 @@ def extract_abstract(pdf_bytes):
|
|
24 |
|
25 |
# Function to process text (summarize and convert to speech)
|
26 |
def process_text(uploaded_file):
|
27 |
-
#
|
28 |
-
|
29 |
-
|
30 |
-
# Check if 'data' key exists
|
31 |
-
if 'data' in uploaded_file:
|
32 |
-
file_info += f", Data type: {type(uploaded_file['data'])}, Data length: {len(uploaded_file['data'])}"
|
33 |
-
else:
|
34 |
-
file_info += ", 'data' key not found"
|
35 |
-
|
36 |
-
# For debugging, return the file info instead of processing the file
|
37 |
-
return file_info, "temp_output.wav"
|
38 |
|
39 |
|
40 |
# Function to process text (summarize and convert to speech)
|
@@ -48,8 +40,6 @@ def process_text(uploaded_file):
|
|
48 |
|
49 |
|
50 |
|
51 |
-
abstract_text = extract_abstract(pdf_bytes)
|
52 |
-
|
53 |
# Generate summary
|
54 |
inputs = tokenizer([abstract_text], max_length=1024, return_tensors='pt', truncation=True)
|
55 |
summary_ids = model.generate(inputs['input_ids'], num_beams=4, max_length=40, min_length=10, length_penalty=2.0, early_stopping=True, no_repeat_ngram_size=2)
|
|
|
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 |
|
32 |
# Function to process text (summarize and convert to speech)
|
|
|
40 |
|
41 |
|
42 |
|
|
|
|
|
43 |
# Generate summary
|
44 |
inputs = tokenizer([abstract_text], max_length=1024, return_tensors='pt', truncation=True)
|
45 |
summary_ids = model.generate(inputs['input_ids'], num_beams=4, max_length=40, min_length=10, length_penalty=2.0, early_stopping=True, no_repeat_ngram_size=2)
|