syscon-tts 0.0.2__tar.gz → 0.0.4__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 (31) hide show
  1. {syscon_tts-0.0.2/src/syscon_tts.egg-info → syscon_tts-0.0.4}/PKG-INFO +117 -39
  2. {syscon_tts-0.0.2 → syscon_tts-0.0.4}/README.md +115 -38
  3. {syscon_tts-0.0.2 → syscon_tts-0.0.4}/pyproject.toml +98 -76
  4. {syscon_tts-0.0.2 → syscon_tts-0.0.4}/src/syscon_tts/__init__.py +16 -2
  5. syscon_tts-0.0.4/src/syscon_tts/alerts.py +502 -0
  6. {syscon_tts-0.0.2 → syscon_tts-0.0.4}/src/syscon_tts/api.py +157 -145
  7. syscon_tts-0.0.4/src/syscon_tts/benchmark.py +117 -0
  8. {syscon_tts-0.0.2 → syscon_tts-0.0.4}/src/syscon_tts/cli.py +436 -345
  9. {syscon_tts-0.0.2 → syscon_tts-0.0.4}/src/syscon_tts/config.py +336 -260
  10. {syscon_tts-0.0.2 → syscon_tts-0.0.4}/src/syscon_tts/data/voices.json +115 -113
  11. {syscon_tts-0.0.2 → syscon_tts-0.0.4}/src/syscon_tts/download.py +255 -188
  12. {syscon_tts-0.0.2 → syscon_tts-0.0.4}/src/syscon_tts/engine.py +58 -8
  13. {syscon_tts-0.0.2 → syscon_tts-0.0.4}/src/syscon_tts/voices.py +413 -407
  14. {syscon_tts-0.0.2 → syscon_tts-0.0.4/src/syscon_tts.egg-info}/PKG-INFO +117 -39
  15. {syscon_tts-0.0.2 → syscon_tts-0.0.4}/src/syscon_tts.egg-info/SOURCES.txt +1 -0
  16. {syscon_tts-0.0.2 → syscon_tts-0.0.4}/src/syscon_tts.egg-info/requires.txt +1 -0
  17. {syscon_tts-0.0.2 → syscon_tts-0.0.4}/tests/test_alerts.py +488 -308
  18. {syscon_tts-0.0.2 → syscon_tts-0.0.4}/tests/test_api.py +128 -102
  19. syscon_tts-0.0.4/tests/test_cli.py +235 -0
  20. {syscon_tts-0.0.2 → syscon_tts-0.0.4}/tests/test_config.py +133 -16
  21. syscon_tts-0.0.4/tests/test_download.py +243 -0
  22. {syscon_tts-0.0.2 → syscon_tts-0.0.4}/tests/test_engine.py +87 -10
  23. {syscon_tts-0.0.2 → syscon_tts-0.0.4}/tests/test_voices.py +2 -2
  24. syscon_tts-0.0.2/src/syscon_tts/alerts.py +0 -296
  25. syscon_tts-0.0.2/tests/test_cli.py +0 -82
  26. syscon_tts-0.0.2/tests/test_download.py +0 -100
  27. {syscon_tts-0.0.2 → syscon_tts-0.0.4}/LICENSE +0 -0
  28. {syscon_tts-0.0.2 → syscon_tts-0.0.4}/setup.cfg +0 -0
  29. {syscon_tts-0.0.2 → syscon_tts-0.0.4}/src/syscon_tts.egg-info/dependency_links.txt +0 -0
  30. {syscon_tts-0.0.2 → syscon_tts-0.0.4}/src/syscon_tts.egg-info/entry_points.txt +0 -0
  31. {syscon_tts-0.0.2 → syscon_tts-0.0.4}/src/syscon_tts.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: syscon-tts
3
- Version: 0.0.2
3
+ Version: 0.0.4
4
4
  Summary: Offline neural text-to-speech for the PlantStar APU
5
5
  Author: Keith Hostetler
6
6
  Author-email: robh@syscon-intl.com
@@ -30,6 +30,7 @@ Requires-Dist: fastapi<1.0,>=0.111; extra == "server"
30
30
  Requires-Dist: uvicorn[standard]<1.0,>=0.30; extra == "server"
31
31
  Provides-Extra: dev
32
32
  Requires-Dist: pytest<9,>=8.2; extra == "dev"
33
+ Requires-Dist: ruff<1.0,>=0.6; extra == "dev"
33
34
  Requires-Dist: httpx<1.0,>=0.27; extra == "dev"
34
35
  Requires-Dist: fastapi<1.0,>=0.111; extra == "dev"
35
36
  Requires-Dist: uvicorn[standard]<1.0,>=0.30; extra == "dev"
@@ -47,12 +48,13 @@ previous VoiceText integration.
47
48
  TTS. No GPU required.
48
49
  - **Interfaces:** a Python library (what the APU uses), a CLI, and an optional
