stackvox 0.2.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.
stackvox-0.2.0/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may accept and charge a
167
+ fee for accepting support, warranty, indemnity, or other liability
168
+ obligations and/or rights consistent with this License. However, in
169
+ accepting such obligations, You may act only on Your own behalf
170
+ and on Your sole responsibility, not on behalf of any other
171
+ Contributor, and only if You agree to indemnify, defend, and hold
172
+ each Contributor harmless for any liability incurred by, or claims
173
+ asserted against, such Contributor by reason of your accepting any
174
+ such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 StackOne Technologies Ltd.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
stackvox-0.2.0/NOTICE ADDED
@@ -0,0 +1,62 @@
1
+ stackvox
2
+ Copyright 2026 StackOne Technologies Ltd.
3
+
4
+ This product includes software developed by StackOne Technologies Ltd.
5
+ (https://www.stackone.com/) and is licensed under the Apache License,
6
+ Version 2.0. A copy of the license is provided in the LICENSE file.
7
+
8
+ --------------------------------------------------------------------------------
9
+ Third-party components
10
+ --------------------------------------------------------------------------------
11
+
12
+ This product relies on, but does not bundle, the following components. They
13
+ are downloaded or installed separately at install / first-run time. Their
14
+ original copyright notices and license terms apply; see the URLs below for
15
+ the authoritative text.
16
+
17
+ Kokoro-82M (TTS model weights and voice files)
18
+ Copyright (c) hexgrad
19
+ Licensed under the Apache License, Version 2.0
20
+ https://huggingface.co/hexgrad/Kokoro-82M
21
+
22
+ stackvox downloads the ONNX-converted model (`kokoro-v1.0.onnx`) and voice
23
+ pack (`voices-v1.0.bin`) from the kokoro-onnx GitHub release assets on
24
+ first use and caches them under `~/.cache/stackvox/`. These files are
25
+ neither modified nor redistributed by stackvox.
26
+
27
+ kokoro-onnx
28
+ Copyright (c) 2025 github.com/thewh1teagle
29
+ Licensed under the MIT License
30
+ https://github.com/thewh1teagle/kokoro-onnx
31
+
32
+ onnxruntime
33
+ Copyright (c) Microsoft Corporation
34
+ Licensed under the MIT License
35
+ https://github.com/microsoft/onnxruntime
36
+
37
+ numpy
38
+ Copyright (c) 2005-2024, NumPy Developers
39
+ Licensed under the BSD 3-Clause License
40
+ https://numpy.org/
41
+
42
+ sounddevice
43
+ Copyright (c) 2015-2025 Matthias Geier
44
+ Licensed under the MIT License
45
+ https://python-sounddevice.readthedocs.io/
46
+
47
+ soundfile (pysoundfile)
48
+ Copyright (c) 2013, Bastian Bechtold
49
+ Licensed under the BSD 3-Clause License
50
+ https://github.com/bastibe/python-soundfile
51
+
52
+ phonemizer-fork
53
+ Licensed under the GNU General Public License v3.0
54
+ https://github.com/bootphon/phonemizer
55
+
56
+ phonemizer-fork is a transitive runtime dependency of kokoro-onnx. It is
57
+ installed by pip alongside stackvox but is neither modified, bundled, nor
58
+ statically linked into stackvox itself — stackvox and phonemizer-fork
59
+ communicate only through phonemizer-fork's published Python interface at
60
+ runtime. Downstream users who distribute a combined work that includes
61
+ phonemizer-fork should review GPL-3.0 obligations for their own
62
+ distribution.
@@ -0,0 +1,185 @@
1
+ Metadata-Version: 2.4
2
+ Name: stackvox
3
+ Version: 0.2.0
4
+ Summary: Offline TTS library using Kokoro-82M
5
+ Author-email: "StackOne Technologies Ltd." <engineering@stackone.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/StackOneHQ/stackvox
8
+ Project-URL: Repository, https://github.com/StackOneHQ/stackvox
9
+ Project-URL: Issues, https://github.com/StackOneHQ/stackvox/issues
10
+ Keywords: tts,kokoro,onnx,offline,speech
11
+ Classifier: Operating System :: MacOS
12
+ Classifier: Operating System :: POSIX :: Linux
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ License-File: NOTICE
20
+ Requires-Dist: kokoro-onnx>=0.4.0
21
+ Requires-Dist: soundfile>=0.12.1
22
+ Requires-Dist: sounddevice>=0.4.6
23
+ Requires-Dist: numpy>=1.24
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=8.0; extra == "dev"
26
+ Requires-Dist: pytest-mock>=3.12; extra == "dev"
27
+ Requires-Dist: pytest-cov>=5.0; extra == "dev"
28
+ Requires-Dist: ruff>=0.5; extra == "dev"
29
+ Requires-Dist: pre-commit>=3.7; extra == "dev"
30
+ Requires-Dist: commitizen>=3.27; extra == "dev"
31
+ Requires-Dist: mypy>=1.11; extra == "dev"
32
+ Dynamic: license-file
33
+
34
+ # stackvox
35
+
36
+ [![ci](https://github.com/StackOneHQ/stackvox/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/StackOneHQ/stackvox/actions/workflows/ci.yml)
37
+ [![coverage](https://codecov.io/gh/StackOneHQ/stackvox/branch/main/graph/badge.svg)](https://codecov.io/gh/StackOneHQ/stackvox)
38
+ [![python](https://img.shields.io/badge/python-3.10%2B-blue)](https://www.python.org/downloads/)
39
+ [![license](https://img.shields.io/badge/license-Apache%202.0-blue)](./LICENSE)
40
+
41
+ Offline TTS using [Kokoro-82M](https://huggingface.co/hexgrad/Kokoro-82M) via [kokoro-onnx](https://github.com/thewh1teagle/kokoro-onnx). Apache 2.0 model, ~340MB, CPU real-time, plays straight to system audio. Designed to be importable as a Python library, drivable as a CLI, or poked via a unix socket for ~13ms speech requests from shell scripts.
42
+
43
+ ## Install
44
+
45
+ Recommended — install globally with pipx so `stackvox` and `stackvox-say` end up on PATH:
46
+
47
+ ```bash
48
+ pipx install git+https://github.com/StackOneHQ/stackvox.git
49
+ ```
50
+
51
+ Upgrade later with `pipx install --force git+https://github.com/StackOneHQ/stackvox.git` (pipx's `upgrade` doesn't always detect new commits on git installs).
52
+
53
+ Dev install from a clone:
54
+
55
+ ```bash
56
+ python3 -m venv .venv && source .venv/bin/activate
57
+ pip install -e .
58
+ ```
59
+
60
+ Model + voice files auto-download to `~/.cache/stackvox/` on first use. Override with `STACKVOX_CACHE_DIR`.
61
+
62
+ ## CLI
63
+
64
+ ```bash
65
+ stackvox "Hello world" # synthesize and play in-process
66
+ stackvox speak "Hi" --voice bf_emma # same, explicit subcommand
67
+ stackvox speak "save" --out a.wav # write wav instead of playing
68
+ stackvox welcome # multilingual welcome (6 languages)
69
+ stackvox voices # list all voice ids
70
+ ```
71
+
72
+ Daemon mode (keeps the model resident so each subsequent call is instant):
73
+
74
+ ```bash
75
+ stackvox serve # foreground; run with `nohup stackvox serve &` to background
76
+ stackvox status # is the daemon up?
77
+ stackvox say "Hello" # send text to the daemon (fails if not running)
78
+ stackvox stop # graceful shutdown
79
+ ```
80
+
81
+ ## `stackvox-say` (bash helper, ~13ms)
82
+
83
+ When you want minimum latency from shell scripts (hooks, CI steps, etc.), skip the Python client and use the bash helper — it talks directly to the daemon's unix socket via `nc`:
84
+
85
+ ```bash
86
+ stackvox-say "back to you in 5"
87
+ stackvox-say --voice bf_emma --speed 1.1 "hello"
88
+ stackvox-say --fallback-say "text" # shell out to macOS `say` if daemon is down
89
+ ```
90
+
91
+ Exit codes: `0` ok, `2` daemon unreachable (unless `--fallback-say` was given).
92
+
93
+ ## Python library
94
+
95
+ ```python
96
+ from stackvox import Stackvox, speak, synthesize
97
+
98
+ # One-shot — model loads on first call, reused for subsequent calls.
99
+ speak("Hello world")
100
+
101
+ # Reusable engine.
102
+ tts = Stackvox(voice="af_bella")
103
+ tts.speak("First line")
104
+ tts.speak("Faster", speed=1.2)
105
+
106
+ # Non-blocking playback.
107
+ tts.speak("async", blocking=False)
108
+ tts.stop()
109
+
110
+ # Raw samples for custom processing.
111
+ samples, sr = tts.synthesize("give me the array")
112
+
113
+ # Gapless multi-line playback with concurrent synthesis.
114
+ tts.speak_sequence([
115
+ {"text": "Hello", "voice": "af_heart", "lang": "en-us"},
116
+ {"text": "Bonjour", "voice": "ff_siwis", "lang": "fr-fr"},
117
+ ])
118
+ ```
119
+
120
+ ### Daemon client from Python
121
+
122
+ ```python
123
+ from stackvox import daemon
124
+
125
+ ok, resp = daemon.say("queue this via the running daemon")
126
+ if daemon.is_running():
127
+ daemon.stop()
128
+ ```
129
+
130
+ ## Voices
131
+
132
+ Kokoro ships voices across several languages. Voice prefix encodes gender + language:
133
+
134
+ | Prefix | Language | Example |
135
+ | -------------- | ---------------- | ------------------------ |
136
+ | `af_*`, `am_*` | American English | `af_heart`, `am_michael` |
137
+ | `bf_*`, `bm_*` | British English | `bf_emma`, `bm_fable` |
138
+ | `ff_*` | French | `ff_siwis` |
139
+ | `hf_*`, `hm_*` | Hindi | `hf_alpha`, `hm_omega` |
140
+ | `if_*`, `im_*` | Italian | `if_sara`, `im_nicola` |
141
+ | `pf_*`, `pm_*` | Portuguese | `pf_dora`, `pm_alex` |
142
+ | `ef_*`, `em_*` | Spanish | `ef_dora`, `em_alex` |
143
+ | `jf_*`, `jm_*` | Japanese | `jf_alpha` |
144
+ | `zf_*`, `zm_*` | Mandarin Chinese | `zf_xiaoxiao` |
145
+
146
+ Run `stackvox voices` for the authoritative list.
147
+
148
+ ## Architecture
149
+
150
+ ```
151
+ ┌────────────────────┐ unix socket ┌─────────────────────────┐
152
+ │ stackvox-say │ ───────────────────────▶ │ stackvox daemon │
153
+ │ (bash, ~13ms) │ JSON line per request │ (Python, long-lived) │
154
+ └────────────────────┘ │ │
155
+ ┌────────────────────┐ ~500ms (Py startup) │ preloaded Kokoro ONNX │
156
+ │ stackvox say │ ───────────────────────▶ │ worker thread playback │
157
+ │ (Python client) │ │ → sounddevice → audio │
158
+ └────────────────────┘ └─────────────────────────┘
159
+ ┌────────────────────┐
160
+ │ stackvox speak │ loads model in-process, plays, exits
161
+ │ (one-shot CLI) │
162
+ └────────────────────┘
163
+ ```
164
+
165
+ Socket lives at `~/.cache/stackvox/daemon.sock` (override with `STACKVOX_SOCKET` for the client, `STACKVOX_CACHE_DIR` for the daemon). Protocol is one line of JSON per connection: `{"text":"...", "voice":"...", "speed":1.0, "lang":"en-us"}`; reply is `ok` / `busy` / `err: <msg>`. Plain text (no JSON) is accepted as a fallback and treated as `{"text": line}`.
166
+
167
+ Queue depth is 2 — rapid-fire requests beyond that get `busy` rather than piling up.
168
+
169
+ Before each utterance the daemon resets PortAudio so it picks up the current system default output device. Swap from speakers to Bluetooth headphones mid-session and the next `say` follows you — no daemon restart needed. The refresh costs ~10–50ms per play, which is invisible next to synthesis time.
170
+
171
+ ## Requirements
172
+
173
+ - Python 3.10+
174
+ - macOS or Linux
175
+ - `nc` (BSD netcat — default on macOS, `netcat-openbsd` on Linux) for the bash helper
176
+
177
+ ## License & attributions
178
+
179
+ stackvox itself is licensed under the **Apache License, Version 2.0** — see [`LICENSE`](./LICENSE). Third-party attributions are collected in [`NOTICE`](./NOTICE); the summary below is informational.
180
+
181
+ **Model.** Speech is generated by [Kokoro-82M](https://huggingface.co/hexgrad/Kokoro-82M) (© hexgrad, Apache 2.0). The ONNX-converted weights (`kokoro-v1.0.onnx`) and voice pack (`voices-v1.0.bin`) are downloaded from the [kokoro-onnx](https://github.com/thewh1teagle/kokoro-onnx) release assets on first use and cached under `~/.cache/stackvox/`. stackvox does not modify or redistribute them.
182
+
183
+ **Runtime dependencies.** [`kokoro-onnx`](https://github.com/thewh1teagle/kokoro-onnx) (MIT, © thewh1teagle), [`onnxruntime`](https://github.com/microsoft/onnxruntime) (MIT, © Microsoft), [`sounddevice`](https://python-sounddevice.readthedocs.io/) (MIT, © Matthias Geier), [`soundfile`](https://github.com/bastibe/python-soundfile) (BSD-3, © Bastian Bechtold), [`numpy`](https://numpy.org/) (BSD-3).
184
+
185
+ **GPL note.** `kokoro-onnx` pulls in [`phonemizer-fork`](https://github.com/bootphon/phonemizer) as a transitive runtime dependency; it is licensed under **GPL-3.0**. stackvox does not bundle, modify, or statically link it — pip installs it alongside stackvox and the two communicate through phonemizer's published Python API at runtime. If you redistribute a combined work (e.g. a frozen binary, container image, or vendored wheel set) that includes phonemizer-fork, review GPL-3.0 obligations for that distribution.
@@ -0,0 +1,152 @@
1
+ # stackvox
2
+
3
+ [![ci](https://github.com/StackOneHQ/stackvox/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/StackOneHQ/stackvox/actions/workflows/ci.yml)
4
+ [![coverage](https://codecov.io/gh/StackOneHQ/stackvox/branch/main/graph/badge.svg)](https://codecov.io/gh/StackOneHQ/stackvox)
5
+ [![python](https://img.shields.io/badge/python-3.10%2B-blue)](https://www.python.org/downloads/)
6
+ [![license](https://img.shields.io/badge/license-Apache%202.0-blue)](./LICENSE)
7
+
8
+ Offline TTS using [Kokoro-82M](https://huggingface.co/hexgrad/Kokoro-82M) via [kokoro-onnx](https://github.com/thewh1teagle/kokoro-onnx). Apache 2.0 model, ~340MB, CPU real-time, plays straight to system audio. Designed to be importable as a Python library, drivable as a CLI, or poked via a unix socket for ~13ms speech requests from shell scripts.
9
+
10
+ ## Install
11
+
12
+ Recommended — install globally with pipx so `stackvox` and `stackvox-say` end up on PATH:
13
+
14
+ ```bash
15
+ pipx install git+https://github.com/StackOneHQ/stackvox.git
16
+ ```
17
+
18
+ Upgrade later with `pipx install --force git+https://github.com/StackOneHQ/stackvox.git` (pipx's `upgrade` doesn't always detect new commits on git installs).
19
+
20
+ Dev install from a clone:
21
+
22
+ ```bash
23
+ python3 -m venv .venv && source .venv/bin/activate
24
+ pip install -e .
25
+ ```
26
+
27
+ Model + voice files auto-download to `~/.cache/stackvox/` on first use. Override with `STACKVOX_CACHE_DIR`.
28
+
29
+ ## CLI
30
+
31
+ ```bash
32
+ stackvox "Hello world" # synthesize and play in-process
33
+ stackvox speak "Hi" --voice bf_emma # same, explicit subcommand
34
+ stackvox speak "save" --out a.wav # write wav instead of playing
35
+ stackvox welcome # multilingual welcome (6 languages)
36
+ stackvox voices # list all voice ids
37
+ ```
38
+
39
+ Daemon mode (keeps the model resident so each subsequent call is instant):
40
+
41
+ ```bash
42
+ stackvox serve # foreground; run with `nohup stackvox serve &` to background
43
+ stackvox status # is the daemon up?
44
+ stackvox say "Hello" # send text to the daemon (fails if not running)
45
+ stackvox stop # graceful shutdown
46
+ ```
47
+
48
+ ## `stackvox-say` (bash helper, ~13ms)
49
+
50
+ When you want minimum latency from shell scripts (hooks, CI steps, etc.), skip the Python client and use the bash helper — it talks directly to the daemon's unix socket via `nc`:
51
+
52
+ ```bash
53
+ stackvox-say "back to you in 5"
54
+ stackvox-say --voice bf_emma --speed 1.1 "hello"
55
+ stackvox-say --fallback-say "text" # shell out to macOS `say` if daemon is down
56
+ ```
57
+
58
+ Exit codes: `0` ok, `2` daemon unreachable (unless `--fallback-say` was given).
59
+
60
+ ## Python library
61
+
62
+ ```python
63
+ from stackvox import Stackvox, speak, synthesize
64
+
65
+ # One-shot — model loads on first call, reused for subsequent calls.
66
+ speak("Hello world")
67
+
68
+ # Reusable engine.
69
+ tts = Stackvox(voice="af_bella")
70
+ tts.speak("First line")
71
+ tts.speak("Faster", speed=1.2)
72
+
73
+ # Non-blocking playback.
74
+ tts.speak("async", blocking=False)
75
+ tts.stop()
76
+
77
+ # Raw samples for custom processing.
78
+ samples, sr = tts.synthesize("give me the array")
79
+
80
+ # Gapless multi-line playback with concurrent synthesis.
81
+ tts.speak_sequence([
82
+ {"text": "Hello", "voice": "af_heart", "lang": "en-us"},
83
+ {"text": "Bonjour", "voice": "ff_siwis", "lang": "fr-fr"},
84
+ ])
85
+ ```
86
+
87
+ ### Daemon client from Python
88
+
89
+ ```python
90
+ from stackvox import daemon
91
+
92
+ ok, resp = daemon.say("queue this via the running daemon")
93
+ if daemon.is_running():
94
+ daemon.stop()
95
+ ```
96
+
97
+ ## Voices
98
+
99
+ Kokoro ships voices across several languages. Voice prefix encodes gender + language:
100
+
101
+ | Prefix | Language | Example |
102
+ | -------------- | ---------------- | ------------------------ |
103
+ | `af_*`, `am_*` | American English | `af_heart`, `am_michael` |
104
+ | `bf_*`, `bm_*` | British English | `bf_emma`, `bm_fable` |
105
+ | `ff_*` | French | `ff_siwis` |
106
+ | `hf_*`, `hm_*` | Hindi | `hf_alpha`, `hm_omega` |
107
+ | `if_*`, `im_*` | Italian | `if_sara`, `im_nicola` |
108
+ | `pf_*`, `pm_*` | Portuguese | `pf_dora`, `pm_alex` |
109
+ | `ef_*`, `em_*` | Spanish | `ef_dora`, `em_alex` |
110
+ | `jf_*`, `jm_*` | Japanese | `jf_alpha` |
111
+ | `zf_*`, `zm_*` | Mandarin Chinese | `zf_xiaoxiao` |
112
+
113
+ Run `stackvox voices` for the authoritative list.
114
+
115
+ ## Architecture
116
+
117
+ ```
118
+ ┌────────────────────┐ unix socket ┌─────────────────────────┐
119
+ │ stackvox-say │ ───────────────────────▶ │ stackvox daemon │
120
+ │ (bash, ~13ms) │ JSON line per request │ (Python, long-lived) │
121
+ └────────────────────┘ │ │
122
+ ┌────────────────────┐ ~500ms (Py startup) │ preloaded Kokoro ONNX │
123
+ │ stackvox say │ ───────────────────────▶ │ worker thread playback │
124
+ │ (Python client) │ │ → sounddevice → audio │
125
+ └────────────────────┘ └─────────────────────────┘
126
+ ┌────────────────────┐
127
+ │ stackvox speak │ loads model in-process, plays, exits
128
+ │ (one-shot CLI) │
129
+ └────────────────────┘
130
+ ```
131
+
132
+ Socket lives at `~/.cache/stackvox/daemon.sock` (override with `STACKVOX_SOCKET` for the client, `STACKVOX_CACHE_DIR` for the daemon). Protocol is one line of JSON per connection: `{"text":"...", "voice":"...", "speed":1.0, "lang":"en-us"}`; reply is `ok` / `busy` / `err: <msg>`. Plain text (no JSON) is accepted as a fallback and treated as `{"text": line}`.
133
+
134
+ Queue depth is 2 — rapid-fire requests beyond that get `busy` rather than piling up.
135
+
136
+ Before each utterance the daemon resets PortAudio so it picks up the current system default output device. Swap from speakers to Bluetooth headphones mid-session and the next `say` follows you — no daemon restart needed. The refresh costs ~10–50ms per play, which is invisible next to synthesis time.
137
+
138
+ ## Requirements
139
+
140
+ - Python 3.10+
141
+ - macOS or Linux
142
+ - `nc` (BSD netcat — default on macOS, `netcat-openbsd` on Linux) for the bash helper
143
+
144
+ ## License & attributions
145
+
146
+ stackvox itself is licensed under the **Apache License, Version 2.0** — see [`LICENSE`](./LICENSE). Third-party attributions are collected in [`NOTICE`](./NOTICE); the summary below is informational.
147
+
148
+ **Model.** Speech is generated by [Kokoro-82M](https://huggingface.co/hexgrad/Kokoro-82M) (© hexgrad, Apache 2.0). The ONNX-converted weights (`kokoro-v1.0.onnx`) and voice pack (`voices-v1.0.bin`) are downloaded from the [kokoro-onnx](https://github.com/thewh1teagle/kokoro-onnx) release assets on first use and cached under `~/.cache/stackvox/`. stackvox does not modify or redistribute them.
149
+
150
+ **Runtime dependencies.** [`kokoro-onnx`](https://github.com/thewh1teagle/kokoro-onnx) (MIT, © thewh1teagle), [`onnxruntime`](https://github.com/microsoft/onnxruntime) (MIT, © Microsoft), [`sounddevice`](https://python-sounddevice.readthedocs.io/) (MIT, © Matthias Geier), [`soundfile`](https://github.com/bastibe/python-soundfile) (BSD-3, © Bastian Bechtold), [`numpy`](https://numpy.org/) (BSD-3).
151
+
152
+ **GPL note.** `kokoro-onnx` pulls in [`phonemizer-fork`](https://github.com/bootphon/phonemizer) as a transitive runtime dependency; it is licensed under **GPL-3.0**. stackvox does not bundle, modify, or statically link it — pip installs it alongside stackvox and the two communicate through phonemizer's published Python API at runtime. If you redistribute a combined work (e.g. a frozen binary, container image, or vendored wheel set) that includes phonemizer-fork, review GPL-3.0 obligations for that distribution.
@@ -0,0 +1,67 @@
1
+ #!/bin/bash
2
+ # stackvox-say — fast TTS client for hooks.
3
+ # Talks directly to the stackvox daemon over its unix socket, bypassing
4
+ # Python startup. Falls back to macOS `say` with --fallback-say.
5
+ #
6
+ # Usage:
7
+ # stackvox-say "text"
8
+ # stackvox-say --voice bf_emma --speed 1.1 "text"
9
+ # stackvox-say --fallback-say "text"
10
+ # stackvox-say --socket /tmp/other.sock "text"
11
+ #
12
+ # Env:
13
+ # STACKVOX_SOCKET — override socket path (default: ~/.cache/stackvox/daemon.sock)
14
+
15
+ set -u
16
+
17
+ sock="${STACKVOX_SOCKET:-$HOME/.cache/stackvox/daemon.sock}"
18
+ voice="" speed="" lang="" fallback=0 text=""
19
+
20
+ while [[ $# -gt 0 ]]; do
21
+ case "$1" in
22
+ --voice) voice="$2"; shift 2 ;;
23
+ --speed) speed="$2"; shift 2 ;;
24
+ --lang) lang="$2"; shift 2 ;;
25
+ --fallback-say) fallback=1; shift ;;
26
+ --socket) sock="$2"; shift 2 ;;
27
+ -h|--help)
28
+ sed -n '3,13p' "$0" | sed 's/^# \{0,1\}//'
29
+ exit 0 ;;
30
+ --) shift; text="$*"; break ;;
31
+ -*) echo "stackvox-say: unknown flag: $1" >&2; exit 1 ;;
32
+ *) text="${text:+$text }$1"; shift ;;
33
+ esac
34
+ done
35
+
36
+ if [[ -z "$text" ]]; then
37
+ echo "stackvox-say: no text provided" >&2
38
+ exit 1
39
+ fi
40
+
41
+ do_fallback() {
42
+ if [[ $fallback -eq 1 ]] && command -v say >/dev/null; then
43
+ say "$text"
44
+ exit 0
45
+ fi
46
+ exit 2
47
+ }
48
+
49
+ [[ -S "$sock" ]] || do_fallback
50
+ command -v nc >/dev/null || do_fallback
51
+
52
+ # Minimal JSON escape: backslash, double quote, newline, tab.
53
+ esc=${text//\\/\\\\}
54
+ esc=${esc//\"/\\\"}
55
+ esc=${esc//$'\n'/\\n}
56
+ esc=${esc//$'\t'/\\t}
57
+
58
+ payload='{"text":"'$esc'"'
59
+ [[ -n "$voice" ]] && payload+=',"voice":"'$voice'"'
60
+ [[ -n "$speed" ]] && payload+=',"speed":'$speed
61
+ [[ -n "$lang" ]] && payload+=',"lang":"'$lang'"'
62
+ payload+='}'
63
+
64
+ resp=$(printf '%s\n' "$payload" | nc -U -w 1 "$sock" 2>/dev/null)
65
+ [[ "$resp" == "ok" ]] && exit 0
66
+
67
+ do_fallback