Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from gradio_client import Client
|
4 |
+
|
5 |
+
MY_HF_TOKEN_KEY = os.environ["MY_HF_TOKEN_KEY"]
|
6 |
+
|
7 |
+
client = Client("Ghana-NLP/ewe-tts",hf_token=MY_HF_TOKEN_KEY)
|
8 |
+
|
9 |
+
def generate(text, direction):
|
10 |
+
output = client.predict(text, direction)
|
11 |
+
return output
|
12 |
+
|
13 |
+
title = "GhanaNLP: Test Text Translation Models"
|
14 |
+
|
15 |
+
description = """
|
16 |
+
<b>How to use:</b> Translate Ga or Ewe text to/from English.
|
17 |
+
"""
|
18 |
+
|
19 |
+
examples = [
|
20 |
+
["Yaaba jogbaŋŋ mi Misuɔmɔ.","Ga->En"],
|
21 |
+
["ha mi gbe fioo","Ga->En"],
|
22 |
+
["kɛ osuɔmɔ aha mi","Ga->En"],
|
23 |
+
]
|
24 |
+
|
25 |
+
gr.Interface(
|
26 |
+
fn=generate,
|
27 |
+
inputs=[
|
28 |
+
gr.Text(label="Input Text"),
|
29 |
+
gr.Dropdown(
|
30 |
+
["En->Ga", "Ga->En","En->Ewe", "Ewe->En"], label="Direction", info="Select From (Input) -> To (Output) languages"
|
31 |
+
),
|
32 |
+
],
|
33 |
+
outputs=[
|
34 |
+
gr.Text(label="Output Text"),
|
35 |
+
],
|
36 |
+
title=title,
|
37 |
+
description=description,
|
38 |
+
examples=examples,
|
39 |
+
).launch()
|