azunre's picture
Create app.py
4457dab verified
raw
history blame
930 Bytes
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/ewe-tts",hf_token=MY_HF_TOKEN_KEY)
def generate(text, direction):
output = client.predict(text, direction)
return output
title = "GhanaNLP: Test Text Translation Models"
description = """
<b>How to use:</b> Translate 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(
["En->Ga", "Ga->En","En->Ewe", "Ewe->En"], label="Direction", info="Select From (Input) -> To (Output) languages"
),
],
outputs=[
gr.Text(label="Output Text"),
],
title=title,
description=description,
examples=examples,
).launch()