amendolajine commited on
Commit
ec7206a
·
1 Parent(s): 41dd0e4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -24,11 +24,19 @@ def extract_abstract(pdf_bytes):
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)
33
  #def process_text(uploaded_file):
34
  # Extract the file data (byte content) from the uploaded file
@@ -38,8 +46,6 @@ def process_text(uploaded_file):
38
  # else:
39
  # return "File content could not be retrieved", None
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)
 
24
 
25
  # Function to process text (summarize and convert to speech)
26
  def process_text(uploaded_file):
27
+ # Diagnostic print statements
28
+ print(f"Uploaded file type: {type(uploaded_file)}")
29
+ if isinstance(uploaded_file, dict):
30
+ print("Uploaded file is a dictionary.")
31
+ print(f"Keys available: {uploaded_file.keys()}")
32
+
33
+ # Assuming uploaded_file is a dictionary and contains 'data' key
34
+ try:
35
+ pdf_bytes = uploaded_file["data"]
36
+ except (TypeError, KeyError):
37
+ print("Error accessing 'data' key in uploaded_file")
38
+ return "File content could not be retrieved", None
39
 
 
40
  # Function to process text (summarize and convert to speech)
41
  #def process_text(uploaded_file):
42
  # Extract the file data (byte content) from the uploaded file
 
46
  # else:
47
  # return "File content could not be retrieved", None
48
 
 
 
49
  # Generate summary
50
  inputs = tokenizer([abstract_text], max_length=1024, return_tensors='pt', truncation=True)
51
  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)