File size: 2,639 Bytes
f63b211
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9884995
0bfbafb
 
 
f63b211
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0bfbafb
842eb49
 
 
 
f63b211
51745ac
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import gradio as gr
from ai4bharat.transliteration import XlitEngine

# Function for transliteration
def transliterate_to_kashmiri(user_input):
    # Create an instance of the transliteration engine
    e = XlitEngine(src_script_type="en", beam_width=5, rescore=False)  # Adjusted beam_width for faster performance
    
    # Perform transliteration
    out = e.translit_sentence(user_input, lang_code="ks")
    
    return out

# Examples for display in the interface
examples = [
    ["Hello, how are you?", "ہیلؤ، ہاؤ آر یو؟"],
    ["Good morning!", "گڈ مارننگ!"],
    ["What is your name?", "تُہند ناو کِیہ چھ؟"],
    ["I am feeling great today!", "آج سچِہ زبردست ہوں!"],
    ["See you later!", "بَعِد چُھٹ چھُ؟"]
]

# Path to your before and after image files
before_image_path = "https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/cPHY7iEpErxAEakPBWvKR.png"  # Replace with actual path to your "before" image
after_image_path = "https://cdn-uploads.huggingface.co/production/uploads/66afb3f1eaf3e876595627bf/TZNNe4XJcO4qzoFfug18v.png"    # Replace with actual path to your "after" image

# Set up the Gradio interface
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.
    """)
    
    # Display the examples
    gr.Markdown("### Enter your own sentence:")
    
    # Create input field for user sentence
    user_input = gr.Textbox(label="Enter the sentence in English:", placeholder="e.g., Hello, how are you?")
    
    # Output area for transliterated text
    transliterated_output = gr.Textbox(label="Transliterated Output (Kashmiri):", placeholder="Result will be shown here")
    
    # Button to trigger the transliteration
    submit_button = gr.Button("Transliterate")
    
    # Define the button action
    submit_button.click(fn=transliterate_to_kashmiri, inputs=user_input, outputs=transliterated_output)
    
    # Add examples to the interface for easy testing
    gr.Examples(examples=examples, inputs=user_input, outputs=transliterated_output)

    # Display the "Before" and "After" images
    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)

# Launch the Gradio interface
demo.launch(share=True, inbrowser=True)