Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -68,7 +68,10 @@ def process_pdf(file):
|
|
| 68 |
finally:
|
| 69 |
os.remove(temp_pdf_path)
|
| 70 |
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
|
| 74 |
# Function to generate thumbnail from PDF
|
|
@@ -185,8 +188,7 @@ elif selection == "PDF Transcriber":
|
|
| 185 |
st.success("Text extraction complete!")
|
| 186 |
st.text_area("Extracted Text", open(output_file).read(), height=400)
|
| 187 |
output_file_name = generate_unique_filename(uploaded_file.name, "(T)", ".txt")
|
| 188 |
-
|
| 189 |
-
download_file(output_file, output_file_name, "text/plain")
|
| 190 |
os.remove(output_file)
|
| 191 |
else:
|
| 192 |
st.error("Could not process the PDF, please try again")
|
|
|
|
| 68 |
finally:
|
| 69 |
os.remove(temp_pdf_path)
|
| 70 |
|
| 71 |
+
with tempfile.NamedTemporaryFile(suffix=".txt", delete=False) as temp_txt:
|
| 72 |
+
temp_txt.write(text.encode("utf-8"))
|
| 73 |
+
temp_txt_path = temp_txt.name
|
| 74 |
+
return temp_txt_path
|
| 75 |
|
| 76 |
|
| 77 |
# Function to generate thumbnail from PDF
|
|
|
|
| 188 |
st.success("Text extraction complete!")
|
| 189 |
st.text_area("Extracted Text", open(output_file).read(), height=400)
|
| 190 |
output_file_name = generate_unique_filename(uploaded_file.name, "(T)", ".txt")
|
| 191 |
+
download_file(output_file, output_file_name, "text/plain")
|
|
|
|
| 192 |
os.remove(output_file)
|
| 193 |
else:
|
| 194 |
st.error("Could not process the PDF, please try again")
|