tiny-voca-ru 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 (46) hide show
  1. tiny_voca_ru-0.1.0/LICENSE +202 -0
  2. tiny_voca_ru-0.1.0/NOTICE +24 -0
  3. tiny_voca_ru-0.1.0/PKG-INFO +252 -0
  4. tiny_voca_ru-0.1.0/README.md +196 -0
  5. tiny_voca_ru-0.1.0/pyproject.toml +107 -0
  6. tiny_voca_ru-0.1.0/setup.cfg +4 -0
  7. tiny_voca_ru-0.1.0/src/tiny_voca_ru/__init__.py +78 -0
  8. tiny_voca_ru-0.1.0/src/tiny_voca_ru/checkpoint.py +135 -0
  9. tiny_voca_ru-0.1.0/src/tiny_voca_ru/config.py +101 -0
  10. tiny_voca_ru-0.1.0/src/tiny_voca_ru/export.py +374 -0
  11. tiny_voca_ru-0.1.0/src/tiny_voca_ru/frontend/__init__.py +96 -0
  12. tiny_voca_ru-0.1.0/src/tiny_voca_ru/frontend/clean.py +90 -0
  13. tiny_voca_ru-0.1.0/src/tiny_voca_ru/frontend/data/LICENSE-ruaccent +15 -0
  14. tiny_voca_ru-0.1.0/src/tiny_voca_ru/frontend/data/accent.onnx +0 -0
  15. tiny_voca_ru-0.1.0/src/tiny_voca_ru/frontend/data/stress.txt.gz +0 -0
  16. tiny_voca_ru-0.1.0/src/tiny_voca_ru/frontend/g2p.py +381 -0
  17. tiny_voca_ru-0.1.0/src/tiny_voca_ru/frontend/lexicon.py +218 -0
  18. tiny_voca_ru-0.1.0/src/tiny_voca_ru/frontend/normalize.py +856 -0
  19. tiny_voca_ru-0.1.0/src/tiny_voca_ru/frontend/numbers.py +387 -0
  20. tiny_voca_ru-0.1.0/src/tiny_voca_ru/frontend/stress.py +428 -0
  21. tiny_voca_ru-0.1.0/src/tiny_voca_ru/frontend/symbols.py +103 -0
  22. tiny_voca_ru-0.1.0/src/tiny_voca_ru/frontend/tables.py +784 -0
  23. tiny_voca_ru-0.1.0/src/tiny_voca_ru/frontend/tokenize.py +222 -0
  24. tiny_voca_ru-0.1.0/src/tiny_voca_ru/infer.py +868 -0
  25. tiny_voca_ru-0.1.0/src/tiny_voca_ru/model.py +525 -0
  26. tiny_voca_ru-0.1.0/src/tiny_voca_ru/train/__init__.py +58 -0
  27. tiny_voca_ru-0.1.0/src/tiny_voca_ru/train/align.py +374 -0
  28. tiny_voca_ru-0.1.0/src/tiny_voca_ru/train/dataset.py +217 -0
  29. tiny_voca_ru-0.1.0/src/tiny_voca_ru/train/losses.py +214 -0
  30. tiny_voca_ru-0.1.0/src/tiny_voca_ru/train/prepare.py +373 -0
  31. tiny_voca_ru-0.1.0/src/tiny_voca_ru/train/train.py +655 -0
  32. tiny_voca_ru-0.1.0/src/tiny_voca_ru.egg-info/PKG-INFO +252 -0
  33. tiny_voca_ru-0.1.0/src/tiny_voca_ru.egg-info/SOURCES.txt +44 -0
  34. tiny_voca_ru-0.1.0/src/tiny_voca_ru.egg-info/dependency_links.txt +1 -0
  35. tiny_voca_ru-0.1.0/src/tiny_voca_ru.egg-info/entry_points.txt +6 -0
  36. tiny_voca_ru-0.1.0/src/tiny_voca_ru.egg-info/requires.txt +30 -0
  37. tiny_voca_ru-0.1.0/src/tiny_voca_ru.egg-info/top_level.txt +1 -0
  38. tiny_voca_ru-0.1.0/tests/test_checkpoint_and_infer.py +365 -0
  39. tiny_voca_ru-0.1.0/tests/test_export.py +124 -0
  40. tiny_voca_ru-0.1.0/tests/test_frontend.py +118 -0
  41. tiny_voca_ru-0.1.0/tests/test_g2p.py +646 -0
  42. tiny_voca_ru-0.1.0/tests/test_model.py +186 -0
  43. tiny_voca_ru-0.1.0/tests/test_normalize.py +375 -0
  44. tiny_voca_ru-0.1.0/tests/test_stress.py +242 -0
  45. tiny_voca_ru-0.1.0/tests/test_train.py +383 -0
  46. tiny_voca_ru-0.1.0/tests/test_web.py +347 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,24 @@
