akhil2808 commited on
Commit
e496127
·
verified ·
1 Parent(s): 38e2102

Upload 2 files

Browse files
Files changed (2) hide show
  1. app (1).py +38 -0
  2. requirements (1).txt +2 -0
app (1).py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from ai4bharat.transliteration import XlitEngine
3
+
4
+ # Function for transliteration
5
+ def transliterate_to_kannada(user_input):
6
+ # Create an instance of the transliteration engine
7
+ e = XlitEngine(src_script_type="en", beam_width=5, rescore=False)
8
+
9
+ # Perform transliteration
10
+ out = e.translit_sentence(user_input, lang_code="kn")
11
+ return out
12
+
13
+ # Set up the Gradio interface
14
+ with gr.Blocks() as demo:
15
+ gr.Markdown("""
16
+ # English to Kannada Transliteration
17
+
18
+ This tool allows you to convert English sentences into Kannada transliterations.
19
+
20
+ **How to use:**
21
+ 1. Enter a sentence in English in the text box.
22
+ 2. Click "Transliterate" to see the Kannada output.
23
+ """)
24
+
25
+ # Create input field for user sentence
26
+ user_input = gr.Textbox(label="Enter the sentence in English:", placeholder="e.g., Hello, how are you?")
27
+
28
+ # Output area for transliterated text
29
+ transliterated_output = gr.Textbox(label="Transliterated Output (Kannada):", placeholder="Result will be shown here")
30
+
31
+ # Button to trigger the transliteration
32
+ submit_button = gr.Button("Transliterate")
33
+
34
+ # Define the button action
35
+ submit_button.click(fn=transliterate_to_kannada, inputs=user_input, outputs=transliterated_output)
36
+
37
+ # Launch the Gradio interface
38
+ demo.launch(share=True, inbrowser=True)
requirements (1).txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ ai4bharat-transliteration
2
+ gradio