ovoz 0.1.0__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 (49) hide show
  1. ovoz-0.1.0/.gitignore +8 -0
  2. ovoz-0.1.0/LICENSE +21 -0
  3. ovoz-0.1.0/NOTICE +30 -0
  4. ovoz-0.1.0/PKG-INFO +113 -0
  5. ovoz-0.1.0/README.md +89 -0
  6. ovoz-0.1.0/pyproject.toml +41 -0
  7. ovoz-0.1.0/src/ovoz/__init__.py +26 -0
  8. ovoz-0.1.0/src/ovoz/__main__.py +3 -0
  9. ovoz-0.1.0/src/ovoz/_gapiring/LICENSE +24 -0
  10. ovoz-0.1.0/src/ovoz/_gapiring/NOTICE +5 -0
  11. ovoz-0.1.0/src/ovoz/_gapiring/__init__.py +147 -0
  12. ovoz-0.1.0/src/ovoz/_gapiring/dictionary.py +192 -0
  13. ovoz-0.1.0/src/ovoz/_gapiring/engine.py +306 -0
  14. ovoz-0.1.0/src/ovoz/_gapiring/frontend/__init__.py +0 -0
  15. ovoz-0.1.0/src/ovoz/_gapiring/frontend/common.py +16 -0
  16. ovoz-0.1.0/src/ovoz/_gapiring/frontend/lexicon_extra.tsv +6 -0
  17. ovoz-0.1.0/src/ovoz/_gapiring/frontend/tashkent_dialect.py +216 -0
  18. ovoz-0.1.0/src/ovoz/_gapiring/frontend/terms.py +58 -0
  19. ovoz-0.1.0/src/ovoz/_gapiring/frontend/terms_reviewed.json +4618 -0
  20. ovoz-0.1.0/src/ovoz/_gapiring/frontend/terms_uz.py +71 -0
  21. ovoz-0.1.0/src/ovoz/_gapiring/frontend/text_to_phoneme/__init__.py +0 -0
  22. ovoz-0.1.0/src/ovoz/_gapiring/frontend/text_to_phoneme/phoneme_converter.py +304 -0
  23. ovoz-0.1.0/src/ovoz/_gapiring/frontend/text_to_phoneme/pipelene_text_to_phoneme.py +49 -0
  24. ovoz-0.1.0/src/ovoz/_gapiring/frontend/text_to_phoneme/text_normalization_for_tts.py +65 -0
  25. ovoz-0.1.0/src/ovoz/_gapiring/frontend/text_to_phoneme/tools/__init__.py +0 -0
  26. ovoz-0.1.0/src/ovoz/_gapiring/frontend/text_to_phoneme/tools/convert_currency_to_text.py +39 -0
  27. ovoz-0.1.0/src/ovoz/_gapiring/frontend/text_to_phoneme/tools/convert_date_time_to_text.py +327 -0
  28. ovoz-0.1.0/src/ovoz/_gapiring/frontend/text_to_phoneme/tools/convert_non_roman_numbers_to_text.py +518 -0
  29. ovoz-0.1.0/src/ovoz/_gapiring/frontend/text_to_phoneme/tools/convert_phone_numbers_to_text.py +159 -0
  30. ovoz-0.1.0/src/ovoz/_gapiring/frontend/text_to_phoneme/tools/convert_roman_numerals_to_text.py +201 -0
  31. ovoz-0.1.0/src/ovoz/_gapiring/frontend/text_to_phoneme/tools/convert_symbols_to_uzbek_text.py +160 -0
  32. ovoz-0.1.0/src/ovoz/_gapiring/frontend/text_to_phoneme/tools/expand_uzbek_abbreviations.py +182 -0
  33. ovoz-0.1.0/src/ovoz/_gapiring/frontend/text_to_phoneme/tools/full_normalize.py +184 -0
  34. ovoz-0.1.0/src/ovoz/_gapiring/frontend/text_to_phoneme/tools/pronounce_links_and_emails.py +81 -0
  35. ovoz-0.1.0/src/ovoz/_gapiring/frontend/text_to_phoneme/tools/split_text_numbers.py +9 -0
  36. ovoz-0.1.0/src/ovoz/_gapiring/frontend/text_to_phoneme/tools/spoken_lexicon.py +40 -0
  37. ovoz-0.1.0/src/ovoz/_gapiring/frontend/text_to_phoneme/tools/spoken_prepass.py +116 -0
  38. ovoz-0.1.0/src/ovoz/_gapiring/frontend/text_to_phoneme/uzbek_orthography.py +24 -0
  39. ovoz-0.1.0/src/ovoz/_gapiring/frontend/textnorm.py +136 -0
  40. ovoz-0.1.0/src/ovoz/_gapiring/frontend/tts_frontend.py +336 -0
  41. ovoz-0.1.0/src/ovoz/_gapiring/lexicon.py +28 -0
  42. ovoz-0.1.0/src/ovoz/_gapiring/nano.py +111 -0
  43. ovoz-0.1.0/src/ovoz/_gapiring/text_front.py +129 -0
  44. ovoz-0.1.0/src/ovoz/audio.py +79 -0
  45. ovoz-0.1.0/src/ovoz/cli.py +99 -0
  46. ovoz-0.1.0/src/ovoz/stt.py +196 -0
  47. ovoz-0.1.0/src/ovoz/translit.py +150 -0
  48. ovoz-0.1.0/src/ovoz/tts.py +109 -0
  49. ovoz-0.1.0/tests/test_translit.py +24 -0
