Spaces:
Runtime error
Runtime error
Teddy Xinyuan Chen
commited on
2024-05-10T11-54-48Z
Browse files
main.py
CHANGED
@@ -1,25 +1,37 @@
|
|
1 |
import gradio as gr
|
2 |
from taibun import Converter # Assuming the taibun package provides a Converter class
|
3 |
|
4 |
-
|
|
|
5 |
# Create a converter object with selected options
|
6 |
converter = Converter(system=system, dialect=dialect, format=format, sandhi=sandhi)
|
7 |
# Return the converted text
|
8 |
return converter.get(text)
|
9 |
|
|
|
10 |
# Define the interface
|
11 |
interface = gr.Interface(
|
12 |
fn=convert_text,
|
13 |
inputs=[
|
14 |
-
gr.Textbox(label="Enter
|
15 |
-
gr.Dropdown(
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
],
|
20 |
outputs=[gr.Textbox(label="Converted Text")],
|
21 |
-
title="
|
22 |
-
description="Convert
|
23 |
)
|
24 |
|
25 |
# Launch the app
|
|
|
1 |
import gradio as gr
|
2 |
from taibun import Converter # Assuming the taibun package provides a Converter class
|
3 |
|
4 |
+
|
5 |
+
def convert_text(text, system="Tailo", dialect="south", format="mark", sandhi="none"):
|
6 |
# Create a converter object with selected options
|
7 |
converter = Converter(system=system, dialect=dialect, format=format, sandhi=sandhi)
|
8 |
# Return the converted text
|
9 |
return converter.get(text)
|
10 |
|
11 |
+
|
12 |
# Define the interface
|
13 |
interface = gr.Interface(
|
14 |
fn=convert_text,
|
15 |
inputs=[
|
16 |
+
gr.Textbox(label="Enter Hokkien text", placeholder="Type Hokkien text here..."),
|
17 |
+
gr.Dropdown(
|
18 |
+
choices=["Tailo", "POJ", "Zhuyin", "TLPA", "Pingyim", "Tongiong", "IPA"],
|
19 |
+
label="System",
|
20 |
+
value="Tailo",
|
21 |
+
),
|
22 |
+
gr.Dropdown(choices=["south", "north"], label="Dialect", value="south"),
|
23 |
+
gr.Dropdown(
|
24 |
+
choices=["mark", "number", "strip"], label="Tone Format", value="mark"
|
25 |
+
),
|
26 |
+
gr.Dropdown(
|
27 |
+
choices=["none", "auto", "exc_last", "incl_last"],
|
28 |
+
label="Tone Sandhi",
|
29 |
+
value="none",
|
30 |
+
),
|
31 |
],
|
32 |
outputs=[gr.Textbox(label="Converted Text")],
|
33 |
+
title="Hokkien Transliteration Converter",
|
34 |
+
description="Convert Hokkien text between various transliteration systems using the <a href='https://github.com/andreihar/taibun' target='_blank'>taibun</a> package.",
|
35 |
)
|
36 |
|
37 |
# Launch the app
|