ali121300 commited on
Commit
40644a4
·
verified ·
1 Parent(s): 2a29fa7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -81,8 +81,10 @@ def handle_userinput(user_question:str):
81
  st.write("پاسخ ربات: "+result)
82
 
83
  #############################################################################################################
84
- def read_pdf_pr_en(pdf_reader):
85
  from deep_translator import GoogleTranslator
 
 
86
  full_text = ""
87
  for page in pdf_reader.pages:
88
  page_pdf=page.extract_text()
@@ -126,8 +128,12 @@ def main():
126
  pdf_docs = st.file_uploader(
127
  "Upload your PDFs here and click on 'Process'", accept_multiple_files=True
128
  )
129
- full_text=read_pdf_pr_en(pdf_reader=pdf_docs)
130
- pdf_docs=full_text
 
 
 
 
131
 
132
  if st.button("Process"):
133
  with st.spinner("Processing"):
 
81
  st.write("پاسخ ربات: "+result)
82
 
83
  #############################################################################################################
84
+ def read_pdf_pr_en(pdf_file_path):
85
  from deep_translator import GoogleTranslator
86
+ with open(pdf_file_path, 'rb') as pdf_file:
87
+ pdf_reader = PyPDF2.PdfReader(pdf_file)
88
  full_text = ""
89
  for page in pdf_reader.pages:
90
  page_pdf=page.extract_text()
 
128
  pdf_docs = st.file_uploader(
129
  "Upload your PDFs here and click on 'Process'", accept_multiple_files=True
130
  )
131
+ if pdf_docs:
132
+ # مسیر فایل آپلود شده را بدست آورید
133
+ file_path = pdf_docs[0].name
134
+ st.write(f"Uploaded file path: {file_path}")
135
+ #full_text=read_pdf_pr_en(pdf_reader=pdf_docs)
136
+ #pdf_docs=full_text
137
 
138
  if st.button("Process"):
139
  with st.spinner("Processing"):