import gradio as gr import os from gradio_client import Client auth_token = os.environ.get("HUGGING_FACE_HUB_TOKEN") #iface = gr.load(name="mutisya/translate-api", hf_token=auth_token, src="spaces") langs = """English (en), Kamba (kam), Kikuyu (kik), Meru (mer), Luo (luo), Somali (som), Swahili (swa)""" lang_list = [lang.strip() for lang in langs.split(',')] client = Client("DrLugha/translate-api",hf_token=auth_token) def translate_paragraphs(src, tgt, text): output = client.predict(src, tgt, text) return output # gr.inputs.Dropdown(lang_list_options, label="Direction"), gradio_ui = gr.Interface( translate_paragraphs, title="Translate Between languages", description="Model built using M2M100-418M", inputs=[ gr.Dropdown(lang_list, label="Translate From"), gr.Dropdown(lang_list, label="Target Language"), gr.Textbox(lines=5, placeholder="Enter text in source language"), ], outputs=[gr.Textbox(label="Translated text")] ) gradio_ui.launch()