49
50
  HTTP server.
50
- - **Voices:** eight voices across five languages out of the box — including
51
+ - **Voices:** seven voices across five languages out of the box — including
51
52
  every locale the APU's UI offers — configured in a single JSON manifest, and
52
53
  extensible per deployment by dropping model files into the voices directory.
53
54
  - **Licensing:** the shipped catalogue only contains voices whose upstream
54
55
  license permits use in a product you sell. See
55
- [Voices and licensing](#voices-and-licensing).
56
+ [Voices and licensing](https://github.com/SYSCON-International/syscon_tts/blob/main/README.md#voices-and-licensing). The engine's own licensing is
57
+ an open question — see [Engine licensing](https://github.com/SYSCON-International/syscon_tts/blob/main/README.md#engine-licensing).
56
58
 
57
59
  ```bash
58
60
  pip install syscon-tts
@@ -64,8 +66,12 @@ syscon-tts doctor # confirm the install
64
66
 
65
67
  ## Platform support
66
68
 
67
- Piper ships **Linux-only** binary wheels. Rather than making that a hard
68
- install failure everywhere else, the dependency is platform-gated, so the same
69
+ Piper depends on `piper-phonemize`, whose 1.1.0 release publishes binary
70
+ wheels for **Linux on Python 3.9–3.11** and for Intel macOS (cp310–cp312) —
71
+ nothing for Windows, Apple Silicon, or Linux on Python 3.12+. Linux is the only
72
+ platform synthesis is tested on, so the dependency marker installs Piper only
73
+ on Linux with Python < 3.12. Rather than making that a hard install failure
74
+ everywhere else, the dependency is platform-gated, so the same
69
75
  `pip install syscon-tts` works on every platform and gives you what that
70
76
  platform can actually do:
71
77
 
@@ -106,31 +112,52 @@ synthesizer = AlertSynthesizer(
106
112
  alerts_dir=Path(settings.MEDIA_ROOT, "public_alert_sounds"),
107
113
  )
108
114
 
115
+ # The APU needs the name up front to build the client's audio URL.
116
+ file_name = synthesizer.file_name_for(message, language=locale)
117
+
109
118
  result = synthesizer.ensure(
110
119
  message,
111
- file_name=file_name, # the APU's get_valid_filename(message)[:50]
120
+ file_name=file_name,
112
121
  language=locale, # optional: "es-mx", "zh-hans", ...
113
122
  )
114
123
  # result.path -> the WAV on disk
115
- # result.cached -> True if it already existed (no synthesis happened)
124
+ # result.cached -> True if a matching file already existed (no synthesis)
125
+ # result.voice -> the voice id, on a hit or a miss
116
126
  ```
117
127
 
118
128
  Two things the APU must do around this call, both covered in
119
- [DEPLOY.md](DEPLOY.md): run it in a thread (synthesis is a seconds-long CPU
120
- burn and `call_tts` is invoked from the Tornado IO loop), and apply the APU's
121
- own `root:www-data` ownership to `result.path` afterwards.
122
-
123
- `ensure()` is **cache first**: if the WAV is already there it returns
124
- immediately without touching Piper. Only a cache miss synthesizes.
125
-
126
- The package derives file names with the exact algorithm the APU already uses
127
- (`django.utils.text.get_valid_filename(text)[:50]`), verified byte-for-byte
128
- including Unicode and the empty-name error cases — so both sides always agree
129
- on the path. Passing `file_name` explicitly is still recommended, so the APU
130
- stays the single source of truth.
129
+ [DEPLOY.md](https://github.com/SYSCON-International/syscon_tts/blob/main/DEPLOY.md):
130
+ run it in a thread (synthesis is a seconds-long CPU burn and `call_tts` is
131
+ invoked from the Tornado IO loop), and apply the APU's own `root:www-data`
132
+ ownership to `result.path` afterwards.
133
+
134
+ **File names are unique per message.** `file_name_for()` (and `ensure()` when
135
+ no `file_name` is given) returns the first 41 characters of the sanitized text
136
+ — Django's `get_valid_filename` rules, so a directory listing stays readable —
137
+ plus `_` and an 8-hex-digit hash of the full text and voice: 50 characters at
138
+ most, the APU's existing limit. Two messages sharing a long prefix, or one
139
+ message in two voices, never share a file. The APU must use this name rather
140
+ than its old `get_valid_filename(message)[:50]`. An explicit `file_name` must
141
+ be one plain path component (letters, digits, `_`, `-`, `.`), or `ensure()`
142
+ raises `InvalidAlertNameError`.
143
+
144
+ `ensure()` is **cache first, and checks what it finds.** Every WAV it writes
145
+ carries a fingerprint of its text, voice, speed and sentence silence in a
146
+ standard RIFF `LIST/INFO` chunk. A file whose fingerprint matches is returned
147
+ immediately without touching Piper; a file with a different fingerprint, or
148
+ none (VoiceText output, or audio from syscon-tts 0.0.x), is rendered again
149
+ rather than announced. Concurrent `ensure()` calls for the same file wait for
150
+ each other, so N clients announcing one message render it once. Alert text is
151
+ capped at `max_alert_chars` (1,000 by default); longer text raises
152
+ `AlertTextTooLongError`.
131
153
 
132
154
  Full integration recipe, including the `IS_LIVE` gate, file ownership and the
133
- threading requirement: [DEPLOY.md](DEPLOY.md).
155
+ threading requirement:
156
+ [DEPLOY.md](https://github.com/SYSCON-International/syscon_tts/blob/main/DEPLOY.md).
157
+
158
+ The library logs under the `syscon_tts` logger — model loads, synthesis
159
+ timings and evictions at INFO, cache hits and misses at DEBUG, and a language
160
+ falling back to the default voice at WARNING. Attach a handler to see them.
134
161
 
135
162
  ---
136
163
 
@@ -141,7 +168,6 @@ threading requirement: [DEPLOY.md](DEPLOY.md).
141
168
  | `en_us_kristin` | en_US | Kristin — female (**default**) | public domain |
142
169
  | `en_us_john` | en_US | John — male | public domain |
143
170
  | `es_mx_ald` | es_MX | Ald — Mexican Spanish | Unlicense |
144
- | `es_mx_ald_x_low` | es_MX | Ald — smallest model | Unlicense |
145
171
  | `es_es_davefx` | es_ES | DaveFX — male (Castilian) | CC0 |
146
172
  | `zh_cn_huayan` | zh_CN | Huayan — Mandarin | **unknown — needs review** |
147
173
  | `fr_fr_siwis` | fr_FR | Siwis — female | CC BY 4.0 (attribution) |
@@ -203,6 +229,8 @@ release of this package:
203
229
  2. **Layer a manifest.** Point `SYSCON_TTS_EXTRA_MANIFEST` at a JSON file of
204
230
  the same shape as the bundled one; new ids are added, reused ids replace the
205
231
  bundled entry. Use this when the voice should also be downloadable.
232
+ `model_sha256` / `config_sha256` are optional but recommended: with them,
233
+ downloads are verified before install and `doctor` re-checks the files.
206
234
 
207
235
  Fetch only what a site will actually speak:
208
236
 
@@ -215,11 +243,31 @@ syscon-tts download-voices --language es-mx
215
243
 
216
244
  ---
217
245
 
246
+ ## Engine licensing
247
+
248
+ This package is MIT, and so is `piper-tts` 1.2.0. But `piper-tts` 1.2.0
249
+ requires `piper-phonemize~=1.1.0`, whose wheels bundle **espeak-ng, which is
250
+ GPL-3.0**. And `piper-tts` 1.3 and later moved to
251
+ [OHF-voice/piper1-gpl](https://github.com/OHF-voice/piper1-gpl) and are
252
+ **GPL-3.0-or-later** themselves.
253
+
254
+ PlantStar is sold and installed on customer hardware, so shipping a
255
+ GPL-licensed component with it is a distribution question. **That question is
256
+ open: a legal decision is pending.** Until it is made:
257
+
258
+ - `piper-tts` is pinned to exactly `1.2.0`, and must not move past 1.2.x
259
+ without legal review. `tests/test_config.py::test_piper_engine_stays_pinned_to_1_2_0`
260
+ fails if the pin changes.
261
+ - Treat the espeak-ng component as unresolved, not cleared, when answering
262
+ questions about what a customer install contains.
263
+
264
+ ---
265
+
218
266
  ## CLI
219
267
 
220
268
  ```bash
221
- syscon-tts doctor # platform, Piper, model + license status
222
- syscon-tts download-voices # fetch the catalogue (needs internet)
269
+ syscon-tts doctor # platform, Piper, model hashes + license status
270
+ syscon-tts download-voices # fetch the catalogue (needs internet; SHA-256 verified)
223
271
  syscon-tts download-voices --language es-mx # or just one site's language
224
272
  syscon-tts download-voices en_us_kristin # or one named voice
225
273
  syscon-tts list-voices # catalogue, install state, licenses
@@ -230,11 +278,18 @@ syscon-tts speak -l es-mx -o aviso.wav "Presion de cavidad excedida en prensa 4.
230
278
  syscon-tts speak -v de_de_thorsten -f mp3 -o ansage.mp3 --text-file notice.txt
231
279
 
232
280
  syscon-tts alert "Press 4 cavity pressure exceeded." # cache-first, as the APU does
281
+ syscon-tts alert -l es-mx "Presion de cavidad excedida en prensa 4."
233
282
  syscon-tts serve --port 5002 # needs [server] extra
283
+ syscon-tts benchmark --threads 2 # RTF per installed voice
284
+
285
+ syscon-tts -V doctor --quick # -V logs model loads (-VV adds cache decisions);
286
+ # --quick skips re-hashing installed models
234
287
  ```
235
288
 
236
- `alert` exits `2` when the audio is absent *and* this machine cannot
237
- synthesize — distinguishable from `1` for ordinary errors.
289
+ `alert` exits `0` on success, `1` on an error, `2` on a usage error
290
+ (argparse), and `69` (`EX_UNAVAILABLE`) when the audio has to be synthesized
291
+ and this machine cannot run Piper — so a provisioning script can tell a typo
292
+ from a platform limitation.
238
293
 
239
294
  ---
240
295
 
@@ -251,15 +306,22 @@ All optional; every one has a working default.
251
306
  | `SYSCON_TTS_DEFAULT_VOICE` | `en_us_kristin` | Voice used when none is given |
252
307
  | `SYSCON_TTS_DEFAULT_VOICES` | — | Per-language defaults, `es-mx=es_mx_ald,...` |
253
308
  | `SYSCON_TTS_MAX_LOADED_VOICES` | `3` | Voice models kept resident in memory |
309
+ | `SYSCON_TTS_THREADS` | unset (onnxruntime's default: one per physical core) | CPU threads per synthesis |
310
+ | `SYSCON_TTS_MAX_ALERT_CHARS` | `1000` | Max alert text length (library / `alert`) |
254
311
  | `SYSCON_TTS_FILE_MODE` | `0644` | Mode for generated audio |
255
312
  | `SYSCON_TTS_DIR_MODE` | `0755` | Mode for directories this package creates |
256
313
  | `SYSCON_TTS_HOST` | `127.0.0.1` | HTTP server bind host |
257
314
  | `SYSCON_TTS_PORT` | `5002` | HTTP server bind port |
258
- | `SYSCON_TTS_MAX_CHARS` | `20000` | Max text length per request |
315
+ | `SYSCON_TTS_MAX_CHARS` | `20000` | Max text length per HTTP request |
259
316
 
260
- The platform data dir is `/var/lib/syscon-tts` on Linux when writable
261
- (otherwise `~/.local/share/syscon-tts`), `%LOCALAPPDATA%\syscon-tts` on
262
- Windows, and `~/Library/Application Support/syscon-tts` on macOS.
317
+ The platform data dir on Linux is `/var/lib/syscon-tts` whenever that
318
+ directory exists — even if the current user cannot write to it, since models
319
+ only need to be readable — or when it can be created; otherwise
320
+ `~/.local/share/syscon-tts` (`$XDG_DATA_HOME`). It is
321
+ `%LOCALAPPDATA%\syscon-tts` on Windows and
322
+ `~/Library/Application Support/syscon-tts` on macOS. `syscon-tts doctor`
323
+ prints the data dir it chose and why; `download-voices` into a directory the
324
+ user cannot write fails with an explicit permission error.
263
325
 
264
326
  An embedded caller that already knows its paths should skip the environment
265
327
  entirely — every setting is a constructor keyword:
@@ -268,6 +330,11 @@ entirely — every setting is a constructor keyword:
268
330
  AlertSynthesizer(alerts_dir=..., default_voices={"zh_CN": "zh_cn_huayan"})
269
331
  ```
270
332
 
333
+ Keywords get the same normalization as environment variables: language keys
334
+ are normalized (`{"es-mx": ...}` becomes `es_MX`), modes may be octal strings
335
+ (`file_mode="0644"`), and integers are coerced (`port="5002"`). Constructing
336
+ `Settings(...)` directly validates the same way.
337
+
271
338
  ### Where the files go on an APU
272
339
 
273
340
  | What | Where | Why |
@@ -328,16 +395,19 @@ pytest
328
395
 
329
396
  The full test suite passes on Windows and macOS without Piper — synthesis is
330
397
  mocked throughout, so no voice models are needed. See
331
- [CONTRIBUTING.md](CONTRIBUTING.md).
398
+ [CONTRIBUTING.md](https://github.com/SYSCON-International/syscon_tts/blob/main/CONTRIBUTING.md).
332
399
 
333
400
  ---
334
401
 
335
402
  ## Documentation
336
403
 
337
- - [DEPLOY.md](DEPLOY.md) — provisioning an APU, the `call_tts()` replacement,
338
- air-gapped installs, tuning.
339
- - [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) — module layout, design
340
- decisions, operations, troubleshooting.
404
+ - [DEPLOY.md](https://github.com/SYSCON-International/syscon_tts/blob/main/DEPLOY.md)
405
+ — provisioning an APU, the `call_tts()` replacement, air-gapped installs,
406
+ tuning.
407
+ - [docs/ARCHITECTURE.md](https://github.com/SYSCON-International/syscon_tts/blob/main/docs/ARCHITECTURE.md)
408
+ — module layout, design decisions, operations, troubleshooting.
409
+ - [CHANGELOG.md](https://github.com/SYSCON-International/syscon_tts/blob/main/CHANGELOG.md)
410
+ — what changed in each release, and what an integrator has to act on.
341
411
 
342
412
  ---
343
413
 
@@ -346,18 +416,26 @@ mocked throughout, so no voice models are needed. See
346
416
  Piper runs on CPU, so throughput depends on the host. Measure on the target:
347
417
 
348
418
  ```bash
349
- python scripts/benchmark.py # per-voice cold load, memory, RTF, latency
419
+ syscon-tts benchmark # per-voice cold load, memory, RTF, latency
420
+ syscon-tts benchmark --threads 2 # the same, with synthesis capped at 2 threads
350
421
  ```
351
422
 
352
423
  It reports the **real-time factor** (RTF = synthesis time ÷ audio seconds) for
353
424
  short/medium/long messages. Record results with
354
- [docs/bench-results-template.md](docs/bench-results-template.md) and use them to
355
- pick quality tiers — switching a voice to its `low`-quality model in the
356
- manifest is the main lever on a weak CPU.
425
+ [docs/bench-results-template.md](https://github.com/SYSCON-International/syscon_tts/blob/main/docs/bench-results-template.md)
426
+ and use them to pick quality tiers — switching a voice to its `low`-quality
427
+ model through an overlay manifest is the main lever on a weak CPU.
428
+
429
+ By default each synthesis uses one onnxruntime thread per physical core, which
430
+ saturates the CPU for the length of the utterance. On a host with other work
431
+ to do, cap it with `SYSCON_TTS_THREADS` (or `threads=` as a constructor
432
+ keyword).
357
433
 
358
434
  Expect roughly 50–120 MB resident per loaded `medium` voice; models stay in
359
435
  memory after first use to avoid reload latency.
360
436
 
361
437
  ## License
362
438
 
363
- MIT — see [LICENSE](LICENSE).
439
+ MIT — see [LICENSE](https://github.com/SYSCON-International/syscon_tts/blob/main/LICENSE).
440
+ The speech engine's dependencies are not all MIT — see
441
+ [Engine licensing](https://github.com/SYSCON-International/syscon_tts/blob/main/README.md#engine-licensing).
@@ -10,12 +10,13 @@ previous VoiceText integration.
10
10
  TTS. No GPU required.
11
11
  - **Interfaces:** a Python library (what the APU uses), a CLI, and an optional
12
12
  HTTP server.
13
- - **Voices:** eight voices across five languages out of the box — including
13
+ - **Voices:** seven voices across five languages out of the box — including
14
14
  every locale the APU's UI offers — configured in a single JSON manifest, and
15
15
  extensible per deployment by dropping model files into the voices directory.
16
16
  - **Licensing:** the shipped catalogue only contains voices whose upstream
17
17
  license permits use in a product you sell. See
18
- [Voices and licensing](#voices-and-licensing).
18
+ [Voices and licensing](https://github.com/SYSCON-International/syscon_tts/blob/main/README.md#voices-and-licensing). The engine's own licensing is
19
+ an open question — see [Engine licensing](https://github.com/SYSCON-International/syscon_tts/blob/main/README.md#engine-licensing).
19
20
 
20
21
  ```bash
21
22
  pip install syscon-tts
@@ -27,8 +28,12 @@ syscon-tts doctor # confirm the install
27
28
 
28
29
  ## Platform support
29
30
 
30
- Piper ships **Linux-only** binary wheels. Rather than making that a hard
31
- install failure everywhere else, the dependency is platform-gated, so the same
31
+ Piper depends on `piper-phonemize`, whose 1.1.0 release publishes binary
32
+ wheels for **Linux on Python 3.9–3.11** and for Intel macOS (cp310–cp312) —
33
+ nothing for Windows, Apple Silicon, or Linux on Python 3.12+. Linux is the only
34
+ platform synthesis is tested on, so the dependency marker installs Piper only
35
+ on Linux with Python < 3.12. Rather than making that a hard install failure
36
+ everywhere else, the dependency is platform-gated, so the same
32
37
  `pip install syscon-tts` works on every platform and gives you what that
33
38
  platform can actually do:
34
39
 
@@ -69,31 +74,52 @@ synthesizer = AlertSynthesizer(
69
74
  alerts_dir=Path(settings.MEDIA_ROOT, "public_alert_sounds"),
70
75
  )
71
76
 
77
+ # The APU needs the name up front to build the client's audio URL.
78
+ file_name = synthesizer.file_name_for(message, language=locale)
79
+
72
80
  result = synthesizer.ensure(
73
81
  message,
74
- file_name=file_name, # the APU's get_valid_filename(message)[:50]
82
+ file_name=file_name,
75
83
  language=locale, # optional: "es-mx", "zh-hans", ...
76
84
  )
77
85
  # result.path -> the WAV on disk
78
- # result.cached -> True if it already existed (no synthesis happened)
86
+ # result.cached -> True if a matching file already existed (no synthesis)
87
+ # result.voice -> the voice id, on a hit or a miss
79
88
  ```
80
89
 
81
90
  Two things the APU must do around this call, both covered in
82
- [DEPLOY.md](DEPLOY.md): run it in a thread (synthesis is a seconds-long CPU
83
- burn and `call_tts` is invoked from the Tornado IO loop), and apply the APU's
84
- own `root:www-data` ownership to `result.path` afterwards.
85
-
86
- `ensure()` is **cache first**: if the WAV is already there it returns
87
- immediately without touching Piper. Only a cache miss synthesizes.
88
-
89
- The package derives file names with the exact algorithm the APU already uses
90
- (`django.utils.text.get_valid_filename(text)[:50]`), verified byte-for-byte
91
- including Unicode and the empty-name error cases — so both sides always agree
92
- on the path. Passing `file_name` explicitly is still recommended, so the APU
93
- stays the single source of truth.
91
+ [DEPLOY.md](https://github.com/SYSCON-International/syscon_tts/blob/main/DEPLOY.md):
92
+ run it in a thread (synthesis is a seconds-long CPU burn and `call_tts` is
93
+ invoked from the Tornado IO loop), and apply the APU's own `root:www-data`
94
+ ownership to `result.path` afterwards.
95
+
96
+ **File names are unique per message.** `file_name_for()` (and `ensure()` when
97
+ no `file_name` is given) returns the first 41 characters of the sanitized text
98
+ — Django's `get_valid_filename` rules, so a directory listing stays readable —
99
+ plus `_` and an 8-hex-digit hash of the full text and voice: 50 characters at
100
+ most, the APU's existing limit. Two messages sharing a long prefix, or one
101
+ message in two voices, never share a file. The APU must use this name rather
102
+ than its old `get_valid_filename(message)[:50]`. An explicit `file_name` must
103
+ be one plain path component (letters, digits, `_`, `-`, `.`), or `ensure()`
104
+ raises `InvalidAlertNameError`.
105
+
106
+ `ensure()` is **cache first, and checks what it finds.** Every WAV it writes
107
+ carries a fingerprint of its text, voice, speed and sentence silence in a
108
+ standard RIFF `LIST/INFO` chunk. A file whose fingerprint matches is returned
109
+ immediately without touching Piper; a file with a different fingerprint, or
110
+ none (VoiceText output, or audio from syscon-tts 0.0.x), is rendered again
111
+ rather than announced. Concurrent `ensure()` calls for the same file wait for
112
+ each other, so N clients announcing one message render it once. Alert text is
113
+ capped at `max_alert_chars` (1,000 by default); longer text raises
114
+ `AlertTextTooLongError`.
94
115
 
95
116
  Full integration recipe, including the `IS_LIVE` gate, file ownership and the
96
- threading requirement: [DEPLOY.md](DEPLOY.md).
117
+ threading requirement:
118
+ [DEPLOY.md](https://github.com/SYSCON-International/syscon_tts/blob/main/DEPLOY.md).
119
+
120
+ The library logs under the `syscon_tts` logger — model loads, synthesis
121
+ timings and evictions at INFO, cache hits and misses at DEBUG, and a language
122
+ falling back to the default voice at WARNING. Attach a handler to see them.
97
123
 
98
124
  ---
99
125
 
@@ -104,7 +130,6 @@ threading requirement: [DEPLOY.md](DEPLOY.md).
104
130
  | `en_us_kristin` | en_US | Kristin — female (**default**) | public domain |
105
131
  | `en_us_john` | en_US | John — male | public domain |
106
132
  | `es_mx_ald` | es_MX | Ald — Mexican Spanish | Unlicense |
107
- | `es_mx_ald_x_low` | es_MX | Ald — smallest model | Unlicense |
108
133
  | `es_es_davefx` | es_ES | DaveFX — male (Castilian) | CC0 |
109
134
  | `zh_cn_huayan` | zh_CN | Huayan — Mandarin | **unknown — needs review** |
110
135
  | `fr_fr_siwis` | fr_FR | Siwis — female | CC BY 4.0 (attribution) |
@@ -166,6 +191,8 @@ release of this package:
166
191
  2. **Layer a manifest.** Point `SYSCON_TTS_EXTRA_MANIFEST` at a JSON file of
167
192
  the same shape as the bundled one; new ids are added, reused ids replace the
168
193
  bundled entry. Use this when the voice should also be downloadable.
194
+ `model_sha256` / `config_sha256` are optional but recommended: with them,
195
+ downloads are verified before install and `doctor` re-checks the files.
169
196
 
170
197
  Fetch only what a site will actually speak:
171
198
 
@@ -178,11 +205,31 @@ syscon-tts download-voices --language es-mx
178
205
 
179
206
  ---
180
207
 
208
+ ## Engine licensing
209
+
210
+ This package is MIT, and so is `piper-tts` 1.2.0. But `piper-tts` 1.2.0
211
+ requires `piper-phonemize~=1.1.0`, whose wheels bundle **espeak-ng, which is
212
+ GPL-3.0**. And `piper-tts` 1.3 and later moved to
213
+ [OHF-voice/piper1-gpl](https://github.com/OHF-voice/piper1-gpl) and are
214
+ **GPL-3.0-or-later** themselves.
215
+
216
+ PlantStar is sold and installed on customer hardware, so shipping a
217
+ GPL-licensed component with it is a distribution question. **That question is
218
+ open: a legal decision is pending.** Until it is made:
219
+
220
+ - `piper-tts` is pinned to exactly `1.2.0`, and must not move past 1.2.x
221
+ without legal review. `tests/test_config.py::test_piper_engine_stays_pinned_to_1_2_0`
222
+ fails if the pin changes.
223
+ - Treat the espeak-ng component as unresolved, not cleared, when answering
224
+ questions about what a customer install contains.
225
+
226
+ ---
227
+
181
228
  ## CLI
182
229
 
183
230
  ```bash
184
- syscon-tts doctor # platform, Piper, model + license status
185
- syscon-tts download-voices # fetch the catalogue (needs internet)
231
+ syscon-tts doctor # platform, Piper, model hashes + license status
232
+ syscon-tts download-voices # fetch the catalogue (needs internet; SHA-256 verified)
186
233
  syscon-tts download-voices --language es-mx # or just one site's language
187
234
  syscon-tts download-voices en_us_kristin # or one named voice
188
235
  syscon-tts list-voices # catalogue, install state, licenses
@@ -193,11 +240,18 @@ syscon-tts speak -l es-mx -o aviso.wav "Presion de cavidad excedida en prensa 4.
193
240
  syscon-tts speak -v de_de_thorsten -f mp3 -o ansage.mp3 --text-file notice.txt
194
241
 
195
242
  syscon-tts alert "Press 4 cavity pressure exceeded." # cache-first, as the APU does
243
+ syscon-tts alert -l es-mx "Presion de cavidad excedida en prensa 4."
196
244
  syscon-tts serve --port 5002 # needs [server] extra
245
+ syscon-tts benchmark --threads 2 # RTF per installed voice
246
+
247
+ syscon-tts -V doctor --quick # -V logs model loads (-VV adds cache decisions);
248
+ # --quick skips re-hashing installed models
197
249
  ```
198
250
 
199
- `alert` exits `2` when the audio is absent *and* this machine cannot
200
- synthesize — distinguishable from `1` for ordinary errors.
251
+ `alert` exits `0` on success, `1` on an error, `2` on a usage error
252
+ (argparse), and `69` (`EX_UNAVAILABLE`) when the audio has to be synthesized
253
+ and this machine cannot run Piper — so a provisioning script can tell a typo
254
+ from a platform limitation.
201
255
 
202
256
  ---
203
257
 
@@ -214,15 +268,22 @@ All optional; every one has a working default.
214
268
  | `SYSCON_TTS_DEFAULT_VOICE` | `en_us_kristin` | Voice used when none is given |
215
269
  | `SYSCON_TTS_DEFAULT_VOICES` | — | Per-language defaults, `es-mx=es_mx_ald,...` |
216
270
  | `SYSCON_TTS_MAX_LOADED_VOICES` | `3` | Voice models kept resident in memory |
271
+ | `SYSCON_TTS_THREADS` | unset (onnxruntime's default: one per physical core) | CPU threads per synthesis |
272
+ | `SYSCON_TTS_MAX_ALERT_CHARS` | `1000` | Max alert text length (library / `alert`) |
217
273
  | `SYSCON_TTS_FILE_MODE` | `0644` | Mode for generated audio |
218
274
  | `SYSCON_TTS_DIR_MODE` | `0755` | Mode for directories this package creates |
219
275
  | `SYSCON_TTS_HOST` | `127.0.0.1` | HTTP server bind host |
220
276
  | `SYSCON_TTS_PORT` | `5002` | HTTP server bind port |
221
- | `SYSCON_TTS_MAX_CHARS` | `20000` | Max text length per request |
277
+ | `SYSCON_TTS_MAX_CHARS` | `20000` | Max text length per HTTP request |
222
278
 
223
- The platform data dir is `/var/lib/syscon-tts` on Linux when writable
224
- (otherwise `~/.local/share/syscon-tts`), `%LOCALAPPDATA%\syscon-tts` on
225
- Windows, and `~/Library/Application Support/syscon-tts` on macOS.
279
+ The platform data dir on Linux is `/var/lib/syscon-tts` whenever that
280
+ directory exists — even if the current user cannot write to it, since models
281
+ only need to be readable — or when it can be created; otherwise
282
+ `~/.local/share/syscon-tts` (`$XDG_DATA_HOME`). It is
283
+ `%LOCALAPPDATA%\syscon-tts` on Windows and
284
+ `~/Library/Application Support/syscon-tts` on macOS. `syscon-tts doctor`
285
+ prints the data dir it chose and why; `download-voices` into a directory the
286
+ user cannot write fails with an explicit permission error.
226
287
 
227
288
  An embedded caller that already knows its paths should skip the environment
228
289
  entirely — every setting is a constructor keyword:
@@ -231,6 +292,11 @@ entirely — every setting is a constructor keyword:
231
292
  AlertSynthesizer(alerts_dir=..., default_voices={"zh_CN": "zh_cn_huayan"})
232
293
  ```
233
294
 
295
+ Keywords get the same normalization as environment variables: language keys
296
+ are normalized (`{"es-mx": ...}` becomes `es_MX`), modes may be octal strings
297
+ (`file_mode="0644"`), and integers are coerced (`port="5002"`). Constructing
298
+ `Settings(...)` directly validates the same way.
299
+
234
300
  ### Where the files go on an APU
235
301
 
236
302
  | What | Where | Why |
@@ -291,16 +357,19 @@ pytest
291
357
 
292
358
  The full test suite passes on Windows and macOS without Piper — synthesis is
293
359
  mocked throughout, so no voice models are needed. See
294
- [CONTRIBUTING.md](CONTRIBUTING.md).
360
+ [CONTRIBUTING.md](https://github.com/SYSCON-International/syscon_tts/blob/main/CONTRIBUTING.md).
295
361
 
296
362
  ---
297
363
 
298
364
  ## Documentation
299
365
 
300
- - [DEPLOY.md](DEPLOY.md) — provisioning an APU, the `call_tts()` replacement,
301
- air-gapped installs, tuning.
302
- - [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) — module layout, design
303
- decisions, operations, troubleshooting.
366
+ - [DEPLOY.md](https://github.com/SYSCON-International/syscon_tts/blob/main/DEPLOY.md)
367
+ — provisioning an APU, the `call_tts()` replacement, air-gapped installs,
368
+ tuning.
369
+ - [docs/ARCHITECTURE.md](https://github.com/SYSCON-International/syscon_tts/blob/main/docs/ARCHITECTURE.md)
370
+ — module layout, design decisions, operations, troubleshooting.
371
+ - [CHANGELOG.md](https://github.com/SYSCON-International/syscon_tts/blob/main/CHANGELOG.md)
372
+ — what changed in each release, and what an integrator has to act on.
304
373
 
305
374
  ---
306
375
 
@@ -309,18 +378,26 @@ mocked throughout, so no voice models are needed. See
309
378
  Piper runs on CPU, so throughput depends on the host. Measure on the target:
310
379
 
311
380
  ```bash
312
- python scripts/benchmark.py # per-voice cold load, memory, RTF, latency
381
+ syscon-tts benchmark # per-voice cold load, memory, RTF, latency
382
+ syscon-tts benchmark --threads 2 # the same, with synthesis capped at 2 threads
313
383
  ```
314
384
 
315
385
  It reports the **real-time factor** (RTF = synthesis time ÷ audio seconds) for
316
386
  short/medium/long messages. Record results with
317
- [docs/bench-results-template.md](docs/bench-results-template.md) and use them to
318
- pick quality tiers — switching a voice to its `low`-quality model in the
319
- manifest is the main lever on a weak CPU.
387
+ [docs/bench-results-template.md](https://github.com/SYSCON-International/syscon_tts/blob/main/docs/bench-results-template.md)
388
+ and use them to pick quality tiers — switching a voice to its `low`-quality
389
+ model through an overlay manifest is the main lever on a weak CPU.
390
+
391
+ By default each synthesis uses one onnxruntime thread per physical core, which
392
+ saturates the CPU for the length of the utterance. On a host with other work
393
+ to do, cap it with `SYSCON_TTS_THREADS` (or `threads=` as a constructor
394
+ keyword).
320
395
 
321
396
  Expect roughly 50–120 MB resident per loaded `medium` voice; models stay in
322
397
  memory after first use to avoid reload latency.
323
398
 
324
399
  ## License
325
400
 
326
- MIT — see [LICENSE](LICENSE).
401
+ MIT — see [LICENSE](https://github.com/SYSCON-International/syscon_tts/blob/main/LICENSE).
402
+ The speech engine's dependencies are not all MIT — see
403
+ [Engine licensing](https://github.com/SYSCON-International/syscon_tts/blob/main/README.md#engine-licensing).