Spaces:
Sleeping
Sleeping
Commit
·
b146e73
1
Parent(s):
1158c4e
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
def txt_to_text(txt_file_cmpt):
|
| 3 |
+
with open(txt_file_cmpt.name, 'r') as file:
|
| 4 |
+
content = file.read()
|
| 5 |
+
return content
|
| 6 |
+
with gr.Blocks() as demo:
|
| 7 |
+
with gr.Row():
|
| 8 |
+
with gr.Column(variant='panel', scale=1):
|
| 9 |
+
txt_file_cmpt = gr.File(label="Select .txt File", file_count="single", file_types=[".txt"],
|
| 10 |
+
height=150)
|
| 11 |
+
with gr.Column(variant='panel', scale=4):
|
| 12 |
+
with gr.Row():
|
| 13 |
+
with gr.Column(variant='panel'):
|
| 14 |
+
text_tbox = gr.Textbox(label=".txt Text", interactive=True,
|
| 15 |
+
info="Upload .pdf or paste in text. Shift-Enter to add a line")
|
| 16 |
+
txt_file_cmpt.change(txt_to_text, inputs=[txt_file_cmpt],
|
| 17 |
+
outputs=[text_tbox])
|
| 18 |
+
demo.launch()
|