mrsk1883 commited on
Commit
6900efd
·
1 Parent(s): e9d4bd7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -34,19 +34,21 @@ def extract_abstract_and_summarize(pdf_file):
34
  # Summarize the extracted abstract using the LED-large model with a specific max_length
35
  result = summarizer(abstract_text, max_length=81)
36
 
37
- # Check if 'summary_text' is present in the result
38
  if result and isinstance(result, list) and len(result) > 0:
39
  summary = result[0].get('summary_text', 'Summary not available.')
 
 
40
  else:
41
- summary = "Summary not available."
42
 
43
  # Generate audio
44
- speech = gTTS(text=summary, lang="en")
45
  speech_bytes = BytesIO()
46
  speech.write_to_fp(speech_bytes)
47
 
48
  # Return individual output values
49
- return summary, speech_bytes.getvalue(), abstract_text.strip()
50
 
51
  except Exception as e:
52
  raise Exception(str(e))
 
34
  # Summarize the extracted abstract using the LED-large model with a specific max_length
35
  result = summarizer(abstract_text, max_length=81)
36
 
37
+ # Extract only the first sentence from the summary
38
  if result and isinstance(result, list) and len(result) > 0:
39
  summary = result[0].get('summary_text', 'Summary not available.')
40
+ # Extracting the first sentence
41
+ first_sentence = summary.split('.')[0] + '.'
42
  else:
43
+ first_sentence = "Summary not available."
44
 
45
  # Generate audio
46
+ speech = gTTS(text=first_sentence, lang="en")
47
  speech_bytes = BytesIO()
48
  speech.write_to_fp(speech_bytes)
49
 
50
  # Return individual output values
51
+ return first_sentence, speech_bytes.getvalue(), abstract_text.strip()
52
 
53
  except Exception as e:
54
  raise Exception(str(e))