|
import gradio as gr |
|
from ai4bharat.transliteration import XlitEngine |
|
|
|
|
|
def transliterate_to_kashmiri(user_input): |
|
|
|
e = XlitEngine(src_script_type="en", beam_width=5, rescore=False) |
|
|
|
|
|
out = e.translit_sentence(user_input, lang_code="ks") |
|
|
|
return out |
|
|
|
|
|
examples = [ |
|
["Hello, how are you?", "ہیلؤ، ہاؤ آر یو؟"], |
|
["Good morning!", "گڈ مارننگ!"], |
|
["What is your name?", "تُہند ناو کِیہ چھ؟"], |
|
["I am feeling great today!", "آج سچِہ زبردست ہوں!"], |
|
["See you later!", "بَعِد چُھٹ چھُ؟"] |
|
] |
|
|
|
|
|
before_image_path = "https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/cPHY7iEpErxAEakPBWvKR.png" |
|
after_image_path = "https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/TZNNe4XJcO4qzoFfug18v.png" |
|
|
|
|
|
with gr.Blocks() as demo: |
|
gr.Markdown(""" |
|
# English to Kashmiri Transliteration |
|
This tool allows you to convert English sentences into Kashmiri transliterations. |
|
|
|
**How to use:** |
|
1. Enter a sentence in English in the text box. |
|
2. Click "Transliterate" to see the Kashmiri output. |
|
""") |
|
|
|
|
|
gr.Markdown("### Enter your own sentence:") |
|
|
|
|
|
user_input = gr.Textbox(label="Enter the sentence in English:", placeholder="e.g., Hello, how are you?") |
|
|
|
|
|
transliterated_output = gr.Textbox(label="Transliterated Output (Kashmiri):", placeholder="Result will be shown here") |
|
|
|
|
|
submit_button = gr.Button("Transliterate") |
|
|
|
|
|
submit_button.click(fn=transliterate_to_kashmiri, inputs=user_input, outputs=transliterated_output) |
|
|
|
|
|
gr.Examples(examples=examples, inputs=user_input, outputs=transliterated_output) |
|
|
|
|
|
with gr.Row(): |
|
gr.Image(before_image_path, label="Before", elem_id="before-image", show_label=True) |
|
gr.Image(after_image_path, label="After", elem_id="after-image", show_label=True) |
|
|
|
|
|
demo.launch(share=True, inbrowser=True) |
|
|