1
+ tiny-voca-ru
2
+ A lightweight 4.5M-parameter Russian text-to-speech model.
3
+
4
+ This project is based on tiny-voca:
5
+ tiny-voca, Copyright 2026 Muhammed Nazeem
6
+ https://github.com/n4ze3m/tiny-voca
7
+ Apache License 2.0, commit db851f75c6287a15be4c4e995f931bce3a86b47b
8
+
9
+ The model architecture and training recipe originate from tiny-voca.
10
+ Changes for Russian include the pure-Python Russian text frontend
11
+ (src/tiny_voca_ru/frontend/: text normalization, stress placement, G2P rules,
12
+ and 61-symbol Russian phoneme inventory), Russian forced-alignment calibration,
13
+ safetensors checkpoint support, ONNX inference/export, and the Russian browser
14
+ demo.
15
+
16
+ The code is licensed under the Apache License 2.0 (see LICENSE).
17
+
18
+ The stress dictionary (stress.txt.gz) and unknown-word accent model
19
+ (accent.onnx) in src/tiny_voca_ru/frontend/data/ are derived from ruaccent:
20
+ https://github.com/Den4ikAI/ruaccent
21
+ https://huggingface.co/ruaccent/accentuator
22
+ MIT License (see src/tiny_voca_ru/frontend/data/LICENSE-ruaccent).
23
+
24
+ tiny-voca-ru is not an official tiny-voca release.
@@ -0,0 +1,252 @@
1
+ Metadata-Version: 2.4
2
+ Name: tiny-voca-ru
3
+ Version: 0.1.0
4
+ Summary: A lightweight 4.5M-parameter Russian text-to-speech model
5
+ Author: Evgeniy Chetvertkov
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/yilbegan/tiny-voca-ru
8
+ Project-URL: Repository, https://github.com/yilbegan/tiny-voca-ru
9
+ Project-URL: Model, https://huggingface.co/egnch/tiny-voca-ru
10
+ Project-URL: Dataset, https://huggingface.co/datasets/egnch/tiny-voca-ru-dataset
11
+ Project-URL: Demo, https://huggingface.co/spaces/egnch/tiny-voca-ru-demo
12
+ Keywords: tts,text-to-speech,russian,onnx,speech-synthesis,tiny-voca
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Natural Language :: Russian
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
23
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
24
+ Requires-Python: >=3.10
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ License-File: NOTICE
28
+ License-File: src/tiny_voca_ru/frontend/data/LICENSE-ruaccent
29
+ Requires-Dist: numpy<3,>=1.24
30
+ Provides-Extra: onnx
31
+ Requires-Dist: onnxruntime<2,>=1.17; extra == "onnx"
32
+ Requires-Dist: soundfile<1,>=0.12; extra == "onnx"
33
+ Requires-Dist: huggingface-hub<3,>=0.34; extra == "onnx"
34
+ Provides-Extra: torch
35
+ Requires-Dist: torch<3,>=2.4; extra == "torch"
36
+ Requires-Dist: safetensors<1,>=0.4; extra == "torch"
37
+ Requires-Dist: soundfile<1,>=0.12; extra == "torch"
38
+ Requires-Dist: onnxruntime<2,>=1.17; extra == "torch"
39
+ Requires-Dist: onnx<2,>=1.15; extra == "torch"
40
+ Requires-Dist: huggingface-hub<3,>=0.34; extra == "torch"
41
+ Provides-Extra: ruaccent
42
+ Requires-Dist: ruaccent==1.5.8.3; extra == "ruaccent"
43
+ Requires-Dist: onnxruntime<2,>=1.17; extra == "ruaccent"
44
+ Requires-Dist: huggingface-hub<3,>=0.34; extra == "ruaccent"
45
+ Provides-Extra: train
46
+ Requires-Dist: torch<3,>=2.4; extra == "train"
47
+ Requires-Dist: safetensors<1,>=0.4; extra == "train"
48
+ Requires-Dist: soundfile<1,>=0.12; extra == "train"
49
+ Requires-Dist: onnxruntime<2,>=1.17; extra == "train"
50
+ Requires-Dist: librosa<1,>=0.10.2; extra == "train"
51
+ Requires-Dist: transformers<5,>=4.40; extra == "train"
52
+ Requires-Dist: torchaudio<3,>=2.1; extra == "train"
53
+ Requires-Dist: scipy<2,>=1.10; extra == "train"
54
+ Requires-Dist: huggingface-hub<3,>=0.34; extra == "train"
55
+ Dynamic: license-file
56
+
57
+ # tiny-voca-ru
58
+
59
+ English | [Русский](https://github.com/yilbegan/tiny-voca-ru/blob/main/README.ru.md)
60
+
61
+ A 4.5M-parameter Russian text-to-speech adaptation of [`tiny-voca`](https://github.com/n4ze3m/tiny-voca) (24 kHz mono, two synthetic voices `F` and `M`) with a pure-Python Russian text frontend, safetensors/ONNX Runtime inference, custom-voice fine-tuning, and a client-side browser demo.
62
+
63
+ - **Model:** [`egnch/tiny-voca-ru`](https://huggingface.co/egnch/tiny-voca-ru)
64
+ - **Dataset:** [`egnch/tiny-voca-ru-dataset`](https://huggingface.co/datasets/egnch/tiny-voca-ru-dataset)
65
+ - **Browser Demo:** [`egnch/tiny-voca-ru-demo`](https://huggingface.co/spaces/egnch/tiny-voca-ru-demo)
66
+ - **PyPI:** [`tiny-voca-ru`](https://pypi.org/project/tiny-voca-ru/)
67
+
68
+ ## Installation
69
+
70
+ Requires Python 3.10+. Works with `pip` or [`uv`](https://docs.astral.sh/uv/).
71
+
72
+ ```bash
73
+ # Minimal Russian text frontend only (no PyTorch)
74
+ pip install tiny-voca-ru
75
+
76
+ # Lightweight ONNX Runtime inference (no PyTorch)
77
+ pip install "tiny-voca-ru[onnx]"
78
+
79
+ # PyTorch inference + safetensors + ONNX export
80
+ pip install "tiny-voca-ru[torch]"
81
+
82
+ # Full training & custom-voice fine-tuning stack
83
+ pip install "tiny-voca-ru[train]"
84
+
85
+ # Optional full ruaccent homograph disambiguation
86
+ pip install "tiny-voca-ru[ruaccent]"
87
+ ```
88
+
89
+ ## Quick Start: Inference
90
+
91
+ `Synthesizer` loads models from Hugging Face Hub (`egnch/tiny-voca-ru` by default) or a local directory, automatically selecting PyTorch (`model.safetensors` + `config.json`) or ONNX Runtime (`model.onnx` + `model.json`).
92
+
93
+ ### Python API
94
+
95
+ ```python
96
+ from tiny_voca_ru import Synthesizer
97
+
98
+ # Load from Hugging Face Hub (defaults to "egnch/tiny-voca-ru")
99
+ synth = Synthesizer.from_pretrained("egnch/tiny-voca-ru")
100
+ # Explicit ONNX Runtime backend (downloads only onnx/model.onnx + onnx/model.json)
101
+ # synth = Synthesizer.from_pretrained("egnch/tiny-voca-ru", backend="onnx")
102
+ # Local safetensors or ONNX directory
103
+ # synth = Synthesizer("checkpoints/tiny-voca-ru")
104
+
105
+ result = synth.save_wav(
106
+ "Здравствуйте! Встречу перенесли на 15:30, 14 марта.",
107
+ "hello.wav",
108
+ voice="M", # "F" or "M"
109
+ speed=1.0, # 0.25 .. 4.0
110
+ pitch_shift=0.0, # log-F0 offset (0.058 ≈ +1 semitone)
111
+ pitch_range=1.0, # 0.0 .. 3.0
112
+ stress="lite", # "lite" | "ruaccent" | "none"
113
+ pause_seconds=0.0, # optional silence gap between sentences
114
+ )
115
+ ```
116
+
117
+ ### CLI
118
+
119
+ ```bash
120
+ # Uses Hugging Face Hub ("egnch/tiny-voca-ru") by default
121
+ tiny-voca-ru-speak \
122
+ --voice F \
123
+ --text "Привет! Билет стоит 1250 рублей." \
124
+ --output out.wav
125
+
126
+ # Explicit ONNX Runtime backend
127
+ tiny-voca-ru-speak \
128
+ --model egnch/tiny-voca-ru \
129
+ --backend onnx \
130
+ --voice M \
131
+ --text "Привет! Билет стоит 1250 рублей." \
132
+ --output out_onnx.wav
133
+
134
+ # Local checkpoint or ONNX directory
135
+ tiny-voca-ru-speak \
136
+ --model checkpoints/tiny-voca-ru \
137
+ --voice F \
138
+ --text "Привет! Билет стоит 1250 рублей." \
139
+ --output out_local.wav
140
+ ```
141
+
142
+ ## Russian Text Frontend
143
+
144
+ `tiny_voca_ru.frontend` has no PyTorch or eSpeak dependency. It normalizes Russian text (numbers, dates, times, currencies, units, Roman numerals, abbreviations, acronyms, Latin words), places lexical stress, and outputs a 61-symbol IPA phoneme sequence.
145
+
146
+ ```python
147
+ from tiny_voca_ru import accentuate, normalize, phonemize, transcribe
148
+
149
+ normalize("В 1999 году билет стоил 12,50 руб.")
150
+ accentuate("Я открыл зам+ок ключом.") # explicit '+' marks are preserved
151
+ transcribe("Здравствуйте!") # readable IPA with ˈ
152
+ seq = phonemize("Привет, мир!", stress="lite")
153
+ ```
154
+
155
+ | Stress Provider | Dependencies | Notes |
156
+ | --- | --- | --- |
157
+ | `lite` (default) | Bundled `stress.txt.gz` + `accent.onnx` (`onnxruntime`) | Fast, offline, runs in browser via JS `accent.onnx` |
158
+ | `ruaccent` | `tiny-voca-ru[ruaccent]` | Full `ruaccent` (`turbo3.1`) neural homograph resolver |
159
+ | `none` | None | Preserves existing `+` stress marks only |
160
+
161
+ ## Custom-Voice Fine-Tuning
162
+
163
+ ### 1. Prepare a dataset
164
+
165
+ Create a `metadata.csv` (or `metadata.jsonl`) with columns `audio`, `text`, and optional `speaker`, `split`, `id`:
166
+
167
+ ```csv
168
+ audio,text,speaker
169
+ wavs/001.wav,Добрый день! Как ваши дела?,alice
170
+ wavs/002.wav,Сегодня отличная погода.,alice
171
+ ```
172
+
173
+ Extract 24 kHz features and `wav2vec2` CTC alignments:
174
+
175
+ ```bash
176
+ tiny-voca-ru-prepare \
177
+ --metadata data/metadata.csv \
178
+ --audio-root data \
179
+ --output work/alice-prepared \
180
+ --val-ratio 0.05
181
+ ```
182
+
183
+ ### 2. Fine-tune from a pretrained checkpoint
184
+
185
+ When fine-tuning onto new speakers, `tiny-voca-ru-train` copies compatible weights and initializes new speaker embeddings from `--init-voice` (or the mean of pretrained voices):
186
+
187
+ ```bash
188
+ tiny-voca-ru-train \
189
+ --data-dir work/alice-prepared \
190
+ --init-from checkpoints/tiny-voca-ru \
191
+ --init-voice F \
192
+ --output work/alice-run \
193
+ --steps 5000 \
194
+ --learning-rate 1e-4 \
195
+ --save-every 500
196
+ ```
197
+
198
+ Add `--freeze-encoder` for small datasets (< 30 min). Resume with `--resume work/alice-run/last.pt`. Safetensors checkpoints are saved to `work/alice-run/inference/` and `work/alice-run/best/`.
199
+
200
+ ## ONNX Export & Legacy Checkpoint Conversion
201
+
202
+ ```bash
203
+ # Export safetensors checkpoint -> model.onnx + model.json
204
+ tiny-voca-ru-export \
205
+ --checkpoint checkpoints/tiny-voca-ru \
206
+ --output checkpoints/tiny-voca-ru-onnx
207
+
208
+ # Convert legacy .pt checkpoint -> model.safetensors + config.json
209
+ tiny-voca-ru-convert \
210
+ --source path/to/tiny-voca-ru.pt \
211
+ --output checkpoints/tiny-voca-ru
212
+ ```
213
+
214
+ ## Browser Demo
215
+
216
+ The static demo in `web/public/` runs `tiny_voca_ru.frontend` in Pyodide and `model.onnx` + `accent.onnx` via ONNX Runtime Web entirely offline:
217
+
218
+ ```bash
219
+ bash web/build_assets.sh checkpoints/tiny-voca-ru-onnx
220
+ python3 -m http.server --directory web/public 8000
221
+ ```
222
+
223
+ ## Development
224
+
225
+ ```bash
226
+ uv sync --python 3.12 --extra torch --extra onnx --extra train --group dev
227
+ uv run pytest -q
228
+ uv run ruff check .
229
+ uv run ruff format --check .
230
+ uv run basedpyright
231
+ ```
232
+
233
+ ## Citation
234
+
235
+ Machine-readable citation metadata is available in [CITATION.cff](https://github.com/yilbegan/tiny-voca-ru/blob/main/CITATION.cff).
236
+
237
+ ```bibtex
238
+ @misc{chetvertkov2026tinyvocaru,
239
+ author = {Chetvertkov, Evgeniy},
240
+ title = {tiny-voca-ru: A 4.5M-Parameter Russian Text-to-Speech Model},
241
+ year = {2026},
242
+ url = {https://huggingface.co/egnch/tiny-voca-ru},
243
+ note = {ORCID: https://orcid.org/0009-0006-6158-2624}
244
+ }
245
+ ```
246
+
247
+ Please also consider citing the original [`tiny-voca`](https://huggingface.co/n4ze3m/tiny-voca) by Muhammed Nazeem (2026).
248
+
249
+ ## License & Attribution
250
+
251
+ Code and weights are licensed under the Apache License 2.0 ([LICENSE](https://github.com/yilbegan/tiny-voca-ru/blob/main/LICENSE)).
252
+ See [NOTICE](https://github.com/yilbegan/tiny-voca-ru/blob/main/NOTICE) for attribution to `tiny-voca` (Muhammed Nazeem, Apache-2.0) and `ruaccent` (MIT License, bundled `stress.txt.gz` and `accent.onnx` in `src/tiny_voca_ru/frontend/data/`).
@@ -0,0 +1,196 @@
1
+ # tiny-voca-ru
2
+
3
+ English | [Русский](https://github.com/yilbegan/tiny-voca-ru/blob/main/README.ru.md)
4
+
5
+ A 4.5M-parameter Russian text-to-speech adaptation of [`tiny-voca`](https://github.com/n4ze3m/tiny-voca) (24 kHz mono, two synthetic voices `F` and `M`) with a pure-Python Russian text frontend, safetensors/ONNX Runtime inference, custom-voice fine-tuning, and a client-side browser demo.
6
+
7
+ - **Model:** [`egnch/tiny-voca-ru`](https://huggingface.co/egnch/tiny-voca-ru)
8
+ - **Dataset:** [`egnch/tiny-voca-ru-dataset`](https://huggingface.co/datasets/egnch/tiny-voca-ru-dataset)
9
+ - **Browser Demo:** [`egnch/tiny-voca-ru-demo`](https://huggingface.co/spaces/egnch/tiny-voca-ru-demo)
10
+ - **PyPI:** [`tiny-voca-ru`](https://pypi.org/project/tiny-voca-ru/)
11
+
12
+ ## Installation
13
+
14
+ Requires Python 3.10+. Works with `pip` or [`uv`](https://docs.astral.sh/uv/).
15
+
16
+ ```bash
17
+ # Minimal Russian text frontend only (no PyTorch)
18
+ pip install tiny-voca-ru
19
+
20
+ # Lightweight ONNX Runtime inference (no PyTorch)
21
+ pip install "tiny-voca-ru[onnx]"
22
+
23
+ # PyTorch inference + safetensors + ONNX export
24
+ pip install "tiny-voca-ru[torch]"
25
+
26
+ # Full training & custom-voice fine-tuning stack
27
+ pip install "tiny-voca-ru[train]"
28
+
29
+ # Optional full ruaccent homograph disambiguation
30
+ pip install "tiny-voca-ru[ruaccent]"
31
+ ```
32
+
33
+ ## Quick Start: Inference
34
+
35
+ `Synthesizer` loads models from Hugging Face Hub (`egnch/tiny-voca-ru` by default) or a local directory, automatically selecting PyTorch (`model.safetensors` + `config.json`) or ONNX Runtime (`model.onnx` + `model.json`).
36
+
37
+ ### Python API
38
+
39
+ ```python
40
+ from tiny_voca_ru import Synthesizer
41
+
42
+ # Load from Hugging Face Hub (defaults to "egnch/tiny-voca-ru")
43
+ synth = Synthesizer.from_pretrained("egnch/tiny-voca-ru")
44
+ # Explicit ONNX Runtime backend (downloads only onnx/model.onnx + onnx/model.json)
45
+ # synth = Synthesizer.from_pretrained("egnch/tiny-voca-ru", backend="onnx")
46
+ # Local safetensors or ONNX directory
47
+ # synth = Synthesizer("checkpoints/tiny-voca-ru")
48
+
49
+ result = synth.save_wav(
50
+ "Здравствуйте! Встречу перенесли на 15:30, 14 марта.",
51
+ "hello.wav",
52
+ voice="M", # "F" or "M"
53
+ speed=1.0, # 0.25 .. 4.0
54
+ pitch_shift=0.0, # log-F0 offset (0.058 ≈ +1 semitone)
55
+ pitch_range=1.0, # 0.0 .. 3.0
56
+ stress="lite", # "lite" | "ruaccent" | "none"
57
+ pause_seconds=0.0, # optional silence gap between sentences
58
+ )
59
+ ```
60
+
61
+ ### CLI
62
+
63
+ ```bash
64
+ # Uses Hugging Face Hub ("egnch/tiny-voca-ru") by default
65
+ tiny-voca-ru-speak \
66
+ --voice F \
67
+ --text "Привет! Билет стоит 1250 рублей." \
68
+ --output out.wav
69
+
70
+ # Explicit ONNX Runtime backend
71
+ tiny-voca-ru-speak \
72
+ --model egnch/tiny-voca-ru \
73
+ --backend onnx \
74
+ --voice M \
75
+ --text "Привет! Билет стоит 1250 рублей." \
76
+ --output out_onnx.wav
77
+
78
+ # Local checkpoint or ONNX directory
79
+ tiny-voca-ru-speak \
80
+ --model checkpoints/tiny-voca-ru \
81
+ --voice F \
82
+ --text "Привет! Билет стоит 1250 рублей." \
83
+ --output out_local.wav
84
+ ```
85
+
86
+ ## Russian Text Frontend
87
+
88
+ `tiny_voca_ru.frontend` has no PyTorch or eSpeak dependency. It normalizes Russian text (numbers, dates, times, currencies, units, Roman numerals, abbreviations, acronyms, Latin words), places lexical stress, and outputs a 61-symbol IPA phoneme sequence.
89
+
90
+ ```python
91
+ from tiny_voca_ru import accentuate, normalize, phonemize, transcribe
92
+
93
+ normalize("В 1999 году билет стоил 12,50 руб.")
94
+ accentuate("Я открыл зам+ок ключом.") # explicit '+' marks are preserved
95
+ transcribe("Здравствуйте!") # readable IPA with ˈ
96
+ seq = phonemize("Привет, мир!", stress="lite")
97
+ ```
98
+
99
+ | Stress Provider | Dependencies | Notes |
100
+ | --- | --- | --- |
101
+ | `lite` (default) | Bundled `stress.txt.gz` + `accent.onnx` (`onnxruntime`) | Fast, offline, runs in browser via JS `accent.onnx` |
102
+ | `ruaccent` | `tiny-voca-ru[ruaccent]` | Full `ruaccent` (`turbo3.1`) neural homograph resolver |
103
+ | `none` | None | Preserves existing `+` stress marks only |
104
+
105
+ ## Custom-Voice Fine-Tuning
106
+
107
+ ### 1. Prepare a dataset
108
+
109
+ Create a `metadata.csv` (or `metadata.jsonl`) with columns `audio`, `text`, and optional `speaker`, `split`, `id`:
110
+
111
+ ```csv
112
+ audio,text,speaker
113
+ wavs/001.wav,Добрый день! Как ваши дела?,alice
114
+ wavs/002.wav,Сегодня отличная погода.,alice
115
+ ```
116
+
117
+ Extract 24 kHz features and `wav2vec2` CTC alignments:
118
+
119
+ ```bash
120
+ tiny-voca-ru-prepare \
121
+ --metadata data/metadata.csv \
122
+ --audio-root data \
123
+ --output work/alice-prepared \
124
+ --val-ratio 0.05
125
+ ```
126
+
127
+ ### 2. Fine-tune from a pretrained checkpoint
128
+
129
+ When fine-tuning onto new speakers, `tiny-voca-ru-train` copies compatible weights and initializes new speaker embeddings from `--init-voice` (or the mean of pretrained voices):
130
+
131
+ ```bash
132
+ tiny-voca-ru-train \
133
+ --data-dir work/alice-prepared \
134
+ --init-from checkpoints/tiny-voca-ru \
135
+ --init-voice F \
136
+ --output work/alice-run \
137
+ --steps 5000 \
138
+ --learning-rate 1e-4 \
139
+ --save-every 500
140
+ ```
141
+
142
+ Add `--freeze-encoder` for small datasets (< 30 min). Resume with `--resume work/alice-run/last.pt`. Safetensors checkpoints are saved to `work/alice-run/inference/` and `work/alice-run/best/`.
143
+
144
+ ## ONNX Export & Legacy Checkpoint Conversion
145
+
146
+ ```bash
147
+ # Export safetensors checkpoint -> model.onnx + model.json
148
+ tiny-voca-ru-export \
149
+ --checkpoint checkpoints/tiny-voca-ru \
150
+ --output checkpoints/tiny-voca-ru-onnx
151
+
152
+ # Convert legacy .pt checkpoint -> model.safetensors + config.json
153
+ tiny-voca-ru-convert \
154
+ --source path/to/tiny-voca-ru.pt \
155
+ --output checkpoints/tiny-voca-ru
156
+ ```
157
+
158
+ ## Browser Demo
159
+
160
+ The static demo in `web/public/` runs `tiny_voca_ru.frontend` in Pyodide and `model.onnx` + `accent.onnx` via ONNX Runtime Web entirely offline:
161
+
162
+ ```bash
163
+ bash web/build_assets.sh checkpoints/tiny-voca-ru-onnx
164
+ python3 -m http.server --directory web/public 8000
165
+ ```
166
+
167
+ ## Development
168
+
169
+ ```bash
170
+ uv sync --python 3.12 --extra torch --extra onnx --extra train --group dev
171
+ uv run pytest -q
172
+ uv run ruff check .
173
+ uv run ruff format --check .
174
+ uv run basedpyright
175
+ ```
176
+
177
+ ## Citation
178
+
179
+ Machine-readable citation metadata is available in [CITATION.cff](https://github.com/yilbegan/tiny-voca-ru/blob/main/CITATION.cff).
180
+
181
+ ```bibtex
182
+ @misc{chetvertkov2026tinyvocaru,
183
+ author = {Chetvertkov, Evgeniy},
184
+ title = {tiny-voca-ru: A 4.5M-Parameter Russian Text-to-Speech Model},
185
+ year = {2026},
186
+ url = {https://huggingface.co/egnch/tiny-voca-ru},
187
+ note = {ORCID: https://orcid.org/0009-0006-6158-2624}
188
+ }
189
+ ```
190
+
191
+ Please also consider citing the original [`tiny-voca`](https://huggingface.co/n4ze3m/tiny-voca) by Muhammed Nazeem (2026).
192
+
193
+ ## License & Attribution
194
+
195
+ Code and weights are licensed under the Apache License 2.0 ([LICENSE](https://github.com/yilbegan/tiny-voca-ru/blob/main/LICENSE)).
196
+ See [NOTICE](https://github.com/yilbegan/tiny-voca-ru/blob/main/NOTICE) for attribution to `tiny-voca` (Muhammed Nazeem, Apache-2.0) and `ruaccent` (MIT License, bundled `stress.txt.gz` and `accent.onnx` in `src/tiny_voca_ru/frontend/data/`).