from transformers import AutoTokenizer, TFBertForSeq2SeqLM # Assuming TFBert model # Load tokenizer configurations source_tokenizer = AutoTokenizer.from_pretrained("https://huggingface.co/Bajiyo/mal_en_transliteration/tree/main/source_tokenizer_config.json") target_tokenizer = AutoTokenizer.from_pretrained("https://huggingface.co/Bajiyo/mal_en_transliteration/tree/main/target_tokenizer_config.json") # Load the model (replace with your actual model path) model = TFBertForSeq2SeqLM.from_pretrained("https://huggingface.co/Bajiyo/mal_en_transliteration/tree/main/transliteration_model.h5") def translate(malayalam_text): """Function to perform Malayalam to English transliteration""" source_ids = source_tokenizer(malayalam_text, return_tensors="pt")["input_ids"] translated_tokens = model.generate(**source_ids) english_text = target_tokenizer.batch_decode(translated_tokens, skip_special_tokens=True)[0] return english_text interface = gradio.Interface( fn=translate, inputs="text", outputs="text", title="Malayalam to English Transliteration", description="Enter Malayalam text to get the English transliteration.", examples=[["എങ്ങനെയാണ് ഞാൻ ഇംഗ്ലീഷിൽ സംസാരിക്കേണ്ടത്?"], ["ഹലോ എങ്ങനെയിരിക്കുന്നു?"]] ) interface.launch()