Rajut commited on
Commit
ee2694e
1 Parent(s): e077868

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -64,7 +64,12 @@ def translate_summary(summary, lang):
64
 
65
  # Function to read PDF and summarize and translate chunk by chunk
66
  def summarize_and_translate_pdf(uploaded_file, lang):
67
- doc = fitz.open(uploaded_file)
 
 
 
 
 
68
  total_chunks = len(doc)
69
  chunks = []
70
 
@@ -79,6 +84,7 @@ def summarize_and_translate_pdf(uploaded_file, lang):
79
 
80
  return translated_chunks
81
 
 
82
  # Streamlit UI
83
  st.title("PDF Summarization and Translation")
84
 
 
64
 
65
  # Function to read PDF and summarize and translate chunk by chunk
66
  def summarize_and_translate_pdf(uploaded_file, lang):
67
+ try:
68
+ doc = fitz.open(stream=uploaded_file.read(), filetype="pdf")
69
+ except FileNotFoundError:
70
+ st.error("File not found. Please make sure the file path is correct.")
71
+ return []
72
+
73
  total_chunks = len(doc)
74
  chunks = []
75
 
 
84
 
85
  return translated_chunks
86
 
87
+
88
  # Streamlit UI
89
  st.title("PDF Summarization and Translation")
90