gapiring 0.1.0__tar.gz → 0.1.2__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 (50) hide show
  1. gapiring-0.1.2/LICENSE +24 -0
  2. gapiring-0.1.2/PKG-INFO +100 -0
  3. gapiring-0.1.0/src/gapiring.egg-info/PKG-INFO → gapiring-0.1.2/README.md +13 -24
  4. {gapiring-0.1.0 → gapiring-0.1.2}/pyproject.toml +2 -1
  5. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/__init__.py +3 -3
  6. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/engine.py +9 -4
  7. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/frontend/tashkent_dialect.py +0 -6
  8. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/frontend/text_to_phoneme/phoneme_converter.py +0 -25
  9. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/frontend/text_to_phoneme/pipelene_text_to_phoneme.py +0 -6
  10. gapiring-0.1.2/src/gapiring/frontend/text_to_phoneme/text_normalization_for_tts.py +65 -0
  11. gapiring-0.1.2/src/gapiring/frontend/text_to_phoneme/tools/convert_currency_to_text.py +39 -0
  12. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/frontend/text_to_phoneme/tools/convert_date_time_to_text.py +0 -44
  13. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/frontend/text_to_phoneme/tools/convert_non_roman_numbers_to_text.py +0 -91
  14. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/frontend/text_to_phoneme/tools/convert_phone_numbers_to_text.py +0 -109
  15. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/frontend/text_to_phoneme/tools/convert_roman_numerals_to_text.py +0 -34
  16. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/frontend/text_to_phoneme/tools/convert_symbols_to_uzbek_text.py +0 -98
  17. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/frontend/text_to_phoneme/tools/expand_uzbek_abbreviations.py +0 -111
  18. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/frontend/text_to_phoneme/tools/full_normalize.py +0 -73
  19. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/frontend/text_to_phoneme/tools/pronounce_links_and_emails.py +0 -18
  20. gapiring-0.1.2/src/gapiring/frontend/text_to_phoneme/tools/split_text_numbers.py +9 -0
  21. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/frontend/textnorm.py +1 -37
  22. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/frontend/tts_frontend.py +0 -8
  23. gapiring-0.1.2/src/gapiring.egg-info/PKG-INFO +100 -0
  24. gapiring-0.1.0/LICENSE +0 -4
  25. gapiring-0.1.0/PKG-INFO +0 -69
  26. gapiring-0.1.0/README.md +0 -50
  27. gapiring-0.1.0/src/gapiring/frontend/text_to_phoneme/text_normalization_for_tts.py +0 -208
  28. gapiring-0.1.0/src/gapiring/frontend/text_to_phoneme/tools/convert_currency_to_text.py +0 -76
  29. gapiring-0.1.0/src/gapiring/frontend/text_to_phoneme/tools/split_text_numbers.py +0 -36
  30. {gapiring-0.1.0 → gapiring-0.1.2}/setup.cfg +0 -0
  31. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/__main__.py +0 -0
  32. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/cli.py +0 -0
  33. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/frontend/__init__.py +0 -0
  34. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/frontend/common.py +0 -0
  35. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/frontend/lexicon_extra.tsv +0 -0
  36. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/frontend/terms.py +0 -0
  37. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/frontend/terms_reviewed.json +0 -0
  38. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/frontend/terms_uz.py +0 -0
  39. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/frontend/text_to_phoneme/__init__.py +0 -0
  40. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/frontend/text_to_phoneme/tools/__init__.py +0 -0
  41. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/frontend/text_to_phoneme/tools/spoken_lexicon.py +0 -0
  42. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/frontend/text_to_phoneme/tools/spoken_prepass.py +0 -0
  43. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/frontend/text_to_phoneme/uzbek_orthography.py +0 -0
  44. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/lexicon.py +0 -0
  45. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring/text_front.py +0 -0
  46. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring.egg-info/SOURCES.txt +0 -0
  47. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring.egg-info/dependency_links.txt +0 -0
  48. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring.egg-info/entry_points.txt +0 -0
  49. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring.egg-info/requires.txt +0 -0
  50. {gapiring-0.1.0 → gapiring-0.1.2}/src/gapiring.egg-info/top_level.txt +0 -0
