phoonnx 0.0.2a2__tar.gz → 0.1.0a1__tar.gz

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.
Files changed (93) hide show
  1. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/PKG-INFO +1 -1
  2. phoonnx-0.1.0a1/phoonnx/phonemizers/ar.py +106 -0
  3. phoonnx-0.1.0a1/phoonnx/thirdparty/bw2ipa.py +66 -0
  4. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/version.py +3 -3
  5. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx.egg-info/PKG-INFO +1 -1
  6. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx.egg-info/SOURCES.txt +2 -0
  7. phoonnx-0.0.2a2/phoonnx/phonemizers/ar.py +0 -42
  8. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/README.md +0 -0
  9. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/__init__.py +0 -0
  10. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/config.py +0 -0
  11. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/locale/ca/phonetic_spellings.txt +0 -0
  12. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/locale/en/phonetic_spellings.txt +0 -0
  13. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/locale/gl/phonetic_spellings.txt +0 -0
  14. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/locale/pt/phonetic_spellings.txt +0 -0
  15. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/phoneme_ids.py +0 -0
  16. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/phonemizers/__init__.py +0 -0
  17. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/phonemizers/base.py +0 -0
  18. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/phonemizers/en.py +0 -0
  19. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/phonemizers/fa.py +0 -0
  20. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/phonemizers/gl.py +0 -0
  21. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/phonemizers/he.py +0 -0
  22. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/phonemizers/ja.py +0 -0
  23. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/phonemizers/ko.py +0 -0
  24. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/phonemizers/mul.py +0 -0
  25. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/phonemizers/vi.py +0 -0
  26. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/phonemizers/zh.py +0 -0
  27. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/__init__.py +0 -0
  28. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/arpa2ipa.py +0 -0
  29. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/cotovia/cotovia_aarch64 +0 -0
  30. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/cotovia/cotovia_x86_64 +0 -0
  31. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/hangul2ipa.py +0 -0
  32. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/ko_tables/aspiration.csv +0 -0
  33. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/ko_tables/assimilation.csv +0 -0
  34. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/ko_tables/double_coda.csv +0 -0
  35. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/ko_tables/hanja.tsv +0 -0
  36. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/ko_tables/ipa.csv +0 -0
  37. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/ko_tables/neutralization.csv +0 -0
  38. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/ko_tables/tensification.csv +0 -0
  39. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/ko_tables/yale.csv +0 -0
  40. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/kog2p/__init__.py +0 -0
  41. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/kog2p/rulebook.txt +0 -0
  42. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/mantoq/__init__.py +0 -0
  43. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/mantoq/buck/__init__.py +0 -0
  44. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/mantoq/buck/phonetise_buckwalter.py +0 -0
  45. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/mantoq/buck/symbols.py +0 -0
  46. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/mantoq/buck/tokenization.py +0 -0
  47. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/mantoq/num2words.py +0 -0
  48. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/mantoq/pyarabic/__init__.py +0 -0
  49. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/mantoq/pyarabic/arabrepr.py +0 -0
  50. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/mantoq/pyarabic/araby.py +0 -0
  51. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/mantoq/pyarabic/named_const.py +0 -0
  52. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/mantoq/pyarabic/normalize.py +0 -0
  53. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/mantoq/pyarabic/number.py +0 -0
  54. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/mantoq/pyarabic/number_const.py +0 -0
  55. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/mantoq/pyarabic/stack.py +0 -0
  56. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/mantoq/pyarabic/trans.py +0 -0
  57. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/mantoq/unicode_symbol2label.py +0 -0
  58. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/tashkeel/LICENSE +0 -0
  59. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/tashkeel/SOURCE +0 -0
  60. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/tashkeel/__init__.py +0 -0
  61. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/tashkeel/hint_id_map.json +0 -0
  62. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/tashkeel/input_id_map.json +0 -0
  63. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/tashkeel/model.onnx +0 -0
  64. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/tashkeel/target_id_map.json +0 -0
  65. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/thirdparty/zh_num.py +0 -0
  66. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/util.py +0 -0
  67. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx/voice.py +0 -0
  68. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx.egg-info/dependency_links.txt +0 -0
  69. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx.egg-info/requires.txt +0 -0
  70. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx.egg-info/top_level.txt +0 -0
  71. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx_train/__main__.py +0 -0
  72. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx_train/export_onnx.py +0 -0
  73. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx_train/norm_audio/__init__.py +0 -0
  74. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx_train/norm_audio/trim.py +0 -0
  75. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx_train/norm_audio/vad.py +0 -0
  76. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx_train/preprocess.py +0 -0
  77. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx_train/vits/__init__.py +0 -0
  78. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx_train/vits/attentions.py +0 -0
  79. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx_train/vits/commons.py +0 -0
  80. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx_train/vits/config.py +0 -0
  81. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx_train/vits/dataset.py +0 -0
  82. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx_train/vits/lightning.py +0 -0
  83. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx_train/vits/losses.py +0 -0
  84. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx_train/vits/mel_processing.py +0 -0
  85. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx_train/vits/models.py +0 -0
  86. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx_train/vits/modules.py +0 -0
  87. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx_train/vits/monotonic_align/__init__.py +0 -0
  88. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx_train/vits/monotonic_align/setup.py +0 -0
  89. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx_train/vits/transforms.py +0 -0
  90. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx_train/vits/utils.py +0 -0
  91. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/phoonnx_train/vits/wavfile.py +0 -0
  92. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/setup.cfg +0 -0
  93. {phoonnx-0.0.2a2 → phoonnx-0.1.0a1}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: phoonnx
