This library is developed to convert Indonesian (Bahasa Indonesia) graphemes (words) to phonemes in IPA. We followed the methods and designs used in the English equivalent library, g2p.
pip install g2p_id_py
from g2p_id import G2p
texts = [
"Apel itu berwarna merah.",
"Rahel bersekolah di S M A Jakarta 17.",
"Mereka sedang bermain bola di lapangan.",
]
g2p = G2p()
for text in texts:
print(g2p(text))
>> [['a', 'p', 'É™', 'l'], ['i', 't', 'u'], ['b', 'É™', 'r', 'w', 'a', 'r', 'n', 'a'], ['m', 'e', 'r', 'a', 'h'], ['.']]
>> [['r', 'a', 'h', 'e', 'l'], ['b', 'É™', 'r', 's', 'É™', 'k', 'o', 'l', 'a', 'h'], ['d', 'i'], ['e', 's'], ['e', 'm'], ['a'], ['dÊ’', 'a', 'k', 'a', 'r', 't', 'a'], ['t', 'u', 'dÊ’', 'u', 'h'], ['b', 'É™', 'l', 'a', 's'], ['.']]
>> [['m', 'É™', 'r', 'e', 'k', 'a'], ['s', 'É™', 'd', 'a', 'Å‹'], ['b', 'É™', 'r', 'm', 'a', 'i', 'n'], ['b', 'o', 'l', 'a'], ['d', 'i'], ['l', 'a', 'p', 'a', 'Å‹', 'a', 'n'], ['.']]
This is heavily inspired from the English g2p.
- Spells out arabic numbers and some currency symbols, e.g.
Rp 200,000 -> dua ratus ribu rupiah
. This is borrowed from Cahya's code. - Attempts to retrieve the correct pronunciation for homographs based on their POS (part-of-speech) tags.
- Looks up a lexicon (pronunciation dictionary) for non-homographs. This list is originally from ipa-dict, and we later made a modified version.
- For OOVs, we predict their pronunciations using either a BERT model or an LSTM model.
graphemes = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
phonemes = ['a', 'b', 'd', 'e', 'f', 'ɡ', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'v', 'w', 'z', 'ŋ', 'ə', 'ɲ', 'tʃ', 'ʃ', 'dʒ', 'x', 'ʔ']
You can find more details on how we handled homographs and out-of-vocabulary prediction on our documentation page.
@misc{g2pE2019,
author = {Park, Kyubyong & Kim, Jongseok},
title = {g2pE},
year = {2019},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/Kyubyong/g2p}}
}
@misc{TextProcessor2021,
author = {Cahya Wirawan},
title = {Text Processor},
year = {2021},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/cahya-wirawan/text_processor}}
}