Spaces:
Running
Running
Update Summarization/app.py
Browse files- Summarization/app.py +5 -12
Summarization/app.py
CHANGED
@@ -279,14 +279,8 @@ def text_to_speech(text: str):
|
|
279 |
except Exception:
|
280 |
return ""
|
281 |
|
282 |
-
def create_pdf(summary: str, filename: str)
|
283 |
try:
|
284 |
-
safe_dir = os.path.join(tempfile.gettempdir(), "aidan_files")
|
285 |
-
os.makedirs(safe_dir, exist_ok=True)
|
286 |
-
|
287 |
-
safe_filename = f"{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}_{filename}.pdf"
|
288 |
-
safe_path = os.path.join(safe_dir, safe_filename)
|
289 |
-
|
290 |
pdf = FPDF()
|
291 |
pdf.add_page()
|
292 |
pdf.set_font("Arial", 'B', 16)
|
@@ -296,11 +290,10 @@ def create_pdf(summary: str, filename: str) -> str:
|
|
296 |
pdf.ln(10)
|
297 |
pdf.set_font("Arial", size=10)
|
298 |
pdf.multi_cell(0, 10, txt=summary)
|
299 |
-
|
300 |
-
pdf.output(
|
301 |
-
return
|
302 |
-
except Exception
|
303 |
-
print(f"[PDF ERROR] {e}")
|
304 |
return ""
|
305 |
|
306 |
|
|
|
279 |
except Exception:
|
280 |
return ""
|
281 |
|
282 |
+
def create_pdf(summary: str, filename: str):
|
283 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
pdf = FPDF()
|
285 |
pdf.add_page()
|
286 |
pdf.set_font("Arial", 'B', 16)
|
|
|
290 |
pdf.ln(10)
|
291 |
pdf.set_font("Arial", size=10)
|
292 |
pdf.multi_cell(0, 10, txt=summary)
|
293 |
+
temp_pdf = tempfile.NamedTemporaryFile(delete=False, suffix=".pdf")
|
294 |
+
pdf.output(temp_pdf.name)
|
295 |
+
return temp_pdf.name
|
296 |
+
except Exception:
|
|
|
297 |
return ""
|
298 |
|
299 |
|