Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,23 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
-
from indic_transliteration.sanscript import transliterate
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
return hindi_text
|
9 |
|
10 |
demo = gr.Interface(
|
11 |
-
fn=
|
12 |
inputs="text",
|
13 |
outputs="text",
|
14 |
title="🔤 Roman Hindi → Hindi Transliteration Demo",
|
15 |
-
description="Type in Roman Hindi (like: mujhe pyar hai) and see it in
|
16 |
)
|
17 |
|
18 |
if __name__ == "__main__":
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
|
|
3 |
|
4 |
+
# Hinglish to Hindi Transliteration model (ai4bharat)
|
5 |
+
model_name = "ai4bharat/indictrans2-en-indic-1B"
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
7 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_name, trust_remote_code=True)
|
8 |
+
|
9 |
+
def transliterate_text(text):
|
10 |
+
inputs = tokenizer(text, return_tensors="pt")
|
11 |
+
outputs = model.generate(**inputs, max_length=128)
|
12 |
+
hindi_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
13 |
return hindi_text
|
14 |
|
15 |
demo = gr.Interface(
|
16 |
+
fn=transliterate_text,
|
17 |
inputs="text",
|
18 |
outputs="text",
|
19 |
title="🔤 Roman Hindi → Hindi Transliteration Demo",
|
20 |
+
description="Type in Roman Hindi (like: mujhe pyar hai) and see it in proper Hindi."
|
21 |
)
|
22 |
|
23 |
if __name__ == "__main__":
|