3
- Version: 0.0.2a2
3
+ Version: 0.1.0a1
4
4
  Home-page: https://github.com/TigreGotico/phoonnx
5
5
  Author: JarbasAi
6
6
  Author-email: jarbasai@mailfence.com
@@ -0,0 +1,106 @@
1
+ from phoonnx.phonemizers.base import BasePhonemizer
2
+ from phoonnx.thirdparty.mantoq import g2p as mantoq
3
+ from phoonnx.config import Alphabet
4
+ from phoonnx.thirdparty.bw2ipa import translate as bw2ipa
5
+
6
+
7
+ class MantoqPhonemizer(BasePhonemizer):
8
+
9
+ def __init__(self, alphabet=Alphabet.MANTOQ):
10
+ if alphabet not in [Alphabet.IPA, Alphabet.MANTOQ]:
11
+ raise ValueError("unsupported alphabet")
12
+ super().__init__(alphabet)
13
+
14
+ @classmethod
15
+ def get_lang(cls, target_lang: str) -> str:
16
+ """
17
+ Validates and returns the closest supported language code.
18
+
19
+ Args:
20
+ target_lang (str): The language code to validate.
21
+
22
+ Returns:
23
+ str: The validated language code.
24
+
25
+ Raises:
26
+ ValueError: If the language code is unsupported.
27
+ """
28
+ # this check is here only to throw an exception if invalid language is provided
29
+ return cls.match_lang(target_lang, ["ar"])
30
+
31
+ def phonemize_string(self, text: str, lang: str = "ar") -> str:
32
+ """
33
+ Phonemizes an Arabic string using the Mantoq G2P tool.
34
+ If the alphabet is set to IPA, it then converts the result using bw2ipa.
35
+ """
36
+ lang = self.get_lang(lang)
37
+ # The mantoq function returns a tuple of (normalized_text, phonemes)
38
+ normalized_text, phonemes = mantoq(text)
39
+
40
+ # The phonemes are a list of characters, we join them into a string
41
+ # and replace the word separator token with a space.
42
+ phonemes = "".join(phonemes).replace("_+_", " ")
43
+
44
+ if self.alphabet == Alphabet.IPA:
45
+ # If the alphabet is IPA, we use the bw2ipa function to translate
46
+ # the Buckwalter-like phonemes into IPA.
47
+ return bw2ipa(phonemes)
48
+
49
+ # Otherwise, we return the phonemes in the default Mantoq alphabet.
50
+ return phonemes
51
+
52
+
53
+ if __name__ == "__main__":
54
+ # Initialize phonemizers for both MANTOQ and IPA alphabets
55
+ pho_mantoq = MantoqPhonemizer()
56
+ pho_ipa = MantoqPhonemizer(alphabet=Alphabet.IPA)
57
+
58
+ text1 = "مرحبا بالعالم"
59
+ print(f"Original Text: {text1}")
60
+ print(f" Mantoq Phonemizer: {pho_mantoq.phonemize_string(text1, 'ar')}")
61
+ print(f" IPA Phonemizer: {pho_ipa.phonemize_string(text1, 'ar')}")
62
+ print("-" * 20)
63
+
64
+ text2 = "ذهب الطالب إلى المكتبة لقراءة كتاب عن تاريخ الأندلس."
65
+ print(f"Original Text: {text2}")
66
+ print(f" Mantoq Phonemizer: {pho_mantoq.phonemize_string(text2, 'ar')}")
67
+ print(f" IPA Phonemizer: {pho_ipa.phonemize_string(text2, 'ar')}")
68
+ print("-" * 20)
69
+
70
+ # --- New Test Cases to check bw2ipa logic ---
71
+ print("--- New Test Cases for bw2ipa logic ---")
72
+
73
+ # 1. Test for gemination of a sun letter (e.g., ash-shams)
74
+ text3 = "الشمس"
75
+ print(f"Original Text: '{text3}'")
76
+ print(f" Mantoq Phonemizer: {pho_mantoq.phonemize_string(text3, 'ar')}")
77
+ print(f" IPA Phonemizer: {pho_ipa.phonemize_string(text3, 'ar')}")
78
+ print("-" * 20)
79
+
80
+ # 2. Test for long vowels (e.g., 'fil' - elephant)
81
+ text4 = "فيل"
82
+ print(f"Original Text: '{text4}'")
83
+ print(f" Mantoq Phonemizer: {pho_mantoq.phonemize_string(text4, 'ar')}")
84
+ print(f" IPA Phonemizer: {pho_ipa.phonemize_string(text4, 'ar')}")
85
+ print("-" * 20)
86
+
87
+ # 3. Test for glide (e.g., 'yawm' - day)
88
+ text5 = "يوم"
89
+ print(f"Original Text: '{text5}'")
90
+ print(f" Mantoq Phonemizer: {pho_mantoq.phonemize_string(text5, 'ar')}")
91
+ print(f" IPA Phonemizer: {pho_ipa.phonemize_string(text5, 'ar')}")
92
+ print("-" * 20)
93
+
94
+ # 4. Test for long vowels (e.g., 'suwr' - wall)
95
+ text6 = "سور"
96
+ print(f"Original Text: '{text6}'")
97
+ print(f" Mantoq Phonemizer: {pho_mantoq.phonemize_string(text6, 'ar')}")
98
+ print(f" IPA Phonemizer: {pho_ipa.phonemize_string(text6, 'ar')}")
99
+ print("-" * 20)
100
+
101
+ # 5. Test for glide (e.g., 'law' - if)
102
+ text7 = "لو"
103
+ print(f"Original Text: '{text7}'")
104
+ print(f" Mantoq Phonemizer: {pho_mantoq.phonemize_string(text7, 'ar')}")
105
+ print(f" IPA Phonemizer: {pho_ipa.phonemize_string(text7, 'ar')}")
106
+ print("-" * 20)
@@ -0,0 +1,66 @@
1
+ # -*- coding: UTF8 -*-
2
+ """
3
+ This script translates Buckwalter-transcribed Modern Standard Arabic to IPA.
4
+
5
+ This relies on Mantoq tokenization that uses separate tokens for vowel length and consonant gemination.
6
+
7
+ by Casimiro Ferreira with help of Gemini July 2025.
8
+ """
9
+
10
+ import re
11
+
12
+ # This dictionary maps a single Buckwalter character to its most common IPA equivalent.
13
+ char_dict = {
14
+ 'a': 'a', 'A': 'aː', 'b': 'b', 'c': 'x', 'd': 'd', 'D': 'dˤ', 'e': 'e', 'E': 'ʕ',
15
+ 'f': 'f', 'g': 'ɣ', 'h': 'h', 'H': 'ħ', 'i': 'i', 'I': 'iː', 'j': 'ʒ', 'k': 'k',
16
+ 'l': 'l', 'm': 'm', 'n': 'n', 'p': 'p', 'q': 'q', 'r': 'r', 'R': 'r', 's': 's',
17
+ 'S': 'sˤ', 't': 't', 'T': 'tˤ', 'u': 'u', 'U': 'uː', 'v': 'v', 'w': 'w', 'x': 'x',
18
+ 'y': 'j', 'z': 'z', 'Z': 'ðˤ', '\'': 'ʔ', '<': 'ʔ', 'o': 'o', '-': ' ',
19
+ '*': 'ð', '$': 'ʃ'
20
+ }
21
+ _vowels = {'a', 'i', 'u', 'aː', 'iː', 'uː'}
22
+
23
+
24
+ def translate(buckwalter_text: str) -> str:
25
+ """
26
+ Translates a Buckwalter-transcribed string into an IPA string.
27
+
28
+ Args:
29
+ buckwalter_text (str): The Buckwalter string to translate.
30
+
31
+ Returns:
32
+ str: The translated IPA string.
33
+ """
34
+ ipa_list = []
35
+ i = 0
36
+ while i < len(buckwalter_text):
37
+ # Check for the longest token first. The new Mantoq tokenization
38
+ # seems to use a 5-character token.
39
+ token = buckwalter_text[i:i + 5]
40
+
41
+ # If the previous character was a vowel, we assume it's a long vowel
42
+ # marker (ː). Otherwise, we assume it's a geminated consonant.
43
+ if token == '_dbl_':
44
+ if ipa_list and ipa_list[-1] in _vowels:
45
+ ipa_list.append('ː') # Add length marker for long vowels
46
+ elif ipa_list:
47
+ ipa_list.append(ipa_list[-1]) # Duplicate the consonant
48
+ i += 5
49
+ continue
50
+
51
+ # Check for multi-character mappings from char_dict
52
+ two_char_token = buckwalter_text[i:i + 2]
53
+ if two_char_token in char_dict:
54
+ ipa_list.append(char_dict[two_char_token])
55
+ i += 2
56
+ continue
57
+
58
+ # Handle single characters
59
+ single_char = buckwalter_text[i]
60
+ if single_char in char_dict:
61
+ ipa_list.append(char_dict[single_char])
62
+ else:
63
+ ipa_list.append(single_char)
64
+ i += 1
65
+
66
+ return ''.join(ipa_list)
@@ -1,6 +1,6 @@
1
1
  # START_VERSION_BLOCK