ovoz-0.1.0/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ models/
2
+ dist/
3
+ build/
4
+ .venv/
5
+ __pycache__/
6
+ *.pyc
7
+ *.egg-info/
8
+ .DS_Store
ovoz-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ziyodullo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
ovoz-0.1.0/NOTICE ADDED
@@ -0,0 +1,30 @@
1
+ ovoz
2
+ ====
3
+
4
+ The code in this package is released under the MIT License (see LICENSE).
5
+
6
+ The speech recognition model used by this package is NOT covered by the MIT License.
7
+ It is a CTranslate2 int8 conversion of:
8
+
9
+ rubaiSTT v2 Medium — https://huggingface.co/islomov/rubaistt_v2_medium
10
+ Copyright (c) Islomov — Apache License 2.0
11
+ Fine-tuned from OpenAI Whisper Medium — https://huggingface.co/openai/whisper-medium
12
+ Copyright (c) OpenAI — Apache License 2.0
13
+
14
+ Changes made to the model: weights converted to CTranslate2 format and quantized to int8;
15
+ a tokenizer.json file generated from the original tokenizer. No retraining.
16
+
17
+ Full Apache License 2.0 text: https://www.apache.org/licenses/LICENSE-2.0
18
+
19
+ The text-to-speech part contains a vendored copy of the Gapiring 0.2.0 runtime code (src/ovoz/_gapiring),
20
+ by Gapi (https://gapi.uz), MIT License — see src/ovoz/_gapiring/LICENSE and src/ovoz/_gapiring/NOTICE.
21
+
22
+ Its models are downloaded on first use from https://huggingface.co/ziyodev/ovoz-tts, an unchanged copy of:
23
+
24
+ Gapiring v2 (Edge, Large int8) — https://huggingface.co/islomov/gapi-uz-gapiring-v2
25
+ Gapiring Nano v1 — https://huggingface.co/islomov/gapi-uz-gapiring-nano-v1
26
+ Gapiring by Gapi (https://gapi.uz), an adaptation of Kyutai Pocket TTS — CC BY 4.0
27
+ Gapiring Nano is based on tiny-voca (https://github.com/n4ze3m/tiny-voca), Apache License 2.0
28
+
29
+ When you share audio or products made with the TTS models, give credit as CC BY 4.0 requires:
30
+ "Gapiring by Gapi (https://gapi.uz), an adaptation of Kyutai Pocket TTS, CC BY 4.0"
ovoz-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,113 @@
1
+ Metadata-Version: 2.5
2
+ Name: ovoz
3
+ Version: 0.1.0
4
+ Summary: Offline o'zbekcha nutq: ovoz → matn (STT) va matn → ovoz (TTS). Torch kerak emas
5
+ Project-URL: Homepage, https://github.com/Ziyodullodev/ovoz
6
+ Project-URL: STT-model, https://huggingface.co/ziyodev/stt-ziyodev-medium-int8
7
+ Project-URL: TTS-model, https://huggingface.co/ziyodev/ovoz-tts
8
+ Author: Ziyodullo
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ License-File: NOTICE
12
+ Keywords: asr,o'zbek,offline,speech-to-text,stt,text-to-speech,tts,uzbek,whisper
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
16
+ Requires-Python: >=3.10
17
+ Requires-Dist: av>=11
18
+ Requires-Dist: faster-whisper>=1.1
19
+ Requires-Dist: huggingface-hub>=0.23
20
+ Requires-Dist: numpy
21
+ Requires-Dist: onnxruntime>=1.23
22
+ Requires-Dist: tokenizers
23
+ Description-Content-Type: text/markdown
24
+
25
+ # ovoz — offline o'zbekcha nutq
26
+
27
+ **Ovoz → matn (STT)** va **matn → ovoz (TTS)** — bitta paketda, to'liq **internetsiz**, **torch'siz**,
28
+ oddiy CPU'da ishlaydi. Natija istalgan alifboda: lotin, yangi alifbo, kirill.
29
+
30
+ ```bash
31
+ pip install ovoz
32
+ ```
33
+
34
+ ```python
35
+ from ovoz import STT, TTS
36
+
37
+ # Ovoz → matn
38
+ stt = STT() # 744 MB model bir marta yuklanadi, keyin offline
39
+ print(stt.transcribe("ovoz.ogg")) # bugun oʻqituvchi maʼlumot berdi
40
+ print(stt.transcribe("ovoz.ogg", script="new")) # bugun öqituvçi maʼlumot berdi
41
+ print(stt.transcribe("ovoz.ogg", script="cyrl")) # бугун ўқитувчи маълумот берди
42
+
43
+ # Matn → ovoz
44
+ tts = TTS() # 117 MB model bir marta yuklanadi
45
+ tts.save("javob.ogg", "Besh ming so'm chiqim yozildi.", voice="f1", style="warm")
46
+ tts.save("kitob.mp3", open("bob.txt").read(), voice="m1", style="book")
47
+ ```
48
+
49
+ Modellar faqat ishlatilganda yuklanadi: faqat TTS kerak bo'lsa, STT modeli umuman yuklanmaydi.
50
+
51
+ ## Buyruq qatori
52
+
53
+ ```bash
54
+ ovoz stt ovoz.mp3 # matn
55
+ ovoz stt ovoz.mp3 --script cyrl # kirillda
56
+ ovoz stt video.mp4 --srt # video.srt subtitr
57
+ ovoz stt ovoz.mp3 --json # bo'laklar, so'zlar va vaqtlar
58
+ ovoz stt ovoz.mp3 --device mps # Apple Silicon'da ~2× tezroq
59
+
60
+ ovoz tts "Assalomu alaykum!" -o salom.ogg
61
+ ovoz tts "Hisobingizda 250 000 so'm bor" -o balans.mp3 --voice m1 --style calm --pace slow
62
+ ovoz tts -f kitob.txt -o kitob.mp3 --style book
63
+ ```
64
+
65
+ ## STT
66
+
67
+ | Parametr | Qiymatlar |
68
+ |---|---|
69
+ | `script=` | `lat` (oʻ, gʻ — standart), `new` (ö, ğ, ş, ç — 2027-yil 22-apreldan), `lat_ascii` (o', g'), `cyrl` (кирилл) |
70
+ | kirish | fayl yo'li (mp3, wav, ogg, m4a, mp4, webm …), ochiq fayl yoki 16 kHz numpy massiv |
71
+ | `stt.segments(...)` | uzun audio — bo'lak-bo'lak, vaqt bilan |
72
+ | `word_timestamps=True` | har bir so'zning vaqti |
73
+ | `initial_prompt="Chilonzor, Yunusobod"` | kerakli nom va atamalarni ko'rsatish |
74
+ | `STT(device="mps")` / `STT(device="cuda")` | Apple Silicon / NVIDIA GPU |
75
+ | `STT(local_files_only=True)` | internetga umuman chiqmaydi |
76
+
77
+ **Aniqlik va tezlik** — 10 ta podkast parchasi (Toshkent shevasi, ruscha aralash) va o'qitishda ishlatilmagan
78
+ 54 soniyalik yozuvda (WER — so'z xatosi, kam bo'lsa yaxshi):
79
+
80
+ | | WER (podkast) | WER (yangi ovoz) | Tezlik (Apple M5) |
81
+ |---|---|---|---|
82
+ | Asl rubaiSTT v2 (transformers + torch) | 15,1% | 21,4% | 1,9× real vaqt |
83
+ | **ovoz STT (int8, CPU, 4 oqim)** | **16,2%** | **17,9%** | **2,8× real vaqt** |
84
+ | ovoz STT (`device="mps"`) | — | — | ~6,5× real vaqt |
85
+
86
+ ## TTS
87
+
88
+ | Parametr | Qiymatlar |
89
+ |---|---|
90
+ | `voice=` | `f1` (ayol), `m1` (erkak) |
91
+ | `style=` | `warm` `neutral` `cheerful` `calm` `empathetic` `serious` `dictation` `operator` `persuasive` `book` `news` `tale` `joking` `angry` `upset` `elderly` |
92
+ | `pace=` | `slow`, `normal`, `fast` (hamma uslubda ham emas — mos kelmasa odatiy tezlik) |
93
+ | fayl formati | `.wav`, `.ogg` (Telegram ovozli xabari), `.mp3`, `.m4a` — kengaytmaga qarab |
94
+ | `TTS("large")` | ovozi tozaroq (346 MB), `TTS("nano")` — eng kichik (31 MB, bitta ovoz) |
95
+
96
+ Sonlar, sanalar, pul miqdorlari so'z bilan o'qiladi. Lotin, kirill va yangi alifbodagi matnni tushunadi;
97
+ `[pause]`, `[laugh]`, `[breath]`, `[sigh]` belgilari ishlaydi. `tts.stream(...)` — jonli ijro uchun bo'laklar.
98
+
99
+ ## Litsenziya
100
+
101
+ Kod — MIT. Modellar paketga kiritilmagan, birinchi ishlatilganda Hugging Face'dan yuklanadi:
102
+
103
+ - **STT:** [ziyodev/stt-ziyodev-medium-int8](https://huggingface.co/ziyodev/stt-ziyodev-medium-int8) —
104
+ [rubaiSTT v2 Medium](https://huggingface.co/islomov/rubaistt_v2_medium) (Islomov, Whisper Medium asosida),
105
+ Apache 2.0; CTranslate2 int8 formatiga o'girilgan
106
+ - **TTS:** [ziyodev/ovoz-tts](https://huggingface.co/ziyodev/ovoz-tts) —
107
+ [Gapiring v2](https://huggingface.co/islomov/gapi-uz-gapiring-v2) va Nano modellarining o'zgartirilmagan nusxasi:
108
+ *Gapiring by Gapi, an adaptation of Kyutai Pocket TTS*, CC BY 4.0. TTS bilan yaratilgan audioni tarqatganda shu
109
+ mualliflikni ko'rsating. Gapiring'ning ishga tushirish kodi (MIT) paket ichida: `ovoz/_gapiring`.
110
+
111
+ Paket asl Gapiring paketi yoki repo'lariga bog'liq emas — ular o'chirilsa ham ishlayveradi.
112
+
113
+ Batafsil: `NOTICE`.
ovoz-0.1.0/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # ovoz — offline o'zbekcha nutq
2
+
3
+ **Ovoz → matn (STT)** va **matn → ovoz (TTS)** — bitta paketda, to'liq **internetsiz**, **torch'siz**,
4
+ oddiy CPU'da ishlaydi. Natija istalgan alifboda: lotin, yangi alifbo, kirill.
5
+
6
+ ```bash
7
+ pip install ovoz
8
+ ```
9
+
10
+ ```python
11
+ from ovoz import STT, TTS
12
+
13
+ # Ovoz → matn
14
+ stt = STT() # 744 MB model bir marta yuklanadi, keyin offline
15
+ print(stt.transcribe("ovoz.ogg")) # bugun oʻqituvchi maʼlumot berdi
16
+ print(stt.transcribe("ovoz.ogg", script="new")) # bugun öqituvçi maʼlumot berdi
17
+ print(stt.transcribe("ovoz.ogg", script="cyrl")) # бугун ўқитувчи маълумот берди
18
+
19
+ # Matn → ovoz
20
+ tts = TTS() # 117 MB model bir marta yuklanadi
21
+ tts.save("javob.ogg", "Besh ming so'm chiqim yozildi.", voice="f1", style="warm")
22
+ tts.save("kitob.mp3", open("bob.txt").read(), voice="m1", style="book")
23
+ ```
24
+
25
+ Modellar faqat ishlatilganda yuklanadi: faqat TTS kerak bo'lsa, STT modeli umuman yuklanmaydi.
26
+
27
+ ## Buyruq qatori
28
+
29
+ ```bash
30
+ ovoz stt ovoz.mp3 # matn
31
+ ovoz stt ovoz.mp3 --script cyrl # kirillda
32
+ ovoz stt video.mp4 --srt # video.srt subtitr
33
+ ovoz stt ovoz.mp3 --json # bo'laklar, so'zlar va vaqtlar
34
+ ovoz stt ovoz.mp3 --device mps # Apple Silicon'da ~2× tezroq
35
+
36
+ ovoz tts "Assalomu alaykum!" -o salom.ogg
37
+ ovoz tts "Hisobingizda 250 000 so'm bor" -o balans.mp3 --voice m1 --style calm --pace slow
38
+ ovoz tts -f kitob.txt -o kitob.mp3 --style book
39
+ ```
40
+
41
+ ## STT
42
+
43
+ | Parametr | Qiymatlar |
44
+ |---|---|
45
+ | `script=` | `lat` (oʻ, gʻ — standart), `new` (ö, ğ, ş, ç — 2027-yil 22-apreldan), `lat_ascii` (o', g'), `cyrl` (кирилл) |
46
+ | kirish | fayl yo'li (mp3, wav, ogg, m4a, mp4, webm …), ochiq fayl yoki 16 kHz numpy massiv |
47
+ | `stt.segments(...)` | uzun audio — bo'lak-bo'lak, vaqt bilan |
48
+ | `word_timestamps=True` | har bir so'zning vaqti |
49
+ | `initial_prompt="Chilonzor, Yunusobod"` | kerakli nom va atamalarni ko'rsatish |
50
+ | `STT(device="mps")` / `STT(device="cuda")` | Apple Silicon / NVIDIA GPU |
51
+ | `STT(local_files_only=True)` | internetga umuman chiqmaydi |
52
+
53
+ **Aniqlik va tezlik** — 10 ta podkast parchasi (Toshkent shevasi, ruscha aralash) va o'qitishda ishlatilmagan
54
+ 54 soniyalik yozuvda (WER — so'z xatosi, kam bo'lsa yaxshi):
55
+
56
+ | | WER (podkast) | WER (yangi ovoz) | Tezlik (Apple M5) |
57
+ |---|---|---|---|
58
+ | Asl rubaiSTT v2 (transformers + torch) | 15,1% | 21,4% | 1,9× real vaqt |
59
+ | **ovoz STT (int8, CPU, 4 oqim)** | **16,2%** | **17,9%** | **2,8× real vaqt** |
60
+ | ovoz STT (`device="mps"`) | — | — | ~6,5× real vaqt |
61
+
62
+ ## TTS
63
+
64
+ | Parametr | Qiymatlar |
65
+ |---|---|
66
+ | `voice=` | `f1` (ayol), `m1` (erkak) |
67
+ | `style=` | `warm` `neutral` `cheerful` `calm` `empathetic` `serious` `dictation` `operator` `persuasive` `book` `news` `tale` `joking` `angry` `upset` `elderly` |
68
+ | `pace=` | `slow`, `normal`, `fast` (hamma uslubda ham emas — mos kelmasa odatiy tezlik) |
69
+ | fayl formati | `.wav`, `.ogg` (Telegram ovozli xabari), `.mp3`, `.m4a` — kengaytmaga qarab |
70
+ | `TTS("large")` | ovozi tozaroq (346 MB), `TTS("nano")` — eng kichik (31 MB, bitta ovoz) |
71
+
72
+ Sonlar, sanalar, pul miqdorlari so'z bilan o'qiladi. Lotin, kirill va yangi alifbodagi matnni tushunadi;
73
+ `[pause]`, `[laugh]`, `[breath]`, `[sigh]` belgilari ishlaydi. `tts.stream(...)` — jonli ijro uchun bo'laklar.
74
+
75
+ ## Litsenziya
76
+
77
+ Kod — MIT. Modellar paketga kiritilmagan, birinchi ishlatilganda Hugging Face'dan yuklanadi:
78
+
79
+ - **STT:** [ziyodev/stt-ziyodev-medium-int8](https://huggingface.co/ziyodev/stt-ziyodev-medium-int8) —
80
+ [rubaiSTT v2 Medium](https://huggingface.co/islomov/rubaistt_v2_medium) (Islomov, Whisper Medium asosida),
81
+ Apache 2.0; CTranslate2 int8 formatiga o'girilgan
82
+ - **TTS:** [ziyodev/ovoz-tts](https://huggingface.co/ziyodev/ovoz-tts) —
83
+ [Gapiring v2](https://huggingface.co/islomov/gapi-uz-gapiring-v2) va Nano modellarining o'zgartirilmagan nusxasi:
84
+ *Gapiring by Gapi, an adaptation of Kyutai Pocket TTS*, CC BY 4.0. TTS bilan yaratilgan audioni tarqatganda shu
85
+ mualliflikni ko'rsating. Gapiring'ning ishga tushirish kodi (MIT) paket ichida: `ovoz/_gapiring`.
86
+
87
+ Paket asl Gapiring paketi yoki repo'lariga bog'liq emas — ular o'chirilsa ham ishlayveradi.
88
+
89
+ Batafsil: `NOTICE`.
@@ -0,0 +1,41 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.24"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "ovoz"
7
+ version = "0.1.0"
8
+ description = "Offline o'zbekcha nutq: ovoz → matn (STT) va matn → ovoz (TTS). Torch kerak emas"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE", "NOTICE"]
12
+ requires-python = ">=3.10"
13
+ authors = [{ name = "Ziyodullo" }]
14
+ keywords = ["uzbek", "o'zbek", "speech-to-text", "text-to-speech", "stt", "tts", "asr", "whisper", "offline"]
15
+ classifiers = [
16
+ "Programming Language :: Python :: 3",
17
+ "Topic :: Multimedia :: Sound/Audio :: Speech",
18
+ "Operating System :: OS Independent",
19
+ ]
20
+ dependencies = [
21
+ "faster-whisper>=1.1",
22
+ "av>=11",
23
+ "onnxruntime>=1.23",
24
+ "tokenizers",
25
+ "huggingface_hub>=0.23",
26
+ "numpy",
27
+ ]
28
+
29
+ [project.urls]
30
+ Homepage = "https://github.com/Ziyodullodev/ovoz"
31
+ STT-model = "https://huggingface.co/ziyodev/stt-ziyodev-medium-int8"
32
+ TTS-model = "https://huggingface.co/ziyodev/ovoz-tts"
33
+
34
+ [project.scripts]
35
+ ovoz = "ovoz.cli:main"
36
+
37
+ [tool.hatch.build.targets.wheel]
38
+ packages = ["src/ovoz"]
39
+
40
+ [tool.hatch.build.targets.sdist]
41
+ exclude = ["models/", "dist/", ".venv/"]
@@ -0,0 +1,26 @@
1
+ """ovoz — offline o'zbekcha nutq: ovoz → matn (STT) va matn → ovoz (TTS). Torch kerak emas.
2
+
3
+ from ovoz import STT, TTS
4
+
5
+ stt = STT() # 744 MB, bir marta yuklanadi, keyin offline
6
+ print(stt.transcribe("ovoz.ogg")) # lotin: oʻ, gʻ
7
+ print(stt.transcribe("ovoz.ogg", script="cyrl")) # kirill
8
+ print(stt.transcribe("ovoz.ogg", script="new")) # yangi alifbo: ö, ğ, ş, ç
9
+
10
+ tts = TTS() # 117 MB, bir marta yuklanadi
11
+ tts.save("javob.ogg", "Besh ming so'm chiqim yozildi.", voice="f1", style="warm")
12
+
13
+ Modellar faqat ishlatilganda yuklanadi: faqat TTS kerak bo'lsa, STT modeli yuklanmaydi.
14
+ """
15
+
16
+ from .audio import decode_audio, encode_audio, save_audio
17
+ from .stt import DEFAULT_REPO, STT, Result, Segment, Word, to_srt
18
+ from .translit import SCRIPTS, to_script
19
+ from .tts import PACES, STYLES, TTS, VOICES
20
+
21
+ __version__ = "0.1.0"
22
+ __all__ = [
23
+ "STT", "TTS", "Segment", "Word", "Result", "to_srt", "DEFAULT_REPO",
24
+ "STYLES", "VOICES", "PACES", "SCRIPTS", "to_script",
25
+ "decode_audio", "encode_audio", "save_audio",
26
+ ]
@@ -0,0 +1,3 @@
1
+ from .cli import main
2
+
3
+ main()
@@ -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,5 @@
1
+ This folder is a vendored copy of the Gapiring 0.2.0 Python package (https://pypi.org/project/gapiring/),
2
+ by Gapi (https://gapi.uz), used under the MIT License (see LICENSE). Changes for the ovoz package:
3
+ - imports changed from `gapiring` to `ovoz._gapiring`;
4
+ - models are downloaded from the mirror `ziyodev/ovoz-tts` (unchanged copies of the Gapi models, CC BY 4.0);
5
+ - the command-line entry points were removed; only int8 models are offered.
@@ -0,0 +1,147 @@
1
+ """Gapiring: Uzbek text-to-speech on a CPU. Two voices, roles and manners by name, a narrator, streaming audio.
2
+
3
+ from ovoz._gapiring import Gapiring
4
+ tts = Gapiring() # Large int8; Gapiring("edge") is the small model, Gapiring("nano") the tiny one
5
+ tts.save("hello.wav", "Assalomu alaykum! Namuna kompaniyasining virtual yordamchisiman, sizga qanday yordam bera olaman?", voice="f1", role="assistant", manner="warm")
6
+ tts.save("chapter.wav", open("chapter.txt").read(), voice="m1", role="narrator", manner="book")
7
+ 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"):
8
+ play(chunk) # float32, 24 kHz, as it is made
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ import os
14
+ import warnings
15
+ import wave
16
+ from pathlib import Path
17
+
18
+ import numpy as np
19
+
20
+ from .engine import PACE_MANNERS, PACES, ROLE_MANNERS, PocketONNX, tags_for
21
+ from .text_front import prepare_readings
22
+
23
+ __version__ = "0.2.0"
24
+ __all__ = ["Gapiring", "MODELS", "VOICES", "ROLES", "PACES", "PACE_MANNERS", "manners", "SAMPLE_RATE"]
25
+
26
+ # ovoz: modellar o'z nusxamizdan yuklanadi (edge/, large/, nano/ papkalari) — asl repo o'chirilsa ham ishlaydi.
27
+ # Asl manba: islomov/gapi-uz-gapiring-v2 va islomov/gapi-uz-gapiring-nano-v1 (Gapi, CC BY 4.0).
28
+ REPO = os.environ.get("OVOZ_TTS_REPO", "ziyodev/ovoz-tts")
29
+ NANO_REPO = REPO
30
+ MODELS = ("edge", "large", "nano")
31
+ NANO_SPEED = {None: 1.0, "slow": 0.85, "fast": 1.2} # Nano has a speed setting: pace maps onto it
32
+ VOICES = ("f1", "m1")
33
+ ROLES = tuple(ROLE_MANNERS)
34
+ SAMPLE_RATE = 24000
35
+ _GRAPHS = ("text_conditioner", "flow_lm_main", "flow_lm_flow", "mimi_decoder")
36
+
37
+
38
+ def manners(role: str) -> tuple[str, ...]:
39
+ """The manners a role speaks in: manners("emotional") -> ("angry", "upset", ...); for the narrator, the genres."""
40
+ return ROLE_MANNERS[role]
41
+
42
+
43
+ def fetch(model: str = "large", precision: str | None = None, dictionary: bool | None = None, revision: str | None = None,
44
+ token: str | None = None) -> Path:
45
+ """Download (once; cached by huggingface_hub) the files of a model and return the folder that holds them.
46
+ dictionary: for nano, False leaves the dictionary of English words out; for the other models it changes nothing."""
47
+ from huggingface_hub import snapshot_download
48
+
49
+ if model not in MODELS:
50
+ raise ValueError(f"model {model!r}: choose from {MODELS}")
51
+ if model == "nano": # one graph and its settings, and the dictionary of English words it reads through
52
+ patterns = ["nano/nano.onnx", "nano/nano.json"] + ([] if dictionary is False else ["nano/lexicon/en_uz.tsv"])
53
+ return Path(snapshot_download(NANO_REPO, allow_patterns=patterns, revision=revision, token=token)) / "nano"
54
+ suffix = _suffix(model, precision)
55
+ patterns = [f"{model}/{g}{suffix}.onnx" for g in _GRAPHS] + [f"{model}/bundle.json", f"{model}/tokenizer.json", f"{model}/voices/*.npy"]
56
+ return Path(snapshot_download(REPO, allow_patterns=patterns, revision=revision, token=token))
57
+
58
+
59
+ def _suffix(model: str, precision: str | None) -> str:
60
+ precision = precision or "int8"
61
+ if precision != "int8": # ovoz nusxasida faqat int8 bor (to'liq aniqlikdagi Large asl repo'da)
62
+ raise ValueError(f"precision {precision!r}: ovoz faqat int8 modellarini qo'llaydi")
63
+ return "_int8" if precision == "int8" else ""
64
+
65
+
66
+ class Gapiring:
67
+ """One loaded model.
68
+
69
+ model "large" (Gapiring Large v2, 24 layers, the default: the cleaner sound), "edge" (Gapiring Edge v2,
70
+ 6 layers, 117 MB, about 2.5 times faster, phone class) or "nano" (Gapiring Nano, 31 MB, one
71
+ voice, no roles or manners, for very small devices)
72
+ precision "int8" (the default: 346 MB for large) or "full" (large only, 1.3 GB)
73
+ threads CPU threads for the model
74
+ dictionary nano only: the dictionary of English words is on unless this is False (it takes about 4 s and
75
+ 400 MB to load); Edge and Large read English words as they are written and ignore it
76
+ normalize "literary" (the default) or "conversational": numbers, dates, money and phone numbers become words,
77
+ English words stay as written; None gives the text to the model as written
78
+ path a local folder with the repository's layout (edge/) instead of downloading
79
+ """
80
+
81
+ def __init__(self, model: str = "large", *, precision: str | None = None, threads: int = 2, dictionary: bool | None = None,
82
+ normalize: str | None = "literary", path: str | Path | None = None, revision: str | None = None, token: str | None = None):
83
+ if model not in MODELS:
84
+ raise ValueError(f"model {model!r}: choose from {MODELS}")
85
+ self.model, self.sample_rate, self._normalize = model, SAMPLE_RATE, normalize
86
+ if model == "nano":
87
+ from .nano import Nano
88
+
89
+ if precision == "full" or precision not in (None, "int8", "full"):
90
+ warnings.warn("precision is ignored: Gapiring Nano is one file", UserWarning, stacklevel=2)
91
+ root = Path(path) if path else fetch(model, None, dictionary, revision, token)
92
+ self._nano = Nano(root, threads)
93
+ self._dictionary = None
94
+ if dictionary is not False:
95
+ from .dictionary import Dictionary
96
+
97
+ self._dictionary = Dictionary.load(root / "lexicon/en_uz.tsv")
98
+ return
99
+ suffix = _suffix(model, precision)
100
+ if dictionary: # an argument of 0.1: mapped to v2 with a warning, never an error
101
+ warnings.warn("dictionary=True is ignored: Gapiring v2 reads English words as they are written", UserWarning, stacklevel=2)
102
+ root = Path(path) if path else fetch(model, precision, revision=revision, token=token)
103
+ self._tts = PocketONNX(root / model, threads=threads, suffix=suffix, normalize=normalize)
104
+
105
+ def stream(self, text: str, voice: str = "f1", role: str = "assistant", manner: str | None = None, seed: int = 0, *,
106
+ pace: str | None = None, serious: bool = False, hesitant: bool = False):
107
+ """Yield float32 chunks (24 kHz mono) as they are made. A text of any length: a longer one is spoken piece by
108
+ piece. manner: neutral when left out; for the narrator the genre (book, article, news, tale), book when left
109
+ out. One optional mark at a time: pace "slow" or "fast"; serious=True for the narrator's article and news;
110
+ hesitant=True for the lively assistant with small hesitations.
111
+ Nano has one voice (f1) and no roles or manners: it takes the text and pace; the rest is ignored with a
112
+ warning. It makes each piece in one pass, so a chunk is a whole sentence or two."""
113
+ if voice not in VOICES:
114
+ raise ValueError(f"voice {voice!r}: choose from {VOICES}")
115
+ if self.model == "nano":
116
+ if pace not in NANO_SPEED:
117
+ raise ValueError(f"pace {pace!r}: choose from {tuple(PACES)}")
118
+ ignored = [name for name, given in (("voice", voice != "f1"), ("role", role != "assistant"), ("manner", manner is not None),
119
+ ("serious", serious), ("hesitant", hesitant)) if given]
120
+ if ignored:
121
+ warnings.warn(f"Gapiring Nano has one voice and no roles or manners: {', '.join(ignored)} ignored", UserWarning, stacklevel=2)
122
+ return self._nano.stream(self.said(text), NANO_SPEED[pace])
123
+ tags_for(role, manner, pace, serious, hesitant) # a wrong name fails here, not at the first chunk
124
+ return self._tts.speak(text, voice=voice, role=role, manner=manner, pace=pace, serious=serious, hesitant=hesitant, seed=seed)
125
+
126
+ def speak(self, text: str, voice: str = "f1", role: str = "assistant", manner: str | None = None, seed: int = 0, **marks) -> np.ndarray:
127
+ """The whole text as one float32 array (24 kHz mono)."""
128
+ chunks = list(self.stream(text, voice, role, manner, seed, **marks))
129
+ return np.concatenate(chunks) if chunks else np.zeros(0, np.float32)
130
+
131
+ def save(self, path: str | Path, text: str, voice: str = "f1", role: str = "assistant", manner: str | None = None, seed: int = 0, **marks) -> float:
132
+ """Write the text as a 16-bit WAV; returns its length in seconds."""
133
+ audio = self.speak(text, voice, role, manner, seed, **marks)
134
+ with wave.open(str(path), "wb") as f:
135
+ f.setnchannels(1)
136
+ f.setsampwidth(2)
137
+ f.setframerate(SAMPLE_RATE)
138
+ f.writeframes((np.clip(audio, -1, 1) * 32767).astype("<i2").tobytes())
139
+ return len(audio) / SAMPLE_RATE
140
+
141
+ def said(self, text: str) -> str:
142
+ """The text as the voice gets it: after the normaliser and, for nano, the dictionary of English words."""
143
+ if self.model != "nano":
144
+ return self._tts.prepared(text)
145
+ if self._normalize:
146
+ return prepare_readings(text, self._dictionary, self._normalize)
147
+ return self._dictionary.apply(text) if self._dictionary else text