Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from deepmultilingualpunctuation import PunctuationModel
|
3 |
+
|
4 |
+
def punctuate_text(input_text):
|
5 |
+
# Load the pre-trained model
|
6 |
+
model = PunctuationModel('ModelsLab/punctuate-indic-v1')
|
7 |
+
# Restore punctuation
|
8 |
+
result = model.restore_punctuation(input_text)
|
9 |
+
return result
|
10 |
+
|
11 |
+
# Define the Gradio interface
|
12 |
+
def main():
|
13 |
+
with gr.Blocks() as interface:
|
14 |
+
gr.Markdown("""# Punctuation Restorer for Indic Languages
|
15 |
+
Enter your unpunctuated text in the box below, and this tool will restore punctuation for better readability.
|
16 |
+
""")
|
17 |
+
|
18 |
+
# Input text box
|
19 |
+
input_text = gr.Textbox(label="Enter your text", placeholder="Type your unpunctuated text here...")
|
20 |
+
|
21 |
+
# Output text box
|
22 |
+
output_text = gr.Textbox(label="Punctuated Text", interactive=False)
|
23 |
+
|
24 |
+
# Button to trigger punctuation
|
25 |
+
submit_button = gr.Button("Punctuate Text")
|
26 |
+
|
27 |
+
# Define the interaction
|
28 |
+
submit_button.click(fn=punctuate_text, inputs=input_text, outputs=output_text)
|
29 |
+
|
30 |
+
interface.launch()
|
31 |
+
|
32 |
+
if __name__ == "__main__":
|
33 |
+
main()
|