phoonnx 0.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- phoonnx/__init__.py +0 -0
- phoonnx/config.py +490 -0
- phoonnx/locale/ca/phonetic_spellings.txt +2 -0
- phoonnx/locale/en/phonetic_spellings.txt +1 -0
- phoonnx/locale/gl/phonetic_spellings.txt +2 -0
- phoonnx/locale/pt/phonetic_spellings.txt +2 -0
- phoonnx/phoneme_ids.py +453 -0
- phoonnx/phonemizers/__init__.py +45 -0
- phoonnx/phonemizers/ar.py +42 -0
- phoonnx/phonemizers/base.py +216 -0
- phoonnx/phonemizers/en.py +250 -0
- phoonnx/phonemizers/fa.py +46 -0
- phoonnx/phonemizers/gl.py +142 -0
- phoonnx/phonemizers/he.py +67 -0
- phoonnx/phonemizers/ja.py +119 -0
- phoonnx/phonemizers/ko.py +97 -0
- phoonnx/phonemizers/mul.py +606 -0
- phoonnx/phonemizers/vi.py +44 -0
- phoonnx/phonemizers/zh.py +308 -0
- phoonnx/thirdparty/__init__.py +0 -0
- phoonnx/thirdparty/arpa2ipa.py +249 -0
- phoonnx/thirdparty/cotovia/cotovia_aarch64 +0 -0
- phoonnx/thirdparty/cotovia/cotovia_x86_64 +0 -0
- phoonnx/thirdparty/hangul2ipa.py +783 -0
- phoonnx/thirdparty/ko_tables/aspiration.csv +20 -0
- phoonnx/thirdparty/ko_tables/assimilation.csv +31 -0
- phoonnx/thirdparty/ko_tables/double_coda.csv +17 -0
- phoonnx/thirdparty/ko_tables/hanja.tsv +8525 -0
- phoonnx/thirdparty/ko_tables/ipa.csv +22 -0
- phoonnx/thirdparty/ko_tables/neutralization.csv +11 -0
- phoonnx/thirdparty/ko_tables/tensification.csv +56 -0
- phoonnx/thirdparty/ko_tables/yale.csv +22 -0
- phoonnx/thirdparty/kog2p/__init__.py +385 -0
- phoonnx/thirdparty/kog2p/rulebook.txt +212 -0
- phoonnx/thirdparty/mantoq/__init__.py +67 -0
- phoonnx/thirdparty/mantoq/buck/__init__.py +0 -0
- phoonnx/thirdparty/mantoq/buck/phonetise_buckwalter.py +569 -0
- phoonnx/thirdparty/mantoq/buck/symbols.py +64 -0
- phoonnx/thirdparty/mantoq/buck/tokenization.py +105 -0
- phoonnx/thirdparty/mantoq/num2words.py +37 -0
- phoonnx/thirdparty/mantoq/pyarabic/__init__.py +12 -0
- phoonnx/thirdparty/mantoq/pyarabic/arabrepr.py +64 -0
- phoonnx/thirdparty/mantoq/pyarabic/araby.py +1647 -0
- phoonnx/thirdparty/mantoq/pyarabic/named_const.py +227 -0
- phoonnx/thirdparty/mantoq/pyarabic/normalize.py +161 -0
- phoonnx/thirdparty/mantoq/pyarabic/number.py +826 -0
- phoonnx/thirdparty/mantoq/pyarabic/number_const.py +1704 -0
- phoonnx/thirdparty/mantoq/pyarabic/stack.py +52 -0
- phoonnx/thirdparty/mantoq/pyarabic/trans.py +517 -0
- phoonnx/thirdparty/mantoq/unicode_symbol2label.py +4173 -0
- phoonnx/thirdparty/tashkeel/LICENSE +22 -0
- phoonnx/thirdparty/tashkeel/SOURCE +1 -0
- phoonnx/thirdparty/tashkeel/__init__.py +212 -0
- phoonnx/thirdparty/tashkeel/hint_id_map.json +18 -0
- phoonnx/thirdparty/tashkeel/input_id_map.json +56 -0
- phoonnx/thirdparty/tashkeel/model.onnx +0 -0
- phoonnx/thirdparty/tashkeel/target_id_map.json +17 -0
- phoonnx/thirdparty/zh_num.py +238 -0
- phoonnx/util.py +705 -0
- phoonnx/version.py +6 -0
- phoonnx/voice.py +521 -0
- phoonnx-0.0.0.dist-info/METADATA +255 -0
- phoonnx-0.0.0.dist-info/RECORD +86 -0
- phoonnx-0.0.0.dist-info/WHEEL +5 -0
- phoonnx-0.0.0.dist-info/top_level.txt +2 -0
- phoonnx_train/__main__.py +151 -0
- phoonnx_train/export_onnx.py +109 -0
- phoonnx_train/norm_audio/__init__.py +92 -0
- phoonnx_train/norm_audio/trim.py +54 -0
- phoonnx_train/norm_audio/vad.py +54 -0
- phoonnx_train/preprocess.py +420 -0
- phoonnx_train/vits/__init__.py +0 -0
- phoonnx_train/vits/attentions.py +427 -0
- phoonnx_train/vits/commons.py +147 -0
- phoonnx_train/vits/config.py +330 -0
- phoonnx_train/vits/dataset.py +214 -0
- phoonnx_train/vits/lightning.py +352 -0
- phoonnx_train/vits/losses.py +58 -0
- phoonnx_train/vits/mel_processing.py +139 -0
- phoonnx_train/vits/models.py +732 -0
- phoonnx_train/vits/modules.py +527 -0
- phoonnx_train/vits/monotonic_align/__init__.py +20 -0
- phoonnx_train/vits/monotonic_align/setup.py +13 -0
- phoonnx_train/vits/transforms.py +212 -0
- phoonnx_train/vits/utils.py +16 -0
- phoonnx_train/vits/wavfile.py +860 -0
@@ -0,0 +1,67 @@
|
|
1
|
+
import os.path
|
2
|
+
|
3
|
+
import requests
|
4
|
+
|
5
|
+
from phoonnx.phonemizers.base import BasePhonemizer
|
6
|
+
from phoonnx.config import Alphabet
|
7
|
+
|
8
|
+
|
9
|
+
class PhonikudPhonemizer(BasePhonemizer):
|
10
|
+
dl_url = "https://huggingface.co/thewh1teagle/phonikud-onnx/resolve/main/phonikud-1.0.int8.onnx"
|
11
|
+
|
12
|
+
def __init__(self, model: str = None, diacritics=True):
|
13
|
+
from phonikud_onnx import Phonikud
|
14
|
+
from phonikud import phonemize
|
15
|
+
self.g2p = phonemize
|
16
|
+
self.diacritics = diacritics
|
17
|
+
if model is None:
|
18
|
+
base_path = os.path.expanduser("~/.local/share/phonikud")
|
19
|
+
fname = self.dl_url.split("/")[-1]
|
20
|
+
model = f"{base_path}/{fname}"
|
21
|
+
if not os.path.isfile(model):
|
22
|
+
os.makedirs(base_path, exist_ok=True)
|
23
|
+
# TODO - streaming download
|
24
|
+
data = requests.get(self.dl_url).content
|
25
|
+
with open(model, "wb") as f:
|
26
|
+
f.write(data)
|
27
|
+
self.phonikud = Phonikud(model) if diacritics else None
|
28
|
+
super().__init__(Alphabet.IPA)
|
29
|
+
|
30
|
+
@classmethod
|
31
|
+
def get_lang(cls, target_lang: str) -> str:
|
32
|
+
"""
|
33
|
+
Validates and returns the closest supported language code.
|
34
|
+
|
35
|
+
Args:
|
36
|
+
target_lang (str): The language code to validate.
|
37
|
+
|
38
|
+
Returns:
|
39
|
+
str: The validated language code.
|
40
|
+
|
41
|
+
Raises:
|
42
|
+
ValueError: If the language code is unsupported.
|
43
|
+
"""
|
44
|
+
# this check is here only to throw an exception if invalid language is provided
|
45
|
+
return cls.match_lang(target_lang, ["he"])
|
46
|
+
|
47
|
+
def phonemize_string(self, text: str, lang: str = "he") -> str:
|
48
|
+
"""
|
49
|
+
"""
|
50
|
+
lang = self.get_lang(lang)
|
51
|
+
if self.diacritics:
|
52
|
+
text = self.phonikud.add_diacritics(text)
|
53
|
+
return self.g2p(text)
|
54
|
+
|
55
|
+
|
56
|
+
if __name__ == "__main__":
|
57
|
+
#text = "מתכת יקרה"
|
58
|
+
text = 'שָׁלוֹם עוֹלָם'
|
59
|
+
|
60
|
+
pho = PhonikudPhonemizer(diacritics=False)
|
61
|
+
lang = "he"
|
62
|
+
|
63
|
+
print(f"\n--- Getting phonemes for '{text}' ---")
|
64
|
+
phonemes = pho.phonemize(text, lang)
|
65
|
+
print(f" Phonemes: {phonemes}")
|
66
|
+
# --- Getting phonemes for 'שָׁלוֹם עוֹלָם' ---
|
67
|
+
# Phonemes: [('ʃalˈom ʔolˈam', '.', True)]
|
@@ -0,0 +1,119 @@
|
|
1
|
+
from phoonnx.phonemizers.base import BasePhonemizer
|
2
|
+
from phoonnx.config import Alphabet
|
3
|
+
|
4
|
+
class OpenJTaklPhonemizer(BasePhonemizer):
|
5
|
+
|
6
|
+
def __init__(self, alphabet=Alphabet.IPA):
|
7
|
+
assert alphabet in [Alphabet.HEPBURN, Alphabet.KANA]
|
8
|
+
import pyopenjtalk
|
9
|
+
self.g2p = pyopenjtalk.g2p
|
10
|
+
super().__init__(alphabet)
|
11
|
+
|
12
|
+
@classmethod
|
13
|
+
def get_lang(cls, target_lang: str) -> str:
|
14
|
+
"""
|
15
|
+
Validates and returns the closest supported language code.
|
16
|
+
|
17
|
+
Args:
|
18
|
+
target_lang (str): The language code to validate.
|
19
|
+
|
20
|
+
Returns:
|
21
|
+
str: The validated language code.
|
22
|
+
|
23
|
+
Raises:
|
24
|
+
ValueError: If the language code is unsupported.
|
25
|
+
"""
|
26
|
+
# this check is here only to throw an exception if invalid language is provided
|
27
|
+
return cls.match_lang(target_lang, ["ja"])
|
28
|
+
|
29
|
+
def phonemize_string(self, text: str, lang: str = "ja") -> str:
|
30
|
+
"""
|
31
|
+
"""
|
32
|
+
lang = self.get_lang(lang)
|
33
|
+
return self.g2p(text, kana=self.alphabet == Alphabet.KANA)
|
34
|
+
|
35
|
+
|
36
|
+
class CutletPhonemizer(BasePhonemizer):
|
37
|
+
|
38
|
+
def __init__(self, alphabet=Alphabet.HEPBURN, use_foreign_spelling = False):
|
39
|
+
assert alphabet in [Alphabet.HEPBURN, Alphabet.KUNREI, Alphabet.NIHON]
|
40
|
+
# If `use_foreign_spelling` is true, output will use the foreign spelling
|
41
|
+
# provided in a UniDic lemma when available. For example, "カツ" will
|
42
|
+
# become "cutlet" instead of "katsu".
|
43
|
+
import cutlet
|
44
|
+
self.g2p = cutlet.Cutlet(alphabet)
|
45
|
+
self.g2p.use_foreign_spelling = use_foreign_spelling
|
46
|
+
super().__init__(alphabet)
|
47
|
+
|
48
|
+
@classmethod
|
49
|
+
def get_lang(cls, target_lang: str) -> str:
|
50
|
+
"""
|
51
|
+
Validates and returns the closest supported language code.
|
52
|
+
|
53
|
+
Args:
|
54
|
+
target_lang (str): The language code to validate.
|
55
|
+
|
56
|
+
Returns:
|
57
|
+
str: The validated language code.
|
58
|
+
|
59
|
+
Raises:
|
60
|
+
ValueError: If the language code is unsupported.
|
61
|
+
"""
|
62
|
+
# this check is here only to throw an exception if invalid language is provided
|
63
|
+
return cls.match_lang(target_lang, ["ja"])
|
64
|
+
|
65
|
+
def phonemize_string(self, text: str, lang: str = "ja") -> str:
|
66
|
+
"""
|
67
|
+
"""
|
68
|
+
lang = self.get_lang(lang)
|
69
|
+
return self.g2p.romaji(text)
|
70
|
+
|
71
|
+
class PyKakasiPhonemizer(BasePhonemizer):
|
72
|
+
|
73
|
+
def __init__(self, alphabet=Alphabet.HEPBURN):
|
74
|
+
assert alphabet in [Alphabet.HEPBURN, Alphabet.KANA, Alphabet.HIRA]
|
75
|
+
# kana, hira, hepburn
|
76
|
+
import pykakasi
|
77
|
+
self.g2p = pykakasi.kakasi()
|
78
|
+
super().__init__(alphabet)
|
79
|
+
|
80
|
+
@classmethod
|
81
|
+
def get_lang(cls, target_lang: str) -> str:
|
82
|
+
"""
|
83
|
+
Validates and returns the closest supported language code.
|
84
|
+
|
85
|
+
Args:
|
86
|
+
target_lang (str): The language code to validate.
|
87
|
+
|
88
|
+
Returns:
|
89
|
+
str: The validated language code.
|
90
|
+
|
91
|
+
Raises:
|
92
|
+
ValueError: If the language code is unsupported.
|
93
|
+
"""
|
94
|
+
# this check is here only to throw an exception if invalid language is provided
|
95
|
+
return cls.match_lang(target_lang, ["ja"])
|
96
|
+
|
97
|
+
def phonemize_string(self, text: str, lang: str = "ja") -> str:
|
98
|
+
"""
|
99
|
+
"""
|
100
|
+
lang = self.get_lang(lang)
|
101
|
+
return " ".join([
|
102
|
+
a[self.alphabet] for a in
|
103
|
+
self.g2p.convert(text)
|
104
|
+
])
|
105
|
+
|
106
|
+
|
107
|
+
if __name__ == "__main__":
|
108
|
+
text = "こんにちは"
|
109
|
+
text = "カツカレーは美味しい"
|
110
|
+
lang = "ja"
|
111
|
+
|
112
|
+
pho = OpenJTaklPhonemizer(kana=True)
|
113
|
+
pho = CutletPhonemizer()
|
114
|
+
pho = PyKakasiPhonemizer(Alphabet.KANA)
|
115
|
+
from phoonnx.phonemizers.mul import MisakiPhonemizer
|
116
|
+
#pho = MisakiPhonemizer()
|
117
|
+
print(f"\n--- Getting phonemes for '{text}' ---")
|
118
|
+
phonemes_cotovia = pho.phonemize(text, lang)
|
119
|
+
print(f" Phonemes: {phonemes_cotovia}")
|
@@ -0,0 +1,97 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
from phoonnx.phonemizers.base import BasePhonemizer
|
4
|
+
from phoonnx.thirdparty.hangul2ipa import hangul2ipa
|
5
|
+
from phoonnx.config import Alphabet
|
6
|
+
|
7
|
+
|
8
|
+
class G2PKPhonemizer(BasePhonemizer):
|
9
|
+
|
10
|
+
def __init__(self, descriptive=True, group_vowels=True, to_syl=True,
|
11
|
+
alphabet=Alphabet.IPA):
|
12
|
+
assert alphabet in [Alphabet.IPA, Alphabet.HANGUL]
|
13
|
+
from g2pk import G2p
|
14
|
+
self.g2p = G2p()
|
15
|
+
self.descriptive = descriptive
|
16
|
+
self.group_vowels = group_vowels
|
17
|
+
self.to_syl = to_syl
|
18
|
+
super().__init__(alphabet)
|
19
|
+
|
20
|
+
@classmethod
|
21
|
+
def get_lang(cls, target_lang: str) -> str:
|
22
|
+
"""
|
23
|
+
Validates and returns the closest supported language code.
|
24
|
+
|
25
|
+
Args:
|
26
|
+
target_lang (str): The language code to validate.
|
27
|
+
|
28
|
+
Returns:
|
29
|
+
str: The validated language code.
|
30
|
+
|
31
|
+
Raises:
|
32
|
+
ValueError: If the language code is unsupported.
|
33
|
+
"""
|
34
|
+
# this check is here only to throw an exception if invalid language is provided
|
35
|
+
return cls.match_lang(target_lang, ["ko"])
|
36
|
+
|
37
|
+
def phonemize_string(self, text: str, lang: str = "ko") -> str:
|
38
|
+
"""
|
39
|
+
"""
|
40
|
+
lang = self.get_lang(lang)
|
41
|
+
p = self.g2p(text, descriptive=self.descriptive,
|
42
|
+
group_vowels=self.group_vowels,
|
43
|
+
to_syl=self.to_syl)
|
44
|
+
if self.alphabet == Alphabet.IPA:
|
45
|
+
return hangul2ipa(p)
|
46
|
+
return p
|
47
|
+
|
48
|
+
|
49
|
+
class KoG2PPhonemizer(BasePhonemizer):
|
50
|
+
"""https://github.com/scarletcho/KoG2P"""
|
51
|
+
def __init__(self, alphabet=Alphabet.IPA):
|
52
|
+
assert alphabet in [Alphabet.IPA, Alphabet.HANGUL]
|
53
|
+
from phoonnx.thirdparty.kog2p import runKoG2P
|
54
|
+
self.g2p = runKoG2P
|
55
|
+
super().__init__(alphabet)
|
56
|
+
|
57
|
+
@classmethod
|
58
|
+
def get_lang(cls, target_lang: str) -> str:
|
59
|
+
"""
|
60
|
+
Validates and returns the closest supported language code.
|
61
|
+
|
62
|
+
Args:
|
63
|
+
target_lang (str): The language code to validate.
|
64
|
+
|
65
|
+
Returns:
|
66
|
+
str: The validated language code.
|
67
|
+
|
68
|
+
Raises:
|
69
|
+
ValueError: If the language code is unsupported.
|
70
|
+
"""
|
71
|
+
# this check is here only to throw an exception if invalid language is provided
|
72
|
+
return cls.match_lang(target_lang, ["ko"])
|
73
|
+
|
74
|
+
def phonemize_string(self, text: str, lang: str = "ko") -> str:
|
75
|
+
"""
|
76
|
+
"""
|
77
|
+
lang = self.get_lang(lang)
|
78
|
+
p = self.g2p(text)
|
79
|
+
if self.alphabet == Alphabet.IPA:
|
80
|
+
return hangul2ipa(p)
|
81
|
+
return p
|
82
|
+
|
83
|
+
|
84
|
+
if __name__ == "__main__":
|
85
|
+
|
86
|
+
pho = G2PKPhonemizer(ipa=False)
|
87
|
+
pho2 = KoG2PPhonemizer(ipa=False)
|
88
|
+
lang = "ko"
|
89
|
+
|
90
|
+
text = "터미널에서 원하는 문자열을 함께 입력해 사용할 수 있습니다."
|
91
|
+
print(f"\n--- Getting phonemes for '{text}' ---")
|
92
|
+
phonemes_cotovia = pho.phonemize(text, lang)
|
93
|
+
print(f" G2PK Phonemes: {phonemes_cotovia}")
|
94
|
+
|
95
|
+
phonemes_cotovia = pho2.phonemize(text, lang)
|
96
|
+
print(f" KoG2P Phonemes: {phonemes_cotovia}")
|
97
|
+
|