Spaces:
Sleeping
Sleeping
Ari
commited on
Commit
•
f6ccaae
1
Parent(s):
1f99276
Update app.py
Browse files
app.py
CHANGED
@@ -77,24 +77,34 @@ def pdf_to_text(text, PDF, min_length=20):
|
|
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
|
81 |
-
sample_document_path = "Marbury v. Madison.pdf"
|
82 |
|
83 |
-
#
|
84 |
-
|
|
|
85 |
|
86 |
# Gradio interface
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
)
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
|
99 |
if __name__ == "__main__":
|
100 |
iface.launch()
|
|
|
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)
|
81 |
+
sample_document_path = "Marbury v. Madison.pdf"
|
82 |
|
83 |
+
# Simulate file-like object for Gradio
|
84 |
+
with open(sample_document_path, "rb") as f:
|
85 |
+
return pdf_to_text("", f, min_length)
|
86 |
|
87 |
# Gradio interface
|
88 |
+
with gr.Blocks() as iface:
|
89 |
+
# Create a button to process the sample document
|
90 |
+
with gr.Row():
|
91 |
+
process_sample_button = gr.Button("Process Sample Legal Document")
|
92 |
+
|
93 |
+
# Create the regular input interface
|
94 |
+
text_input = gr.Textbox(label="Input Text")
|
95 |
+
file_input = gr.File(label="Upload PDF or DOCX")
|
96 |
+
slider = gr.Slider(minimum=10, maximum=100, step=10, value=20, label="Summary Minimum Length")
|
97 |
+
|
98 |
+
# Outputs
|
99 |
+
audio_output = gr.Audio(label="Generated Audio")
|
100 |
+
summary_output = gr.Textbox(label="Generated Summary")
|
101 |
+
pdf_output = gr.File(label="Summary PDF")
|
102 |
+
|
103 |
+
# Define the action for the button click to process the preloaded document
|
104 |
+
process_sample_button.click(fn=process_sample_document, inputs=slider, outputs=[audio_output, summary_output, pdf_output])
|
105 |
+
|
106 |
+
# Define the action for the regular file processing
|
107 |
+
file_input.change(fn=pdf_to_text, inputs=[text_input, file_input, slider], outputs=[audio_output, summary_output, pdf_output])
|
108 |
|
109 |
if __name__ == "__main__":
|
110 |
iface.launch()
|