kusht55's picture
Create app.py
981756a verified
import gradio as gr
from deepmultilingualpunctuation import PunctuationModel
def punctuate_text(input_text):
# Load the pre-trained model
model = PunctuationModel('ModelsLab/punctuate-indic-v1')
# Restore punctuation
result = model.restore_punctuation(input_text)
return result
# Define the Gradio interface
def main():
with gr.Blocks() as interface:
gr.Markdown("""# Punctuation Restorer for Indic Languages
Enter your unpunctuated text in the box below, and this tool will restore punctuation for better readability.
""")
# Input text box
input_text = gr.Textbox(label="Enter your text", placeholder="Type your unpunctuated text here...")
# Output text box
output_text = gr.Textbox(label="Punctuated Text", interactive=False)
# Button to trigger punctuation
submit_button = gr.Button("Punctuate Text")
# Define the interaction
submit_button.click(fn=punctuate_text, inputs=input_text, outputs=output_text)
interface.launch()
if __name__ == "__main__":
main()