Skip to content

Commit

Permalink
Fix k phonemization issues
Browse files Browse the repository at this point in the history
  • Loading branch information
w11wo committed Dec 9, 2024
1 parent a5b47b9 commit 1dc234a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion g2p_id/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
from .onnx_utils import WrapInferenceSession
from .text_processor import TextProcessor

__version__ = "0.4.0"
__version__ = "0.4.1"
__all__ = ["G2p", "LSTM", "BERT", "WrapInferenceSession", "TextProcessor"]
12 changes: 6 additions & 6 deletions g2p_id/g2p.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,14 @@ def __call__(self, text: str) -> List[List[str]]:
if isinstance(self.model, BERT):
pron = self._rule_based_g2p(pron)

prons.append(pron.split())
if pron.endswith("ʔ"):
pron = pron[:-1] + "k"

if pron.endswith("ʔ"):
pron = pron[:-1] + "k"
consonants = "bdjklmnprstwɲ"

consonants = "bdjklmnprstwɲ"
for letter in consonants:
text = text.replace(f"ʔ{letter}", f"k{letter}")

for letter in consonants:
text = text.replace(f"ʔ{letter}", f"k{letter}")
prons.append(pron.split())

return prons
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
if __name__ == "__main__":
setup(
name="g2p_id_py",
version="0.4.0",
version="0.4.1",
description="Indonesian G2P.",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
1 change: 1 addition & 0 deletions tests/test_g2p.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def test_g2p(g2p):
["s", "ə", "l", "a", "m", "a", "t"],
["d", "a", "t", "a", "ŋ"],
]
assert g2p("kakak layak") == [["k", "a", "k", "a", "k"], ["l", "a", "j", "a", "k"]]


def test_rule_based_g2p(g2p):
Expand Down

0 comments on commit 1dc234a

Please sign in to comment.