import gradio as gr from transformers import pipeline translater_en_ss = pipeline("translation", model="dsfsi/en-ss-m2m100-combo") translater_ss_en = pipeline("translation", model="dsfsi/ss-en-m2m100-combo") def translate(inp, direction): if direction == 'en->ss': res = translater_en_ss(inp, max_length=512, early_stopping=True)[0]['translation_text'] else: res = translater_ss_en(inp, max_length=512, early_stopping=True)[0]['translation_text'] return res description = """

Multi-domain Translation Between Siswati and English

""" article = "

by dsfsi

" examples = [ ["Thank you for your help", "en->ss"], ["Ngiyabonga ngesiciniseko sakho", "ss->en"] ] iface = gr.Interface( fn=translate, title="Siswati-English Translation", description=description, article=article, examples=examples, inputs=[ gr.inputs.Textbox(lines=5, placeholder="Enter text (maximum 5 lines)", label="Input"), gr.inputs.Radio( choices=[ 'en->ss', 'ss->en'], default='en->ss', label='Direction'), ], outputs="text" ) iface.launch(enable_queue=True)