Spaces:
Sleeping
Sleeping
mrfakename
commited on
Commit
•
9e6872b
1
Parent(s):
a8e1060
autoregressive
Browse files
app.py
CHANGED
@@ -4,7 +4,9 @@ from gruut import sentences
|
|
4 |
from phonemap.g2pphonemizer import G2PPhonemizer
|
5 |
from phonemap.charsiu import CharsiuPhonemizer
|
6 |
from openphonemizer import OpenPhonemizer
|
|
|
7 |
opphonemizer = OpenPhonemizer()
|
|
|
8 |
|
9 |
g2p = G2PPhonemizer()
|
10 |
charsiu = CharsiuPhonemizer()
|
@@ -12,7 +14,6 @@ import phonemizer
|
|
12 |
global_phonemizer = phonemizer.backend.EspeakBackend(language='en-us', preserve_punctuation=True, with_stress=True, words_mismatch='ignore')
|
13 |
from nltk import word_tokenize
|
14 |
import nltk
|
15 |
-
from cached_path import cached_path
|
16 |
|
17 |
from dp.phonemizer import Phonemizer
|
18 |
phonemizer = Phonemizer.from_checkpoint(str(cached_path('https://public-asai-dl-models.s3.eu-central-1.amazonaws.com/DeepPhonemizer/en_us_cmudict_ipa_forward.pt')))
|
@@ -55,17 +56,20 @@ def dp(text):
|
|
55 |
return phonemizer(text, lang='en_us')
|
56 |
def run_openphonemizer(text):
|
57 |
return opphonemizer(text)
|
|
|
|
|
58 |
def run(t, r):
|
59 |
if r == 'phonemizer': return phonemizerfunc(t)
|
60 |
if r == 'openphonemizer': return run_openphonemizer(t)
|
61 |
if r == 'gruut': return gruut(t)
|
62 |
if r == 'deep_phonemizer': return dp(t)
|
63 |
if r == 'g2p_en (buggy)': return g2pen(t)
|
|
|
64 |
return f'Error: Phonemizer {r} not found, please try another Phonemizer and create a Community discussion on HF.'
|
65 |
with gr.Blocks() as demo:
|
66 |
gr.Markdown("# PhonemizerHub")
|
67 |
t = gr.Textbox(label="Text", placeholder="Enter text...", interactive=True)
|
68 |
-
r = gr.Radio(choices=['phonemizer', 'openphonemizer', 'gruut', 'deep_phonemizer', 'g2p_en (buggy)'], value='openphonemizer', interactive=True, label='Select a phonemizer')
|
69 |
b = gr.Button("Phonemize")
|
70 |
out = gr.Textbox(interactive=False, label="Phonemes")
|
71 |
b.click(run, inputs=[t, r], outputs=[out])
|
|
|
4 |
from phonemap.g2pphonemizer import G2PPhonemizer
|
5 |
from phonemap.charsiu import CharsiuPhonemizer
|
6 |
from openphonemizer import OpenPhonemizer
|
7 |
+
from cached_path import cached_path
|
8 |
opphonemizer = OpenPhonemizer()
|
9 |
+
opphonemizer_ar = OpenPhonemizer(str(cached_path('hf://openphonemizer/autoreg-ckpt/best_model.pt')))
|
10 |
|
11 |
g2p = G2PPhonemizer()
|
12 |
charsiu = CharsiuPhonemizer()
|
|
|
14 |
global_phonemizer = phonemizer.backend.EspeakBackend(language='en-us', preserve_punctuation=True, with_stress=True, words_mismatch='ignore')
|
15 |
from nltk import word_tokenize
|
16 |
import nltk
|
|
|
17 |
|
18 |
from dp.phonemizer import Phonemizer
|
19 |
phonemizer = Phonemizer.from_checkpoint(str(cached_path('https://public-asai-dl-models.s3.eu-central-1.amazonaws.com/DeepPhonemizer/en_us_cmudict_ipa_forward.pt')))
|
|
|
56 |
return phonemizer(text, lang='en_us')
|
57 |
def run_openphonemizer(text):
|
58 |
return opphonemizer(text)
|
59 |
+
def opar(text):
|
60 |
+
return opphonemizer_ar(text)
|
61 |
def run(t, r):
|
62 |
if r == 'phonemizer': return phonemizerfunc(t)
|
63 |
if r == 'openphonemizer': return run_openphonemizer(t)
|
64 |
if r == 'gruut': return gruut(t)
|
65 |
if r == 'deep_phonemizer': return dp(t)
|
66 |
if r == 'g2p_en (buggy)': return g2pen(t)
|
67 |
+
if r == 'openphonemizer autoregressive': return opar(t)
|
68 |
return f'Error: Phonemizer {r} not found, please try another Phonemizer and create a Community discussion on HF.'
|
69 |
with gr.Blocks() as demo:
|
70 |
gr.Markdown("# PhonemizerHub")
|
71 |
t = gr.Textbox(label="Text", placeholder="Enter text...", interactive=True)
|
72 |
+
r = gr.Radio(choices=['phonemizer', 'openphonemizer', 'gruut', 'openphonemizer autoregressive', 'deep_phonemizer', 'g2p_en (buggy)'], value='openphonemizer', interactive=True, label='Select a phonemizer')
|
73 |
b = gr.Button("Phonemize")
|
74 |
out = gr.Textbox(interactive=False, label="Phonemes")
|
75 |
b.click(run, inputs=[t, r], outputs=[out])
|