Add app
Browse files- app.py +34 -0
- requirements.txt +1 -0
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from pygoruut.pygoruut import Pygoruut
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
pygoruut = Pygoruut()
|
5 |
+
|
6 |
+
def dephon_offline(txt, language_tag, is_reverse):
|
7 |
+
try:
|
8 |
+
response = pygoruut.phonemize(language=language_tag, sentence=txt, is_reverse=is_reverse)
|
9 |
+
except TypeError:
|
10 |
+
return ''
|
11 |
+
if not response or not response.Words:
|
12 |
+
return ''
|
13 |
+
|
14 |
+
phonetic_line = " ".join(word.Phonetic for word in response.Words)
|
15 |
+
return phonetic_line
|
16 |
+
|
17 |
+
def phonemize(sentence, language, is_reverse):
|
18 |
+
return dephon_offline(sentence, language, is_reverse)
|
19 |
+
|
20 |
+
with gr.Blocks() as demo:
|
21 |
+
gr.Markdown('''
|
22 |
+
# Pygoruut Phonemizer Demo
|
23 |
+
This demo allows you to phonemize text using the Pygoruut phonemizer.
|
24 |
+
You can specify the language and choose whether to perform reverse phonemization.
|
25 |
+
''')
|
26 |
+
with gr.Row():
|
27 |
+
sentence = gr.Textbox(label="Sentence", placeholder="Enter the text to phonemize...")
|
28 |
+
language = gr.Textbox(label="Language", placeholder="Enter the language tag (e.g., 'en' for English)...")
|
29 |
+
is_reverse = gr.Checkbox(label="Reverse Phonemization")
|
30 |
+
output = gr.Textbox(label="Phonemized Text")
|
31 |
+
submit_btn = gr.Button("Phonemize")
|
32 |
+
submit_btn.click(fn=phonemize, inputs=[sentence, language, is_reverse], outputs=output)
|
33 |
+
|
34 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
pygoruut
|