Spaces:
Sleeping
Sleeping
Ari
commited on
Commit
•
6de4d60
1
Parent(s):
4e50c5b
Update app.py
Browse files
app.py
CHANGED
@@ -75,12 +75,26 @@ def pdf_to_text(text, PDF, min_length=20):
|
|
75 |
except Exception as e:
|
76 |
return None, f"An error occurred: {str(e)}", None
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
# Gradio interface
|
79 |
iface = gr.Interface(
|
80 |
fn=pdf_to_text,
|
81 |
inputs=[gr.Textbox(label="Input Text"), gr.File(label="Upload PDF or DOCX"), gr.Slider(minimum=10, maximum=100, step=10, value=20, label="Summary Minimum Length")],
|
82 |
-
outputs=[gr.Audio(label="Generated Audio"), gr.Textbox(label="Generated Summary"), gr.File(label="Summary PDF")]
|
|
|
|
|
83 |
)
|
84 |
|
|
|
|
|
|
|
|
|
85 |
if __name__ == "__main__":
|
86 |
iface.launch()
|
|
|
75 |
except Exception as e:
|
76 |
return None, f"An error occurred: {str(e)}", None
|
77 |
|
78 |
+
# Function to process the preloaded document
|
79 |
+
def process_sample_document(min_length=20):
|
80 |
+
# Replace this with the path to your preloaded legal document (PDF or DOCX)
|
81 |
+
sample_document_path = "sample_legal_document.pdf" # Replace with your file's path
|
82 |
+
|
83 |
+
# Use the same processing function to summarize the preloaded document
|
84 |
+
return pdf_to_text("", sample_document_path, min_length)
|
85 |
+
|
86 |
# Gradio interface
|
87 |
iface = gr.Interface(
|
88 |
fn=pdf_to_text,
|
89 |
inputs=[gr.Textbox(label="Input Text"), gr.File(label="Upload PDF or DOCX"), gr.Slider(minimum=10, maximum=100, step=10, value=20, label="Summary Minimum Length")],
|
90 |
+
outputs=[gr.Audio(label="Generated Audio"), gr.Textbox(label="Generated Summary"), gr.File(label="Summary PDF")],
|
91 |
+
title="Legal Document Summarizer",
|
92 |
+
description="Upload a legal document in PDF or DOCX format to generate a summary.",
|
93 |
)
|
94 |
|
95 |
+
# Add a button for the sample document
|
96 |
+
iface.add_component(gr.Button("Process Sample Legal Document", elem_id="process_sample_document", interactive=True))
|
97 |
+
iface.set_event_listener("process_sample_document", process_sample_document)
|
98 |
+
|
99 |
if __name__ == "__main__":
|
100 |
iface.launch()
|