Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import requests
|
|
3 |
from fpdf import FPDF
|
4 |
import nltk
|
5 |
import os
|
|
|
6 |
from nltk.tokenize import sent_tokenize
|
7 |
import random
|
8 |
|
@@ -95,11 +96,10 @@ def create_pdf(transcript, long_questions, short_questions, mcqs):
|
|
95 |
pdf.multi_cell(0, 10, f" - {option}")
|
96 |
pdf.multi_cell(0, 10, f"Answer: {mcq['answer']}\n")
|
97 |
|
98 |
-
#
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
pdf.output(pdf_path)
|
103 |
|
104 |
return pdf_path
|
105 |
|
@@ -111,10 +111,10 @@ def create_error_pdf(message):
|
|
111 |
pdf.set_font("Arial", "", 12)
|
112 |
pdf.multi_cell(0, 10, message)
|
113 |
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
return error_pdf_path
|
119 |
|
120 |
iface = gr.Interface(
|
@@ -124,4 +124,4 @@ iface = gr.Interface(
|
|
124 |
title="Voice to Text Converter and Notes Generator",
|
125 |
)
|
126 |
|
127 |
-
iface.
|
|
|
3 |
from fpdf import FPDF
|
4 |
import nltk
|
5 |
import os
|
6 |
+
import tempfile
|
7 |
from nltk.tokenize import sent_tokenize
|
8 |
import random
|
9 |
|
|
|
96 |
pdf.multi_cell(0, 10, f" - {option}")
|
97 |
pdf.multi_cell(0, 10, f"Answer: {mcq['answer']}\n")
|
98 |
|
99 |
+
# Save the PDF in a temporary directory
|
100 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") as temp_pdf:
|
101 |
+
pdf.output(temp_pdf.name)
|
102 |
+
pdf_path = temp_pdf.name
|
|
|
103 |
|
104 |
return pdf_path
|
105 |
|
|
|
111 |
pdf.set_font("Arial", "", 12)
|
112 |
pdf.multi_cell(0, 10, message)
|
113 |
|
114 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") as temp_pdf:
|
115 |
+
pdf.output(temp_pdf.name)
|
116 |
+
error_pdf_path = temp_pdf.name
|
117 |
+
|
118 |
return error_pdf_path
|
119 |
|
120 |
iface = gr.Interface(
|
|
|
124 |
title="Voice to Text Converter and Notes Generator",
|
125 |
)
|
126 |
|
127 |
+
iface.l
|