pygoruut v0.5.0
Browse files
app.py
CHANGED
|
@@ -4,19 +4,21 @@ import gradio as gr
|
|
| 4 |
pygoruut = Pygoruut()
|
| 5 |
languages = PygoruutLanguages()
|
| 6 |
|
| 7 |
-
def dephon_offline(txt, language_tag, is_reverse):
|
| 8 |
try:
|
| 9 |
response = pygoruut.phonemize(language=language_tag, sentence=txt, is_reverse=is_reverse)
|
| 10 |
except TypeError:
|
| 11 |
return ''
|
| 12 |
if not response or not response.Words:
|
| 13 |
return ''
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
| 16 |
return phonetic_line
|
| 17 |
|
| 18 |
-
def phonemize(sentence, language, is_reverse):
|
| 19 |
-
return dephon_offline(sentence, language, is_reverse)
|
| 20 |
|
| 21 |
with gr.Blocks() as demo:
|
| 22 |
gr.Markdown('''
|
|
@@ -26,11 +28,12 @@ with gr.Blocks() as demo:
|
|
| 26 |
''')
|
| 27 |
with gr.Row():
|
| 28 |
sentence = gr.Textbox(label="Sentence", placeholder="Enter the text to phonemize...")
|
| 29 |
-
language = gr.Textbox(label="Language", placeholder="Enter the language tag (e.g., 'en' for English)...")
|
| 30 |
-
|
|
|
|
|
|
|
| 31 |
output = gr.Textbox(label="Phonemized Text")
|
| 32 |
-
submit_btn =
|
| 33 |
-
submit_btn.click(fn=phonemize, inputs=[sentence, language, is_reverse], outputs=output)
|
| 34 |
gr.Markdown('''
|
| 35 |
# Supported languages
|
| 36 |
''')
|
|
|
|
| 4 |
pygoruut = Pygoruut()
|
| 5 |
languages = PygoruutLanguages()
|
| 6 |
|
| 7 |
+
def dephon_offline(txt, language_tag, is_reverse, is_punct):
|
| 8 |
try:
|
| 9 |
response = pygoruut.phonemize(language=language_tag, sentence=txt, is_reverse=is_reverse)
|
| 10 |
except TypeError:
|
| 11 |
return ''
|
| 12 |
if not response or not response.Words:
|
| 13 |
return ''
|
| 14 |
+
if is_punct:
|
| 15 |
+
phonetic_line = str(response)
|
| 16 |
+
else:
|
| 17 |
+
phonetic_line = " ".join(word.Phonetic for word in response.Words)
|
| 18 |
return phonetic_line
|
| 19 |
|
| 20 |
+
def phonemize(sentence, language, is_reverse, is_punct):
|
| 21 |
+
return dephon_offline(sentence, language, is_reverse, is_punct)
|
| 22 |
|
| 23 |
with gr.Blocks() as demo:
|
| 24 |
gr.Markdown('''
|
|
|
|
| 28 |
''')
|
| 29 |
with gr.Row():
|
| 30 |
sentence = gr.Textbox(label="Sentence", placeholder="Enter the text to phonemize...")
|
| 31 |
+
language = gr.Textbox(label="Language", placeholder="Enter the language tag (e.g., 'en' for English), separate multiple languages by comma (,)...")
|
| 32 |
+
is_reverse = gr.Checkbox(label="Reverse Phonemization")
|
| 33 |
+
is_punct = gr.Checkbox(label="Keep Punctuation")
|
| 34 |
+
submit_btn = gr.Button("Phonemize")
|
| 35 |
output = gr.Textbox(label="Phonemized Text")
|
| 36 |
+
submit_btn.click(fn=phonemize, inputs=[sentence, language, is_reverse, is_punct], outputs=output)
|
|
|
|
| 37 |
gr.Markdown('''
|
| 38 |
# Supported languages
|
| 39 |
''')
|