File size: 930 Bytes
4457dab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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()