File size: 1,113 Bytes
981756a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
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()
|