-
Notifications
You must be signed in to change notification settings - Fork 0
/
phonemize.py
39 lines (33 loc) · 877 Bytes
/
phonemize.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from phonemizer.backend import BACKENDS
from phonemizer.separator import Separator
word_separator = " "
syllable_separator = ""
phone_separator = ""
backend="espeak"
separator = Separator(
word=word_separator,
syllable=syllable_separator,
phone=phone_separator,
)
phonemizer_ko = BACKENDS[backend](
language="ko",
with_stress=False,
preserve_punctuation=True,
words_mismatch='ignore',
language_switch='remove-flags'
)
phonemizer_en = BACKENDS[backend](
language="en-us",
with_stress=True,
preserve_punctuation=True,
words_mismatch='ignore',
language_switch='remove-flags'
)
def text2ipa_kor(text):
tokens = phonemizer_ko.phonemize([text])[0]
tokens = [c for c in tokens]
return tokens
def text2ipa_eng(text):
tokens = phonemizer_en.phonemize([text])[0]
tokens = [c for c in tokens]
return tokens