tejovanth commited on
Commit
8723dfc
·
verified ·
1 Parent(s): 7116300

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -8
app.py CHANGED
@@ -9,11 +9,9 @@ import io
9
  summarizer = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6")
10
 
11
  # Function to extract text from different file types
12
- def extract_text(file_obj):
13
  try:
14
- # Read the file content
15
- file_bytes = file_obj.read()
16
- file_obj.seek(0)
17
  header = file_bytes[:4]
18
 
19
  # Determine file type based on magic numbers
@@ -40,8 +38,8 @@ def extract_text(file_obj):
40
  return f"❌ Error reading file: {str(e)}"
41
 
42
  # Summarize the extracted text
43
- def summarize_file(file_obj):
44
- text = extract_text(file_obj)
45
  if not text or len(text.strip()) == 0:
46
  return "❌ No text found in the uploaded file."
47
 
@@ -62,7 +60,5 @@ demo = gr.Interface(
62
  demo.launch()
63
 
64
 
65
-
66
-
67
 
68
 
 
9
  summarizer = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6")
10
 
11
  # Function to extract text from different file types
12
+ def extract_text(file_bytes):
13
  try:
14
+ # file_bytes is already a bytes object
 
 
15
  header = file_bytes[:4]
16
 
17
  # Determine file type based on magic numbers
 
38
  return f"❌ Error reading file: {str(e)}"
39
 
40
  # Summarize the extracted text
41
+ def summarize_file(file_bytes):
42
+ text = extract_text(file_bytes)
43
  if not text or len(text.strip()) == 0:
44
  return "❌ No text found in the uploaded file."
45
 
 
60
  demo.launch()
61
 
62
 
 
 
63
 
64