#!/usr/bin/env python import gradio as gr from urdu_punkt import Urdu from multi_lingual import MultiLingual from langdetect import detect, DetectorFactory DetectorFactory.seed = 42 ur_model = Urdu() multi_model = MultiLingual() title = "SELMA H2020 — Multilingual Punctuation & Casing Prediction" description = "Supported languages are: Amharic, Bengali, German, English, Spanish, French, Hindi, Italian, Latvian, Pashto, Portuguese, Russian, Tamil and Urdu." article = "

SELMA-H2020

" text_input = gr.Textbox(label="Enter some text") result_output = gr.Textbox(label="Result") def punctuate(text: str) -> str: if detect(text) == "ur": return ur_model.punctuate(text) else: return multi_model.punctuate(text) def run(): io = gr.Interface( fn=punctuate, title=title, description=description, article=article, theme=gr.themes.Soft(), inputs=text_input, outputs=result_output, allow_flagging="never", css="footer {visibility: hidden}", ) io.launch(server_name="0.0.0.0", server_port=7860) if __name__ == "__main__": run()