gapiring-0.1.2/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ Gapiring is open source: free for any use, commercial use included.
2
+
3
+ 1. Code (the runtimes, the libraries, the text normaliser): MIT License
4
+
5
+ Copyright (c) 2026 Gapi (https://gapi.uz)
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
8
+ documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
9
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
10
+ persons to whom the Software is furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
13
+ Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
16
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
18
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
+
20
+ 2. Model files, voices and dictionary: Creative Commons Attribution 4.0 International (CC BY 4.0)
21
+ https://creativecommons.org/licenses/by/4.0/
22
+
23
+ Credit to give when you share them or what you make from them: "Gapiring by Gapi (https://gapi.uz), an adaptation of
24
+ Kyutai Pocket TTS (https://huggingface.co/kyutai/pocket-tts), CC BY 4.0".
@@ -0,0 +1,100 @@
1
+ Metadata-Version: 2.4
2
+ Name: gapiring
3
+ Version: 0.1.2
4
+ Summary: Uzbek text-to-speech on a CPU: two voices, roles and manners by name, streaming audio
5
+ License: Gapiring is open source: free for any use, commercial use included.
6
+
7
+ 1. Code (the runtimes, the libraries, the text normaliser): MIT License
8
+
9
+ Copyright (c) 2026 Gapi (https://gapi.uz)
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
12
+ documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
13
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
14
+ persons to whom the Software is furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
17
+ Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
21
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ 2. Model files, voices and dictionary: Creative Commons Attribution 4.0 International (CC BY 4.0)
25
+ https://creativecommons.org/licenses/by/4.0/
26
+
27
+ Credit to give when you share them or what you make from them: "Gapiring by Gapi (https://gapi.uz), an adaptation of
28
+ Kyutai Pocket TTS (https://huggingface.co/kyutai/pocket-tts), CC BY 4.0".
29
+
30
+ Keywords: tts,text-to-speech,uzbek,onnx,edge
31
+ Classifier: License :: OSI Approved :: MIT License
32
+ Classifier: Programming Language :: Python :: 3
33
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
34
+ Requires-Python: >=3.10
35
+ Description-Content-Type: text/markdown
36
+ License-File: LICENSE
37
+ Requires-Dist: numpy
38
+ Requires-Dist: onnxruntime>=1.23
39
+ Requires-Dist: tokenizers
40
+ Requires-Dist: huggingface_hub
41
+ Dynamic: license-file
42
+
43
+ # Gapiring
44
+
45
+ Uzbek text-to-speech that runs on an ordinary CPU, with no GPU and no server. Two voices (`f1` female, `m1` male), a
46
+ **role** and a **manner** of speech by name, including an emotional mode, and audio that streams as it is made.
47
+
48
+ ```bash
49
+ pip install gapiring
50
+ gapiring say "Assalomu alaykum! Namuna kompaniyasining virtual yordamchisiman, sizga qanday yordam bera olaman?" --voice f1 --role assistant --manner warm --out hello.wav
51
+ ```
52
+
53
+ ```python
54
+ from gapiring import Gapiring
55
+
56
+ tts = Gapiring("edge", dictionary=True, normalize="literary")
57
+ tts.save("meeting.wav", "Uchrashuv 25-noyabr soat 14:30 da, to'lov Payme orqali, narxi 1 250 000 so'm.", voice="m1", role="operator", manner="calm")
58
+
59
+ for chunk in tts.stream("Oyimning tug'ilgan kuniga sovg'a buyurtma qilgandim, [sigh] vaqtida olib kelmadinglar, rosa xafa bo'ldim to'g'risi.", voice="f1", role="emotional", manner="upset"):
60
+ play(chunk) # float32, 24 kHz mono, the first chunk after about 20 ms on a desktop CPU
61
+ ```
62
+
63
+ | | `edge` | `large` |
64
+ | --- | --- | --- |
65
+ | Transformer layers | 6 | 24 |
66
+ | Download | 117 MB (int8) | 346 MB (int8) or 1.3 GB (full precision) |
67
+ | Speed, 2 CPU threads | about 10x real time | about 4x real time (int8) |
68
+ | For | CPU, phone class devices | server, desktop |
69
+
70
+ The model files are downloaded from the public repository `islomov/gapi-uz-gapiring-v1` on Hugging Face on first use and
71
+ cached; with the files already on disk, pass `Gapiring("edge", path="folder")`.
72
+
73
+ ## Roles and manners
74
+
75
+ | `role` | `manner` |
76
+ | --- | --- |
77
+ | `operator` | `neutral` `warm` `cheerful` `empathetic` `calm` `dictation` `persuasive` `brisk` |
78
+ | `assistant` | `neutral` `warm` `cheerful` `empathetic` `calm` `dictation` `soothing` |
79
+ | `emotional` | `angry` `upset` `irritated` `worried` `tired` `sceptical` `confused` `hurried` `joking` `grateful` `curious` `friendly` `calm` `elderly` |
80
+
81
+ `gapiring manners` prints the same list. Sounds go inside the text: `[laugh]`, `[sigh]`, `[pause]`, `[breath]`.
82
+ Give the model one sentence or a short paragraph per call.
83
+
84
+ ## Text
85
+
86
+ `normalize="literary"` reads numbers, dates, times, money, percentages, units and phone numbers out as words and
87
+ turns Cyrillic into Uzbek Latin; `"conversational"` also uses the Tashkent spoken forms. `dictionary=True` reads English
88
+ words, brands and acronyms the Uzbek way (Payme -> Peymi, CRM -> si-ar-em, deadline -> dedlayn); it takes about 4 s and
89
+ 400 MB to load, so leave it out on small devices when the text has no English. `tts.said(text)` shows the text as the
90
+ voice gets it.
91
+
92
+ Dependencies: numpy, onnxruntime, tokenizers, huggingface_hub. Built on Kyutai Pocket TTS (CC-BY-4.0).
93
+
94
+ Synthesis runs on your machine; after the model is downloaded nothing is sent anywhere. Recent ONNX Runtime builds
95
+ report usage to Microsoft by default: this package switches that off (`ORT_DISABLE_TELEMETRY=1`) when it is imported,
96
+ so import `gapiring` before `onnxruntime` if you use both. A value you set yourself is left alone.
97
+
98
+ ## Licence
99
+
100
+ Open source, free for any use, commercial use included. The code is under the MIT licence; the model files, voices and dictionary are under CC BY 4.0 (credit: Gapiring by Gapi, an adaptation of Kyutai Pocket TTS). Full text: `LICENSE`.
@@ -1,22 +1,3 @@
1
- Metadata-Version: 2.4
2
- Name: gapiring
3
- Version: 0.1.0
4
- Summary: Uzbek text-to-speech on a CPU: two voices, roles and manners by name, streaming audio
5
- License: Gapiring: licence terms are not published yet. Until they are, all rights are reserved and this package is
6
- for evaluation by people the authors gave it to.
7
-
8
- The models are built on Kyutai Pocket TTS, licensed under CC-BY-4.0.
9
-
10
- Keywords: tts,text-to-speech,uzbek,onnx,edge
11
- Requires-Python: >=3.10
12
- Description-Content-Type: text/markdown
13
- License-File: LICENSE
14
- Requires-Dist: numpy
15
- Requires-Dist: onnxruntime>=1.23
16
- Requires-Dist: tokenizers
17
- Requires-Dist: huggingface_hub
18
- Dynamic: license-file
19
-
20
1
  # Gapiring
21
2
 
22
3
  Uzbek text-to-speech that runs on an ordinary CPU, with no GPU and no server. Two voices (`f1` female, `m1` male), a
@@ -24,16 +5,16 @@ Uzbek text-to-speech that runs on an ordinary CPU, with no GPU and no server. Tw
24
5
 
25
6
  ```bash
26
7
  pip install gapiring
27
- gapiring say "Assalomu alaykum! Sizga qanday yordam bera olaman?" --voice f1 --role assistant --manner warm --out hello.wav
8
+ gapiring say "Assalomu alaykum! Namuna kompaniyasining virtual yordamchisiman, sizga qanday yordam bera olaman?" --voice f1 --role assistant --manner warm --out hello.wav
28
9
  ```
29
10
 
30
11
  ```python
31
12
  from gapiring import Gapiring
32
13
 
33
14
  tts = Gapiring("edge", dictionary=True, normalize="literary")
34
- tts.save("order.wav", "Buyurtmangiz 25-noyabr soat 14:30 da yetkaziladi, to'lov Payme orqali.", voice="m1", role="operator", manner="calm")
15
+ tts.save("meeting.wav", "Uchrashuv 25-noyabr soat 14:30 da, to'lov Payme orqali, narxi 1 250 000 so'm.", voice="m1", role="operator", manner="calm")
35
16
 
36
- for chunk in tts.stream("Oyimning tug'ilgan kuniga sovg'a buyurtma qilgandim.", voice="f1", role="emotional", manner="upset"):
17
+ for chunk in tts.stream("Oyimning tug'ilgan kuniga sovg'a buyurtma qilgandim, [sigh] vaqtida olib kelmadinglar, rosa xafa bo'ldim to'g'risi.", voice="f1", role="emotional", manner="upset"):
37
18
  play(chunk) # float32, 24 kHz mono, the first chunk after about 20 ms on a desktop CPU
38
19
  ```
39
20
 
@@ -44,8 +25,8 @@ for chunk in tts.stream("Oyimning tug'ilgan kuniga sovg'a buyurtma qilgandim.",
44
25
  | Speed, 2 CPU threads | about 10x real time | about 4x real time (int8) |
45
26
  | For | CPU, phone class devices | server, desktop |
46
27
 
47
- The model files are downloaded from `islomov/gapi-uz-gapiring-v1` on first use and cached. While that repository is private,
48
- set `HF_TOKEN` to a token with access to it.
28
+ The model files are downloaded from the public repository `islomov/gapi-uz-gapiring-v1` on Hugging Face on first use and
29
+ cached; with the files already on disk, pass `Gapiring("edge", path="folder")`.
49
30
 
50
31
  ## Roles and manners
51
32
 
@@ -67,3 +48,11 @@ words, brands and acronyms the Uzbek way (Payme -> Peymi, CRM -> si-ar-em, deadl
67
48
  voice gets it.
68
49
 
69
50
  Dependencies: numpy, onnxruntime, tokenizers, huggingface_hub. Built on Kyutai Pocket TTS (CC-BY-4.0).
51
+
52
+ Synthesis runs on your machine; after the model is downloaded nothing is sent anywhere. Recent ONNX Runtime builds
53
+ report usage to Microsoft by default: this package switches that off (`ORT_DISABLE_TELEMETRY=1`) when it is imported,
54
+ so import `gapiring` before `onnxruntime` if you use both. A value you set yourself is left alone.
55
+
56
+ ## Licence
57
+
58
+ Open source, free for any use, commercial use included. The code is under the MIT licence; the model files, voices and dictionary are under CC BY 4.0 (credit: Gapiring by Gapi, an adaptation of Kyutai Pocket TTS). Full text: `LICENSE`.
@@ -4,11 +4,12 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "gapiring"
7
- version = "0.1.0"
7
+ version = "0.1.2"
8
8
  description = "Uzbek text-to-speech on a CPU: two voices, roles and manners by name, streaming audio"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
11
11
  license = {file = "LICENSE"}
12
+ classifiers = ["License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Topic :: Multimedia :: Sound/Audio :: Speech"]
12
13
  keywords = ["tts", "text-to-speech", "uzbek", "onnx", "edge"]
13
14
  dependencies = ["numpy", "onnxruntime>=1.23", "tokenizers", "huggingface_hub"]
14
15
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  from gapiring import Gapiring
4
4
  tts = Gapiring("edge") # or "large"; fetched once, then cached
5
- tts.save("hello.wav", "Assalomu alaykum! Sizga qanday yordam bera olaman?", voice="f1", role="assistant", manner="warm")
6
- for chunk in tts.stream("Buyurtmangiz yo'lda.", voice="m1", role="operator", manner="calm"):
5
+ tts.save("hello.wav", "Assalomu alaykum! Namuna kompaniyasining virtual yordamchisiman, sizga qanday yordam bera olaman?", voice="f1", role="assistant", manner="warm")
6
+ for chunk in tts.stream("Bugun obunani rasmiylashtirsangiz, birinchi oy uchun to'liq ellik foiz chegirma beriladi, imkoniyatni qo'ldan boy bermang.", voice="m1", role="operator", manner="calm"):
7
7
  play(chunk) # float32, 24 kHz, as it is made
8
8
  """
9
9
 
@@ -17,7 +17,7 @@ import numpy as np
17
17
 
18
18
  from .engine import MANNERS, ROLE_MANNERS, PocketONNX
19
19
 
20
- __version__ = "0.1.0"
20
+ __version__ = "0.1.2"
21
21
  __all__ = ["Gapiring", "MODELS", "VOICES", "ROLES", "manners", "SAMPLE_RATE"]
22
22
 
23
23
  REPO = os.environ.get("GAPIRING_REPO", "islomov/gapi-uz-gapiring-v1")
@@ -15,16 +15,21 @@ from __future__ import annotations
15
15
 
16
16
  import argparse
17
17
  import json
18
+ import os
18
19
  import re
19
20
  import time
20
21
  from pathlib import Path
21
22
 
22
- import numpy as np
23
- import onnxruntime as ort
23
+ # ONNX Runtime's official builds (seen with 1.32 on Linux; 1.23 has none) send usage events to Microsoft by default.
24
+ # Only this variable, set before the library is loaded, stops it; a value the user set is left alone.
25
+ os.environ.setdefault("ORT_DISABLE_TELEMETRY", "1")
26
+
27
+ import numpy as np # noqa: E402
28
+ import onnxruntime as ort # noqa: E402
24
29
 
25
30
  EVENTS = {"[laugh]": "§", "[pause]": "¦", "[breath]": "¶", "[sigh]": "¤"}
26
- # roles and manners by name (owner 2026-11-23: the symbols stay in the code): operator, assistant, and emotional mode
27
- ROLES = {"operator": "\u2460", "assistant": "\u2462", "emotional": "\u2461"} # emotional: a caller with a feeling (owner 2026-11-23)
31
+ # roles and manners by name: operator, assistant, and emotional mode
32
+ ROLES = {"operator": "\u2460", "assistant": "\u2462", "emotional": "\u2461"} # emotional: a caller with a feeling
28
33
  MANNERS = {"calm": "\u2464", "neutral": "\u2472", "warm": "\u2473", "cheerful": "\u2474", "empathetic": "\u2475",
29
34
  "dictation": "\u2476", "persuasive": "\u2477", "brisk": "\u2478", "soothing": "\u2479", "angry": "\u246c", "upset": "\u246e", "irritated": "\u246b", "worried": "\u246d", "tired": "\u2470", "sceptical": "\u246f", "confused": "\u2469", "hurried": "\u246a", "joking": "\u2466", "grateful": "\u2467", "curious": "\u2468", "friendly": "\u2465", "elderly": "\u2471"}
30
35
  ROLE_MANNERS = {"operator": ("neutral", "warm", "cheerful", "empathetic", "calm", "dictation", "persuasive", "brisk"),
@@ -214,9 +214,3 @@ def russian_only(text: str) -> str:
214
214
  return WORD.sub(sub, s)
215
215
 
216
216
 
217
- if __name__ == "__main__":
218
- for line in sys.argv[1:] or [sys.stdin.read()]:
219
- out, changes = convert(line)
220
- print(out)
221
- for a, b, r in changes:
222
- print(f" {a} -> {b} [{', '.join(r)}]")
@@ -302,28 +302,3 @@ def uzbek_to_ipa_final(text: str) -> str:
302
302
  return stressed_ipa_str_final
303
303
 
304
304
 
305
- if __name__ == '__main__':
306
-
307
- words_uz = [
308
- "Oʻzbekiston", "yaxshi", "kitoblar", "senga", "qizsiz",
309
- "iloji yoʻq", "telefonda", "mening", "Talabamisiz",
310
- "Gʻalabaning", "ketdi", "nonvoy", "keldi", "keldimi",
311
- "tong", "koʻngil", "sut", "yozdi", "yuzta", "e'lon", "ma'no", "sahifa",
312
- "bilan", "uchun", "qiziq", "tushun", "iste'mol", "xususiyat", "mustaqillik",
313
- "aytishicha", "institut", "koʻrsatkich", "bilimdonlik", "kitob", "ishchi", "yutuq",
314
- "qir", "xirmon", "ipak", "qishloq", "iqtisod", "qoʻshiqchi", "tarixiy", "aqlli",
315
- "mix", "nikotin", "xirurg",
316
- "bilim", "kirim", "sizniki"
317
- ]
318
-
319
- print("Script Results with standard apostrophe variants:")
320
- for w_uz in words_uz:
321
- ipa_transcription = uzbek_to_ipa_final(w_uz)
322
- print(f"{w_uz} -> {ipa_transcription}")
323
-
324
- print("\nPotentially problematic words:")
325
- problematic_words = ["kel", "men", "sen", "bor", "yoʻq", "bu", "shu", "ish", "hid"]
326
- for w_uz in problematic_words:
327
- ipa_transcription = uzbek_to_ipa_final(w_uz)
328
- print(f"{w_uz} -> {ipa_transcription}")
329
-
@@ -47,9 +47,3 @@ def is_punctuation_or_symbol(word):
47
47
  return all(char in skip_chars for char in word)
48
48
 
49
49
 
50
- if __name__ == "__main__":
51
- input_text = "1-yanvar, 2025-yil soat 09:00 da OʻzMUda $10 evaziga imtihon boʻladi."
52
-
53
- normalized, phonemized = pipeline_text_to_phoneme(input_text)
54
- print("Normalized:", normalized)
55
- print("Phonemized:", phonemized)
@@ -0,0 +1,65 @@
1
+ import re
2
+ from typing import List, Tuple
3
+
4
+ from gapiring.frontend.text_to_phoneme.uzbek_orthography import normalize_uzbek_apostrophes
5
+ from gapiring.frontend.text_to_phoneme.tools.convert_currency_to_text import convert_currency_to_text
6
+ from gapiring.frontend.text_to_phoneme.tools.convert_date_time_to_text import convert_date_time_to_text
7
+ from gapiring.frontend.text_to_phoneme.tools.full_normalize import full_normalize
8
+ from gapiring.frontend.text_to_phoneme.tools.convert_non_roman_numbers_to_text import convert_non_roman_numbers_to_text
9
+ from gapiring.frontend.text_to_phoneme.tools.split_text_numbers import split_text_numbers
10
+ from gapiring.frontend.text_to_phoneme.tools.convert_phone_numbers_to_text import convert_phone_numbers_to_text
11
+ from gapiring.frontend.text_to_phoneme.tools.convert_roman_numerals_to_text import convert_roman_numerals_to_text
12
+ from gapiring.frontend.text_to_phoneme.tools.pronounce_links_and_emails import pronounce_links_and_emails
13
+ from gapiring.frontend.text_to_phoneme.tools.convert_symbols_to_uzbek_text import convert_symbols_to_uzbek_text
14
+ from gapiring.frontend.text_to_phoneme.tools.expand_uzbek_abbreviations import expand_uzbek_abbreviations
15
+ from gapiring.frontend.text_to_phoneme.tools.spoken_lexicon import hide_terms, restore_terms
16
+ from gapiring.frontend.text_to_phoneme.tools.spoken_prepass import (attach_suffix, convert_decimals, convert_identifiers,
17
+ convert_ranges_and_codes, convert_times)
18
+
19
+ ELLIPSIS_MARKER = "ELLIPSISMARKER"
20
+ HYPHEN_MARKER = "zqhyphenqz"
21
+
22
+ NUMBER_WORDS = ("nol bir ikki uch to'rt besh olti yetti sakkiz to'qqiz o'n yigirma o'ttiz qirq ellik oltmish "
23
+ "yetmish sakson to'qson yuz ming million milliard yarim foiz").split()
24
+ _DETACHED_SUFFIX = re.compile(r"\b(" + "|".join(map(re.escape, NUMBER_WORDS)) +
25
+ r") (dagi|dan|da|gacha|ga|ning|ni|lardan|larda|lar|tadan|tasi|ta)(?![\w'])", re.IGNORECASE)
26
+
27
+
28
+ def _join_detached_suffix(match):
29
+ word, suffix = match.group(1), match.group(2).lower()
30
+ if word.lower() == "bir" and suffix.startswith("ta"):
31
+ return word[:1] + "itta" + suffix[2:]
32
+ return attach_suffix(word, suffix)
33
+
34
+
35
+ def text_normalization_for_tts(text: str) -> str:
36
+
37
+ processed_text = normalize_uzbek_apostrophes(text)
38
+
39
+ processed_text = re.sub(r"(?<=[\w'])\s*(?:\.{3,}|…)", f" {ELLIPSIS_MARKER} ", processed_text)
40
+ processed_text, terms = hide_terms(processed_text)
41
+
42
+ processed_text = convert_times(processed_text)
43
+ processed_text = convert_phone_numbers_to_text(processed_text)
44
+ processed_text = convert_date_time_to_text(processed_text)
45
+ processed_text = convert_ranges_and_codes(processed_text)
46
+ processed_text = convert_identifiers(processed_text)
47
+ processed_text = convert_currency_to_text(processed_text)
48
+ processed_text = expand_uzbek_abbreviations(processed_text)
49
+ processed_text = convert_decimals(processed_text)
50
+ processed_text = pronounce_links_and_emails(processed_text)
51
+ processed_text = convert_symbols_to_uzbek_text(processed_text)
52
+ processed_text = split_text_numbers(processed_text)
53
+ processed_text = convert_roman_numerals_to_text(processed_text)
54
+ processed_text = convert_non_roman_numbers_to_text(processed_text)
55
+
56
+ processed_text = re.sub(r"(?<=[A-Za-z'])-(?=[A-Za-z])", HYPHEN_MARKER, processed_text)
57
+ processed_text = full_normalize(processed_text)
58
+ processed_text = processed_text.replace(HYPHEN_MARKER, "-")
59
+ processed_text = re.sub(rf"\s*{ELLIPSIS_MARKER}", "...", processed_text)
60
+ processed_text = _DETACHED_SUFFIX.sub(_join_detached_suffix, processed_text)
61
+ processed_text = restore_terms(processed_text, terms)
62
+
63
+ return processed_text
64
+
65
+
@@ -0,0 +1,39 @@
1
+ import re
2
+
3
+
4
+ def convert_currency_to_text(text: str) -> str:
5
+
6
+ currency_rules = [
7
+ {"abbr": "USD", "name": "dollar", "symbols": ["$"]},
8
+ {"abbr": "EUR", "name": "yevro", "symbols": ["€", "EUR"]},
9
+ {"abbr": "GBP", "name": "funt sterling", "symbols": ["£"]},
10
+ {"abbr": "UZS", "name": "so'm", "symbols": []},
11
+ {"abbr": "RUB", "name": "rubl", "symbols": ["₽"]},
12
+ {"abbr": "KZT", "name": "tenge", "symbols": ["₸"]},
13
+ {"abbr": "CNY", "name": "yuan", "symbols": ["CN¥"]},
14
+ {"abbr": "JPY", "name": "iyena", "symbols": ["¥"]},
15
+ ]
16
+
17
+ processed_text = text
18
+
19
+ number_pattern = r"((?:\d{1,3}(?:[,']\d{3})+|\d+)(?:\.\d+)?)"
20
+
21
+ for rule in currency_rules:
22
+ full_name = rule["name"]
23
+ abbr_val = rule["abbr"]
24
+
25
+ abbr_regex = re.compile(rf"{number_pattern}\s*{abbr_val}\b", re.IGNORECASE)
26
+ processed_text = abbr_regex.sub(rf"\1 {full_name}", processed_text)
27
+
28
+ for symbol in rule["symbols"]:
29
+ escaped_symbol = re.escape(symbol)
30
+
31
+ symbol_before_regex = re.compile(rf"{escaped_symbol}\s*({number_pattern})")
32
+ processed_text = symbol_before_regex.sub(rf"\1 {full_name}", processed_text)
33
+
34
+ symbol_after_regex = re.compile(rf"({number_pattern})\s*{escaped_symbol}")
35
+ processed_text = symbol_after_regex.sub(rf"\1 {full_name}", processed_text)
36
+
37
+ return processed_text
38
+
39
+
@@ -325,47 +325,3 @@ def convert_date_time_to_text(full_text):
325
325
  return "".join(result_parts)
326
326
 
327
327
 
328
- if __name__ == "__main__":
329
- print("--- Testing individual date_to_uzbek_text ---")
330
- print(f"'10/05/2023' -> {date_to_uzbek_text('10/05/2023')}")
331
- print(f"'Dec. 25, 2024' -> {date_to_uzbek_text('Dec. 25, 2024')}")
332
- print(f"'01/09/1991' -> {date_to_uzbek_text('01/09/1991')}")
333
-
334
- print("\n--- Testing individual time_to_uzbek_text ---")
335
- print(f"'13:00' -> {time_to_uzbek_text('13:00')}")
336
- print(f"'08:05' -> {time_to_uzbek_text('08:05')}")
337
- print(f"'20:05' -> {time_to_uzbek_text('20:05')}")
338
- print(f"'02:05' -> {time_to_uzbek_text('02:05')}")
339
- print(f"'06:00' -> {time_to_uzbek_text('06:00')}")
340
- print(f"'04:00' -> {time_to_uzbek_text('04:00')}")
341
- print(f"'25:00' -> {time_to_uzbek_text('25:00')}")
342
-
343
- print("\n--- Testing process_text_for_dates_and_time (finding and replacing in text) ---")
344
- sample_texts = [
345
- "The event is on 10/05/2023 at 14:30, and the deadline is May 20, 2023.",
346
- "Uchrashuv 15 may 2024 kuni soat 09:00 da. Keyingisi esa 20 dekabr 2024 soat 18:45. Vaqt 20:05.",
347
- "Historical date: 01-01-2000. Future date: 2025/12/31. Meeting time: 10:00, 02:30.",
348
- "Reference: Project started 2022 Jan. 15 (time 11:15) and ended on 15 Fevral 2023.",
349
- "Invalid date 99/99/9999, but valid 03.04.2021 and valid time 00:00.",
350
- "US format: 12/31/2023. Also: 2025 yanvar 05. Va 10 fev. 2026 soat 23:59.",
351
- "Short year test: 01/01/25 (08:08) and meeting on 15 avgust 24. Also 1 mar 27 at 17:00 and 06:10.",
352
- "This text has no dates or times, only numbers like 12345.",
353
- "The date 20.03.2024 is Navruz (begins 05:30), an important holiday.",
354
- "Date: Dec. 25, 2024 (time 20:00) is Christmas. Another one: 5 Sen. 2023.",
355
- "Yana bir sana: 2027 Noy 15. Vaqt: 01:05.",
356
- "01/09/1991 da mustaqil boʻldik.",
357
- "Uchrashuv 14:00 da.",
358
- "Mustaqillik 01/09/1991da boshlandi (no space before suffix - current logic might miss this, needs space).",
359
- "Mustaqillik 01/09/1991 ning tongida boshlandi.",
360
- "10/05/2023ga xat yuborildi.",
361
- "10/05/2023 dan keyin.",
362
- "Invalid date string 01/32/2023da (should not attach 'da' to original if not converted).",
363
- "Valid date 03.04.2021da and also 03.04.2021 dan and time 00:00.",
364
- "Soat 06:00da uchrashamiz.",
365
- "Soat 04:00da uchrashamiz."
366
- ]
367
-
368
- for i, text in enumerate(sample_texts):
369
- print(f"\nOriginal Text {i + 1}: {text}")
370
- processed_text = convert_date_time_to_text(text)
371
- print(f"Processed Text {i + 1}: {processed_text}")
@@ -516,94 +516,3 @@ def convert_non_roman_numbers_to_text(text_input):
516
516
  return text
517
517
 
518
518
 
519
- if __name__ == "__main__":
520
- test_texts_non_roman = [
521
- "Harorat -4 daraja.", "Balans: -25000 so'm.", "Jami 25,000 so'm.", "Jami 25 000 so'm.",
522
- "Son -0.", "Raqam 0.", "Summa: -45.67 so'm", "Qiymat: 15,500.75 dollar.",
523
- "Narx: 15 000.75 yevro.", "Narx: 15 000.00 yevro.", "Narx: 15 000.05 yevro.",
524
- "Narx: 15 000.50 yevro.", "1.1", "101.24", "-5.3", "0.5", "-.5", "-0.5", "-0.05", "-.05",
525
- "-0", "-0.0", "Telefon: 998902345678", "ID: 123456789012345", "Kod: -1234567890123",
526
- "Bu -4test so'zi emas, lekin -4 alohida.", "(-4) va (20-da) test.", "(-4) va (1,200-da) test.",
527
- "Raqamlar: 1, -2, 3.", "1-dars, 2-topshiriq.", "1,500-dars, 20 000-topshiriq.",
528
- "10%", "10.5%", "-15.5%", "%12,345.67", "12 345.67 %", "10-sinf",
529
- "o'n beshinchi asr va 20-asr", "sakkizinchi bobida va 5-band", "uchta olma va 2 ta anor",
530
- "bir ta olma", " ko'p bo'shliq ", "Bu 1,234,567.890 raqami.",
531
- "Bu 1 000 000 sondir.", "Bu 1,000,000 sondir.", "1000", "1001", "1,000", "1 000",
532
- "100.00", "1,000.00", "0.0", "Raqam .5", "Raqam 0.05", "Salbiy -0.5", "Salbiy -.05",
533
- "Hisobda .00 so'm bor", "Qiymat 1.0 so'm", "Qiymat -test so'z", "(-so'z)",
534
- "Qiymat 123.005", "Qiymat 123.050", "Qiymat 123.500",
535
- "1.2.3. Bu versiya raqami.",
536
- "Versiya 10.2.5 ishlatilmoqda.",
537
- "IP manzil: 192.168.1.1",
538
- "Narx 1.2 million so'm, versiya 4.0.1 da.",
539
- "Versiya 2.007.1",
540
- "ID 10.0.0.1 host",
541
- "Test 0.0.0.0",
542
- "Test 001.002.00100",
543
- ]
544
-
545
- print("Rim raqamlarisiz matnni normallashtirish:\n")
546
- for text_input in test_texts_non_roman:
547
- normalized_text = convert_non_roman_numbers_to_text(str(text_input))
548
- print(f"Asl matn: '{text_input}'")
549
- print(f"Normallashgan matn:'{normalized_text}'\n")
550
-
551
- print("\n--- Maxsus raqam testlari (number_to_words_uz & _convert_version_part) ---")
552
- tests = {
553
- "15,500.75": ("o'n besh ming besh yuz butun yetmish besh", number_to_words_uz),
554
- "0.05": ("nol butun nol besh", number_to_words_uz),
555
- "-.05": ("minus nol butun nol besh", number_to_words_uz),
556
- "-0.0": ("minus nol", number_to_words_uz),
557
- "1000.00": ("ming", number_to_words_uz),
558
- ".00": ("nol", number_to_words_uz),
559
- "0.75": ("nol butun yetmish besh", number_to_words_uz),
560
- "123.005": ("yuz yigirma uch butun nol nol besh", number_to_words_uz),
561
- "123.050": ("yuz yigirma uch butun nol besh nol", number_to_words_uz),
562
- "123.500": ("yuz yigirma uch butun besh yuz", number_to_words_uz),
563
- "1.2.3": ("bir.ikki.uch", convert_non_roman_numbers_to_text),
564
- "1": ("bir", number_to_words_uz),
565
- "0": ("nol", number_to_words_uz),
566
- "-10": ("minus o'n", number_to_words_uz),
567
- "100": ("yuz", number_to_words_uz),
568
- "101": ("yuz bir", number_to_words_uz),
569
- "200": ("ikki yuz", number_to_words_uz),
570
- "1000": ("ming", number_to_words_uz),
571
- "2000": ("ikki ming", number_to_words_uz),
572
- "1000000": ("million", number_to_words_uz),
573
- ".5": ("nol butun besh", number_to_words_uz),
574
- "-.5": ("minus nol butun besh", number_to_words_uz),
575
- "00": ("nol nol", _convert_version_part),
576
- "007": ("nol nol yetti", _convert_version_part),
577
- "00100": ("nol nol yuz", _convert_version_part),
578
- "05": ("nol besh", _convert_version_part),
579
- "192": ("bir to'qqiz ikki", _convert_version_part),
580
- }
581
- for num_str, (expected, func_to_call) in tests.items():
582
- actual = func_to_call(num_str)
583
-
584
- print(f"Test for '{num_str}' using {func_to_call.__name__}:")
585
- print(f" Expected: '{expected}'")
586
- print(f" Actual: '{actual}'")
587
- if actual != expected:
588
- print(f" MISMATCH!")
589
- print()
590
-
591
- print("\n--- Test case for version/IP strings (using convert_non_roman_numbers_to_text) ---")
592
- version_tests = {
593
- '1.2.3. Bu versiya raqami.': 'bir.ikki.uch. Bu versiya raqami.',
594
- 'Versiya 10.2.5 ishlatilmoqda.': "Versiya o'n.ikki.besh ishlatilmoqda.",
595
- 'IP manzil: 192.168.1.1': "IP manzil: bir to'qqiz ikki.bir olti sakkiz.bir.bir",
596
- 'Versiya 2.007.1': "Versiya ikki.nol nol yetti.bir",
597
- 'Test 0.0.0.0': "Test nol.nol.nol.nol",
598
- 'Test 001.002.00100': "Test nol nol bir.nol nol ikki.nol nol yuz"
599
- }
600
- for input_text, expected_output in version_tests.items():
601
- actual_output = convert_non_roman_numbers_to_text(input_text)
602
- print(f" Input: '{input_text}'")
603
- print(f" Expected: '{expected_output}'")
604
- print(f" Actual: '{actual_output}'")
605
- if actual_output == expected_output:
606
- print(f" Result: PASS")
607
- else:
608
- print(f" Result: FAIL")
609
- print()