2
2
  VERSION_MAJOR = 0
3
- VERSION_MINOR = 0
4
- VERSION_BUILD = 2
5
- VERSION_ALPHA = 2
3
+ VERSION_MINOR = 1
4
+ VERSION_BUILD = 0
5
+ VERSION_ALPHA = 1
6
6
  # END_VERSION_BLOCK
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: phoonnx
3
- Version: 0.0.2a2
3
+ Version: 0.1.0a1
4
4
  Home-page: https://github.com/TigreGotico/phoonnx
5
5
  Author: JarbasAi
6
6
  Author-email: jarbasai@mailfence.com
@@ -29,6 +29,7 @@ phoonnx/phonemizers/vi.py
29
29
  phoonnx/phonemizers/zh.py
30
30
  phoonnx/thirdparty/__init__.py
31
31
  phoonnx/thirdparty/arpa2ipa.py
32
+ phoonnx/thirdparty/bw2ipa.py
32
33
  phoonnx/thirdparty/hangul2ipa.py
33
34
  phoonnx/thirdparty/zh_num.py
34
35
  phoonnx/thirdparty/cotovia/cotovia_aarch64
@@ -93,6 +94,7 @@ phoonnx_train/../phoonnx/phonemizers/vi.py
93
94
  phoonnx_train/../phoonnx/phonemizers/zh.py
