MohammedNasser commited on
Commit
df2c275
โ€ข
1 Parent(s): d1a5ff6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -13
app.py CHANGED
@@ -18,9 +18,8 @@ from pdf2image import convert_from_path
18
  from huggingface_hub import Repository, login
19
  from huggingface_hub import hf_hub_download
20
  from langchain.schema import Document
21
- from PyPDF2 import PdfReader # Make sure to install PyPDF2 for PDF handling
22
- from langdetect import detect # Install langdetect to detect language
23
-
24
 
25
 
26
  # Load environment variables
@@ -40,10 +39,6 @@ for folder in [UPLOAD_FOLDER, AUDIO_FOLDER]:
40
  if not os.path.exists(folder):
41
  os.makedirs(folder)
42
 
43
-
44
-
45
-
46
-
47
  def load_pdf(file_path):
48
  """Load and preprocess Arabic text from a PDF file."""
49
 
@@ -61,7 +56,7 @@ def load_pdf(file_path):
61
  documents.append(text)
62
  except Exception as e:
63
  print(f"Error processing page {pageNum}: {e}")
64
- documents.append("") # Append empty string for pages where OCR failed
65
 
66
  return documents
67
 
@@ -276,11 +271,11 @@ with gr.Blocks(css=custom_css) as demo:
276
 
277
  with gr.Row():
278
  gr.Markdown("""
279
- #### ุชุนู„ูŠู…ุงุช ู„ุชุญู…ูŠู„ ู…ู„ู PDF
280
- <ul style="list-style-type: disc; color: green; font-size: 12px;">
281
- <li style="color: green; font-size: 12px;">ุชุฃูƒุฏ ู…ู† ุงุฎุชูŠุงุฑ ู…ู„ู PDF.</li>
282
- <li style="color: green; font-size: 12px;">ุญุฌู… ุงู„ู…ู„ู ูŠุฌุจ ุฃู† ูŠูƒูˆู† ุฃู‚ู„ ู…ู† 10 ู…ูŠุฌุงุจุงูŠุช.</li>
283
- <li style="color: green; font-size: 12px;">ูŠุฌุจ ุฃู† ูŠูƒูˆู† ุงู„ู…ุญุชูˆู‰ ุจุงู„ู„ุบุฉ ุงู„ุนุฑุจูŠุฉ.</li>
284
  </ul>""", rtl=True)
285
  pdf_input = gr.File(label="ุงุฎุชุฑ ู…ู„ู PDF")
286
  with gr.Row():
 
18
  from huggingface_hub import Repository, login
19
  from huggingface_hub import hf_hub_download
20
  from langchain.schema import Document
21
+ from PyPDF2 import PdfReader
22
+ from langdetect import detect
 
23
 
24
 
25
  # Load environment variables
 
39
  if not os.path.exists(folder):
40
  os.makedirs(folder)
41
 
 
 
 
 
42
  def load_pdf(file_path):
43
  """Load and preprocess Arabic text from a PDF file."""
44
 
 
56
  documents.append(text)
57
  except Exception as e:
58
  print(f"Error processing page {pageNum}: {e}")
59
+ documents.append("")
60
 
61
  return documents
62
 
 
271
 
272
  with gr.Row():
273
  gr.Markdown("""
274
+
275
+ <ul style="list-style-type: disc;">
276
+ <li style="color: #FF8343; font-size: 12px;">ุชุฃูƒุฏ ู…ู† ุงุฎุชูŠุงุฑ ู…ู„ู PDF.</li>
277
+ <li style="color: #FF8343; font-size: 12px;">ุญุฌู… ุงู„ู…ู„ู ูŠุฌุจ ุฃู† ูŠูƒูˆู† ุฃู‚ู„ ู…ู† 10 ู…ูŠุฌุงุจุงูŠุช.</li>
278
+ <li style="color: #FF8343; font-size: 12px;">ูŠุฌุจ ุฃู† ูŠูƒูˆู† ุงู„ู…ุญุชูˆู‰ ุจุงู„ู„ุบุฉ ุงู„ุนุฑุจูŠุฉ.</li>
279
  </ul>""", rtl=True)
280
  pdf_input = gr.File(label="ุงุฎุชุฑ ู…ู„ู PDF")
281
  with gr.Row():