import os import gradio as gr from gradio_client import Client MY_HF_TOKEN_KEY = os.environ["MY_HF_TOKEN_KEY"] client = Client("Ghana-NLP/test-text-models",hf_token=MY_HF_TOKEN_KEY) def generate(text, direction): output = client.predict(text, direction) return output title = "GhanaNLP: Test Text Translation Models" description = """ How to use: Translate Twi, Ga or Ewe text to/from English. """ examples = [ ["Yaaba jogbaŋŋ mi Misuɔmɔ.","Ga->En"], ["ha mi gbe fioo","Ga->En"], ["kɛ osuɔmɔ aha mi","Ga->En"], ] gr.Interface( fn=generate, inputs=[ gr.Text(label="Input Text"), gr.Dropdown( ["Twi->En", "En->Twi","En->Ga", "Ga->En","En->Ewe", "Ewe->En", "Dagbani->En", "En->Dagbani","En->Gurene", "Gurene->En","En->Kusaal", "Kusaal->En"], label="Direction", info="Select From (Input) -> To (Output) languages" ), ], outputs=[ gr.Text(label="Output Text"), ], title=title, description=description, examples=examples, ).launch()