Spaces:
Running
Running
import gradio as gr | |
from transformers import pipeline | |
# Load model once | |
model = pipeline("text2text-generation", model = "crossroderick/dalat5") | |
def transliterate(text: str) -> str: | |
""" | |
Prediction function. | |
""" | |
if text.strip() == "": | |
return "" | |
input_text = f"Cyrillic2Latin: {text.strip()}" | |
output = model(input_text, max_length = 128, do_sample = False)[0]["generated_text"] | |
return output.strip() | |
# App description (Markdown style) | |
description = """ | |
## Қазақша кириллица → латын графикасының транслитераторы / Kazakh Cyrillic → Latin Script Transliterator | |
--- | |
**[EN]** | |
DalaT5 is a T5-based model trained to convert natural Kazakh written in **Cyrillic** into fluent **Latin script**, based on the official 2021 alphabet reform of Kazakhstan. | |
This model is offered as a cultural gesture of respect and curiosity. It accepts modern Kazakh as people write it today - and answers in the language of its future. | |
**[KZ]** | |
DalaT5 - **кириллицада** жазылған табиғи қазақ тілін еркін **латын графикасына** ауыстыру үшін дайындалған T5 негізіндегі модель, Қазақстанның 2021 жылғы ресми әліпби реформасына негізделген. | |
Бұл модель құрмет пен қызығушылықтың мәдени қимылы ретінде ұсынылады. Ол қазіргі қазақ тілін бүгінгі адамдар қалай жазады, солай қабылдайды - және оның болашағының тілінде жауап береді. | |
🧠 [Model link](https://huggingface.co/crossroderick/dalat5) | |
🔤 [Kazakhstan 2021 alphabet reform](https://astanatimes.com/2021/02/kazakhstan-presents-new-latin-alphabet-plans-gradual-transition-through-2031/) | |
""" | |
# Interface | |
demo = gr.Interface( | |
fn = transliterate, | |
inputs = gr.Textbox( | |
label = "Қазақ тілінде теріңіз (кириллица) / Type in Kazakh (Cyrillic script)", | |
placeholder = "Мен қазақ тілінде сөйлеймін.", | |
lines = 6 | |
), | |
outputs = gr.Textbox( | |
label = "Латын графикасының шығуы / Latin script output" | |
), | |
title = "🇰🇿 DalaT5", | |
description = description, | |
theme = "default", | |
flagging_mode = "never" | |
) | |
if __name__ == "__main__": | |
demo.launch(share = True) | |