94
95
  phoonnx_train/../phoonnx/thirdparty/__init__.py
95
96
  phoonnx_train/../phoonnx/thirdparty/arpa2ipa.py
97
+ phoonnx_train/../phoonnx/thirdparty/bw2ipa.py
96
98
  phoonnx_train/../phoonnx/thirdparty/hangul2ipa.py
97
99
  phoonnx_train/../phoonnx/thirdparty/zh_num.py
98
100
  phoonnx_train/../phoonnx/thirdparty/cotovia/cotovia_aarch64
@@ -1,42 +0,0 @@
1
- from phoonnx.phonemizers.base import BasePhonemizer
2
- from phoonnx.thirdparty.mantoq import g2p as mantoq
3
- from phoonnx.config import Alphabet
4
-
5
- class MantoqPhonemizer(BasePhonemizer):
6
-
7
- def __init__(self):
8
- super().__init__(Alphabet.MANTOQ)
9
-
10
- @classmethod
11
- def get_lang(cls, target_lang: str) -> str:
12
- """
13
- Validates and returns the closest supported language code.
14
-
15
- Args:
16
- target_lang (str): The language code to validate.
17
-
18
- Returns:
19
- str: The validated language code.
20
-
21
- Raises:
22
- ValueError: If the language code is unsupported.
23
- """
24
- # this check is here only to throw an exception if invalid language is provided
25
- return cls.match_lang(target_lang, ["ar"])
26
-
27
- def phonemize_string(self, text: str, lang: str = "ar") -> str:
28
- """
29
- """
30
- lang = self.get_lang(lang)
31
- normalized_text, phonemes = mantoq(text)
32
- return "".join(phonemes).replace("_+_", " ")
33
-
34
-
35
- if __name__ == "__main__":
36
- text = "مرحبا بالعالم"
37
- # gets normalized to
38
- # مَرْحَبًا بِالْعالَم
39
-
40
- pho = MantoqPhonemizer()
41
- print(pho.phonemize(text, "ar"))
42
- # [('m a r H a b a n aa b i l E aa l a m', '.', True)]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes