Teddy Xinyuan Chen commited on
Commit
99062a4
·
unverified ·
1 Parent(s): 00b5233

2024-05-10T11-54-48Z

Browse files
Files changed (1) hide show
  1. main.py +20 -8
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
- def convert_text(text, system, dialect, format, sandhi):
 
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 Taiwanese Hokkien text"),
15
- gr.Dropdown(choices=["Tailo", "POJ", "Zhuyin", "TLPA", "Pingyim", "Tongiong", "IPA"], label="System"),
16
- gr.Dropdown(choices=["south", "north"], label="Dialect"),
17
- gr.Dropdown(choices=["mark", "number", "strip"], label="Tone Format"),
18
- gr.Dropdown(choices=["none", "auto", "exc_last", "incl_last"], label="Tone Sandhi"),
 
 
 
 
 
 
 
 
 
 
19
  ],
20
  outputs=[gr.Textbox(label="Converted Text")],
21
- title="Taiwanese Hokkien Transliteration Converter",
22
- description="Convert Taiwanese Hokkien text between various transliteration systems using the Taibun package."
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