Ahmed235 commited on
Commit
d769313
·
verified ·
1 Parent(s): 9e4c3a1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -4,15 +4,18 @@ from transformers import pipeline
4
  import gradio as gr
5
 
6
  def extract_text_from_pptx(file_path):
7
- presentation = Presentation(file_path)
8
-
9
- text = []
10
- for slide_number, slide in enumerate(presentation.slides, start=1):
11
- for shape in slide.shapes:
12
- if hasattr(shape, "text"):
13
- text.append(shape.text)
 
 
 
 
14
 
15
- return "\n".join(text)
16
 
17
  def predict_pptx_content(file_path):
18
  print(f"File path received: {file_path}")
 
4
  import gradio as gr
5
 
6
  def extract_text_from_pptx(file_path):
7
+ try:
8
+ presentation = Presentation(file_path)
9
+ text = []
10
+ for slide_number, slide in enumerate(presentation.slides, start=1):
11
+ for shape in slide.shapes:
12
+ if hasattr(shape, "text"):
13
+ text.append(shape.text)
14
+ return "\n".join(text)
15
+ except Exception as e:
16
+ print(f"Error extracting text from PowerPoint: {e}")
17
+ raise # Re-raise the exception for further investigation
18
 
 
19
 
20
  def predict_pptx_content(file_path):
21
  print(f"File path received: {file_path}")