termux-tts 1.4.3 → 1.4.4
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.
- package/.github/workflows/release.yml +98 -98
- package/CHANGELOG.md +69 -57
- package/LICENSE +17 -17
- package/README.md +138 -441
- package/README.pypi.md +54 -441
- package/bin/cli.js +33 -33
- package/doc.config.yaml +596 -532
- package/docs/benchmarks.md +11 -11
- package/index.js +5 -5
- package/install.sh +53 -53
- package/package.json +57 -57
- package/pyproject.toml +81 -81
- package/setup.py +38 -38
- package/termux_tts/__init__.py +74 -64
- package/termux_tts/audio.py +6 -3
- package/termux_tts/cli.py +27 -10
- package/termux_tts/control/component.py +398 -398
- package/termux_tts/engine.py +73 -7
- package/termux_tts/engine_multilingual.py +374 -0
- package/termux_tts/engine_native.py +104 -104
- package/termux_tts/engine_sherpa.py +2 -1
- package/termux_tts/engine_sherpa_capi.py +491 -0
- package/termux_tts/exceptions.py +28 -28
- package/termux_tts/hardware.py +34 -1
- package/termux_tts/installer.py +154 -12
- package/termux_tts/script_classifier.py +253 -0
- package/termux_tts/tokenizer.py +186 -184
package/README.md
CHANGED
|
@@ -1,441 +1,138 @@
|
|
|
1
|
-
# Termux-TTS
|
|
2
|
-
|
|
3
|
-
[](https://pypi.org/project/termux-tts/)
|
|
4
|
-
[](https://pypi.org/project/termux-tts/)
|
|
5
|
-
[](https://www.npmjs.com/package/termux-tts)
|
|
6
|
-
[](https://github.com/uno-km/termux-tts)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
#
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
#
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
#
|
|
74
|
-
termux-tts
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
#
|
|
111
|
-
with tts.load(engine="
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
const result = await engine.synthesize(
|
|
142
|
-
"Synthesizing high-resolution neural speech in Node.js on Termux.",
|
|
143
|
-
{ output: 'node_output.wav', speed: 1.0 }
|
|
144
|
-
);
|
|
145
|
-
|
|
146
|
-
console.log(`Synthesized in ${result.elapsedMs}ms | RTF: ${result.rtf}x`);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
main().catch(console.error);
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
---
|
|
153
|
-
|
|
154
|
-
## 4. Advanced Usage & 4-Tier Speech Architecture
|
|
155
|
-
|
|
156
|
-
Termux-TTS features a robust 4-tier synthesis architecture engineered to provide the optimal balance between acoustic fidelity, memory consumption, and compute latency.
|
|
157
|
-
|
|
158
|
-
### 4.1 Architecture Tier Breakdown
|
|
159
|
-
1. **Tier 1: Parametric DSP Formant Vocoder (`engine="dsp"`)**:
|
|
160
|
-
- Zero-dependency Rosenberg glottal source pulse generator paired with a 5-band second-order biquad formant resonator filter bank.
|
|
161
|
-
- 0MB disk footprint, deterministic latency under 50ms (RTF ~0.013x on ARM Cortex-A78).
|
|
162
|
-
- Ideal for embedded alerts, battery-saving modes, and fail-safe recovery.
|
|
163
|
-
2. **Tier 2: Android System Native Voice Bridge (`engine="native"`)**:
|
|
164
|
-
- Direct IPC connection to Android `TextToSpeech` service via `termux-api` and Unix domain sockets.
|
|
165
|
-
- Zero CPU inference overhead; delegates synthesis and playback to Samsung Voice Engine or Google Speech Services.
|
|
166
|
-
3. **Tier 3: Subprocess-Isolated Sherpa C++ Engine (`engine="neural"`)**:
|
|
167
|
-
- CPU-based VITS neural acoustic synthesis with multi-threaded ARM NEON SIMD vectorization.
|
|
168
|
-
- Subprocess process-isolation prevents memory fragmentation and native memory leaks during multi-hour continuous execution.
|
|
169
|
-
4. **Tier 4: Pure Vulkan GPU Hardware Neural Engine (`engine="vulkan"`)**:
|
|
170
|
-
- End-to-end GPU compute shader pipeline via `sherpa-ncnn` with zero silent CPU fallback.
|
|
171
|
-
- Evaluates high-resolution FP16 neural models (`vits-piper-en_US-lessac-high-fp16`) natively on mobile GPU silicon.
|
|
172
|
-
|
|
173
|
-
### 4.2 Emotional & Expressive Conversational Modulation
|
|
174
|
-
The Expressive Engine (`engine="expressive"`) injects natural acoustic non-verbal vocalizations directly into neural synthesis:
|
|
175
|
-
- `[sigh]` / `[한숨]`: Organic aspiration decay and exhalation acoustic wave.
|
|
176
|
-
- `[laugh]` / `[웃음]`: Rhythmic 6.5 Hz glottal laughter bursts with vocal fold resonance.
|
|
177
|
-
- `[breath]` / `[호흡]`: Soft physiological inhalation pause.
|
|
178
|
-
- `[pause]` / `[쉼]`: Contextual silence spacing.
|
|
179
|
-
|
|
180
|
-
```python
|
|
181
|
-
import termux_tts as tts
|
|
182
|
-
|
|
183
|
-
with tts.load(engine="expressive", language="en") as engine:
|
|
184
|
-
script = (
|
|
185
|
-
"Good morning! [breath] We have successfully deployed the system. "
|
|
186
|
-
"[laugh] It took all night, [sigh] but everything is operating smoothly now."
|
|
187
|
-
)
|
|
188
|
-
res = engine.synthesize(script, output="conversational.wav")
|
|
189
|
-
print(f"Expressive tags processed: {res.expressive_tags_detected}")
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
### 4.3 Streaming & Real-Time Audio Buffer Manipulation
|
|
193
|
-
Inspect and manipulate raw floating-point and 16-bit PCM audio buffers directly in memory before writing to disk:
|
|
194
|
-
```python
|
|
195
|
-
import termux_tts as tts
|
|
196
|
-
|
|
197
|
-
with tts.load(engine="dsp") as engine:
|
|
198
|
-
res = engine.synthesize("Buffer streaming test.")
|
|
199
|
-
audio_buf = res.audio_buffer
|
|
200
|
-
|
|
201
|
-
# Access raw PCM sample array
|
|
202
|
-
samples = audio_buf.samples # np.ndarray (float32, normalized [-1.0, 1.0])
|
|
203
|
-
raw_bytes = audio_buf.to_wav_bytes() # RIFF WAV binary stream
|
|
204
|
-
print(f"Sample count: {len(samples)}, Duration: {audio_buf.duration_seconds:.3f}s")
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
---
|
|
208
|
-
|
|
209
|
-
## 5. Feature & Parameter Matrix
|
|
210
|
-
|
|
211
|
-
### 5.1 CLI Arguments (`termux-tts synth` & `termux-tts speak`)
|
|
212
|
-
|
|
213
|
-
| Option Flag | Argument Type | Default | Description |
|
|
214
|
-
| :--- | :--- | :--- | :--- |
|
|
215
|
-
| `-t`, `--text` | `string` | *(Required)* | Input text or SSML-tagged phrase to synthesize. |
|
|
216
|
-
| `-o`, `--output` | `path` | `output.wav` | Destination filesystem path for generated RIFF WAV file. |
|
|
217
|
-
| `-l`, `--lang` | `string` | `ko` | Target language code (`en`, `ko`). |
|
|
218
|
-
| `-e`, `--engine` | `enum` | `auto` | Engine backend tier: `auto`, `vulkan`, `dsp`, `native`, `neural`, `expressive`. |
|
|
219
|
-
| `--tier` | `enum` | `high` | Model resolution profile: `high` (Studio FP16, 57MB), `medium` (Balanced, 25MB). |
|
|
220
|
-
| `-p`, `--preset` | `enum` | `balanced` | DSP vocoder profile: `fast`, `balanced`, `expressive`, `ultra`. |
|
|
221
|
-
| `-d`, `--device` | `enum` | `auto` | Compute execution device: `auto`, `gpu`, `vulkan`, `cpu`. |
|
|
222
|
-
| `-s`, `--speed` | `float` | `1.0` | Speech cadence multiplier (`0.5` to `2.0`). |
|
|
223
|
-
| `--threads` | `int` | `4` | Worker threads for CPU ARM NEON SIMD compute (1 for GPU). |
|
|
224
|
-
| `--volume` | `int` | `None` | Android media volume level (`1` to `15`). |
|
|
225
|
-
| `--play` | `flag` | `False` | Automatically dispatch audio to physical speaker upon synthesis completion. |
|
|
226
|
-
|
|
227
|
-
### 5.2 Python SDK `load()` Parameters
|
|
228
|
-
|
|
229
|
-
| Parameter | Type | Default | Description |
|
|
230
|
-
| :--- | :--- | :--- | :--- |
|
|
231
|
-
| `engine` | `str` | `"auto"` | Selects target engine: `"vulkan"`, `"dsp"`, `"native"`, `"neural"`, `"expressive"`. |
|
|
232
|
-
| `tier` | `str` | `"high"` | Specifies neural weight tier (`"high"`, `"medium"`). |
|
|
233
|
-
| `language` | `str` | `"ko"` | Phonemizer and lexicon locale code. |
|
|
234
|
-
| `preset` | `str` | `"balanced"` | Parametric DSP quality level (`"fast"`, `"balanced"`, `"expressive"`, `"ultra"`). |
|
|
235
|
-
| `device` | `str` | `"auto"` | Compute target device (`"gpu"`, `"vulkan"`, `"cpu"`, `"auto"`). |
|
|
236
|
-
| `threads` | `int` | `4` | CPU concurrency worker count. |
|
|
237
|
-
| `model` | `str` | `None` | Optional explicit path to custom VITS or NCNN model directory. |
|
|
238
|
-
| `sample_rate`| `int` | `22050` | Audio sampling frequency (Hz). |
|
|
239
|
-
|
|
240
|
-
---
|
|
241
|
-
|
|
242
|
-
## 6. Production Code Examples & Diagnostics
|
|
243
|
-
|
|
244
|
-
### 6.1 Enterprise Batch Speech Pipeline with Fallback Assurance
|
|
245
|
-
```python
|
|
246
|
-
import os
|
|
247
|
-
import termux_tts as tts
|
|
248
|
-
from termux_tts.exceptions import VulkanInitializationError, TTSModelLoadError
|
|
249
|
-
|
|
250
|
-
scripts = [
|
|
251
|
-
"Alert: Thermal gradient within nominal thresholds.",
|
|
252
|
-
"System diagnostics passed all 12 validation gates.",
|
|
253
|
-
"Unattended background daemon active on port 8080."
|
|
254
|
-
]
|
|
255
|
-
|
|
256
|
-
def synthesize_batch(items, out_dir="dist_audio"):
|
|
257
|
-
os.makedirs(out_dir, exist_ok=True)
|
|
258
|
-
|
|
259
|
-
# Attempt primary Tier 4 Vulkan GPU engine with Fail-Safe fallback to Tier 1 DSP
|
|
260
|
-
try:
|
|
261
|
-
engine = tts.load(engine="vulkan", tier="high")
|
|
262
|
-
print("[INFO] Initialized Tier 4 Vulkan GPU Neural Engine.")
|
|
263
|
-
except (VulkanInitializationError, TTSModelLoadError) as exc:
|
|
264
|
-
print(f"[WARN] Hardware acceleration unavailable ({exc}). Falling back to Tier 1 DSP.")
|
|
265
|
-
engine = tts.load(engine="dsp", preset="balanced")
|
|
266
|
-
|
|
267
|
-
with engine:
|
|
268
|
-
for idx, text in enumerate(items):
|
|
269
|
-
out_file = os.path.join(out_dir, f"notice_{idx:02d}.wav")
|
|
270
|
-
res = engine.synthesize(text, output=out_file)
|
|
271
|
-
print(f"[{idx+1}/{len(items)}] Generated '{out_file}' | Backend: {res.backend} | RTF: {res.rtf:.4f}x")
|
|
272
|
-
|
|
273
|
-
if __name__ == "__main__":
|
|
274
|
-
synthesize_batch(scripts)
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
### 6.2 12-Stage Hardware Diagnostic Validation
|
|
278
|
-
Run programmatic health audits to verify Vulkan compute queues, shared memory bindings, and driver integrity:
|
|
279
|
-
```python
|
|
280
|
-
from termux_tts.engine import doctor
|
|
281
|
-
|
|
282
|
-
report = doctor()
|
|
283
|
-
print("Hardware Diagnostic Status:", report["status"])
|
|
284
|
-
print("Passed Verification Stages:", report["passed_stages"])
|
|
285
|
-
print("Recommended Compute Backend:", report["recommended_backend"])
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
---
|
|
289
|
-
|
|
290
|
-
## 7. Real-World Outputs & Empirical Hardware Benchmarks
|
|
291
|
-
|
|
292
|
-
### 7.1 Empirical Physical Device Benchmarks
|
|
293
|
-
All metrics were gathered directly on physical mobile hardware running Android 16 / Termux ARM64:
|
|
294
|
-
|
|
295
|
-
| Device Model | Processor Architecture | Synthesis Engine | Model Profile | Audio Length | Inference Time | Real-Time Factor (RTF) | Memory Footprint |
|
|
296
|
-
| :--- | :--- | :--- | :--- | :---: | :---: | :---: | :---: |
|
|
297
|
-
| **Galaxy S25** | Snapdragon 8 Elite / Adreno 830 | Vulkan GPU Neural | `lessac-high-fp16` | 6.70 s | **6.65 s** | **0.993x** | 68 MB |
|
|
298
|
-
| **Galaxy S25** | Snapdragon 8 Elite / Adreno 830 | Vulkan GPU Neural | `amy-medium` | 4.59 s | **1.21 s** | **0.264x** | 38 MB |
|
|
299
|
-
| **Galaxy A35** | Exynos 1380 / Mali-G68 MP5 | Vulkan GPU Neural | `amy-medium` | 4.52 s | **5.18 s** | **1.146x** | 42 MB |
|
|
300
|
-
| **Galaxy A35** | Exynos 1380 / Mali-G68 MP5 | Vulkan GPU Neural | `lessac-high-fp16` | 6.73 s | **34.33 s** | **5.098x** | 72 MB |
|
|
301
|
-
| **ARM64 CPU** | Cortex-A78 / A55 (Quad-Core) | Parametric DSP Vocoder | 5-Band Biquad | 4.15 s | **0.054 s** | **0.0130x** | **0 MB** |
|
|
302
|
-
|
|
303
|
-
> **Real-Time Factor (RTF) Definition**: $\text{RTF} = \frac{\text{Synthesis Latency (Seconds)}}{\text{Generated Audio Duration (Seconds)}}$.
|
|
304
|
-
> An RTF under `1.0x` indicates faster-than-realtime synthesis suitable for live interactive voice applications.
|
|
305
|
-
|
|
306
|
-
### 7.2 Verified Audio Samples
|
|
307
|
-
Reference audio samples generated directly on-device are included in the repository:
|
|
308
|
-
- **Expressive Emotional Output**: [`docs/assets/samples/expressive_demo.wav`](https://github.com/uno-km/termux-tts/blob/main/docs/assets/samples/expressive_demo.wav) — Demonstrates natural aspiration sighs and laughter tags.
|
|
309
|
-
- **Parametric DSP Output**: [`docs/assets/samples/dsp_test.wav`](https://github.com/uno-km/termux-tts/blob/main/docs/assets/samples/dsp_test.wav) — Demonstrates 0MB instant formant synthesis.
|
|
310
|
-
|
|
311
|
-
---
|
|
312
|
-
|
|
313
|
-
## 8. GPU Interconnect Architecture & Compatibility
|
|
314
|
-
|
|
315
|
-
```mermaid
|
|
316
|
-
flowchart LR
|
|
317
|
-
A["Termux-TTS Application Layer"] --> B["AMEVA Hardware Gateway"]
|
|
318
|
-
B --> C["/system/lib64/libvulkan.so"]
|
|
319
|
-
C --> D{"SoC GPU Silicon"}
|
|
320
|
-
D -->|"Adreno 7xx / 8xx (Full SPIR-V FP16)"| E["Qualcomm Snapdragon"]
|
|
321
|
-
D -->|"Mali Bifrost / Valhall (Driver Pipelined)"| F["ARM Mali / Exynos"]
|
|
322
|
-
E --> G["High-Throughput Shader Core (RTF < 0.3x)"]
|
|
323
|
-
F --> H["Balanced Execution (Medium Tier Recommended)"]
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
### 8.1 Vulkan Compute Shader Pipeline
|
|
327
|
-
Termux-TTS interfaces directly with `/system/lib64/libvulkan.so` via SPIR-V compute shaders compiled in `sherpa-ncnn`. Tensor matrix multiplications for VITS encoder, duration predictor, and inverse coupling flows execute directly on GPU compute units.
|
|
328
|
-
|
|
329
|
-
### 8.2 Silicon Compatibility Matrix
|
|
330
|
-
- **Qualcomm Snapdragon (Adreno 6xx, 7xx, 8xx)**:
|
|
331
|
-
- **Status: Tier-1 Full Support**. Hardware FP16 arithmetic instructions, high sub-group sizes, and low dispatch latency deliver real-time factor performance as low as `0.264x`.
|
|
332
|
-
- **Samsung Exynos / MediaTek Dimensity (ARM Mali-Gxx / Immortalis)**:
|
|
333
|
-
- **Status: Supported (Medium Tier Recommended)**. Works out of the box. Due to Mali driver SPIR-V shader compilation overhead, `--tier medium` (`amy-medium`) is recommended for real-time responsiveness.
|
|
334
|
-
- **Strict Zero-Silent-Fallback**:
|
|
335
|
-
- If `--engine vulkan` or `--gpu` is specified and no Vulkan driver or compatible hardware is available, Termux-TTS raises `VulkanInitializationError` immediately rather than secretly degrading to CPU execution.
|
|
336
|
-
|
|
337
|
-
---
|
|
338
|
-
|
|
339
|
-
## 8-1. CPU vs. GPU Performance & Thermal Trade-offs
|
|
340
|
-
|
|
341
|
-
| Evaluation Metric | CPU Synthesis (ARM Cortex-A78) | Vulkan GPU Neural (Adreno 830) | Parametric DSP (0MB) |
|
|
342
|
-
| :--- | :--- | :--- | :--- |
|
|
343
|
-
| **Real-Time Factor (Medium)** | ~0.85x – 1.10x | **0.264x** (3.5x Faster) | **0.013x** (70x Faster) |
|
|
344
|
-
| **Real-Time Factor (Studio High)** | ~3.80x – 5.20x | **0.993x** (Sub-realtime) | N/A (Formant Only) |
|
|
345
|
-
| **First-Token Latency (TTFA)** | ~450 ms | ~180 ms | **< 15 ms** |
|
|
346
|
-
| **CPU Big-Core Utilization** | 100% across 4 cores | < 15% (Driver Dispatch) | Single Core ~8% |
|
|
347
|
-
| **Thermal Dissipation** | High (Thermal Throttling at ~3min) | Low to Moderate | Negligible |
|
|
348
|
-
| **Memory Allocation** | ~85 MB Heap | ~38 MB (GPU VRAM Mapped) | **0 MB Disk / < 2MB RAM** |
|
|
349
|
-
|
|
350
|
-
Offloading neural acoustic calculations to the Vulkan GPU protects CPU big cores from thermal throttling during prolonged text reading, maintaining consistent interactive responsiveness across Android background services.
|
|
351
|
-
|
|
352
|
-
---
|
|
353
|
-
|
|
354
|
-
## 9. Hardware Requirements & Operational Limits
|
|
355
|
-
|
|
356
|
-
### 9.1 Hardware Specifications
|
|
357
|
-
|
|
358
|
-
| Specification Metric | Minimum Requirements | Recommended Production Spec |
|
|
359
|
-
| :--- | :--- | :--- |
|
|
360
|
-
| **Operating System** | Android 9.0+ (API level 28+) / Linux 5.4+ | Android 12.0+ (API level 31+) |
|
|
361
|
-
| **Architecture** | ARM64 (aarch64) or x86_64 | ARM64-v8a / v9a |
|
|
362
|
-
| **System RAM** | 2 GB Total (DSP Tier: 512 MB) | 4 GB+ Unified RAM |
|
|
363
|
-
| **Storage Footprint** | 10 MB (DSP Only) / 80 MB (Neural) | 250 MB Free Flash Storage |
|
|
364
|
-
| **GPU Subsystem** | Vulkan 1.1 Conforming Mobile Driver | Qualcomm Adreno 660 / 730 / 830 or Mali-G78+ |
|
|
365
|
-
|
|
366
|
-
### 9.2 Known Operational Limits
|
|
367
|
-
- **32-Bit ARM (armeabi-v7a)**: Not supported for Vulkan GPU neural compute. Use Tier 1 DSP vocoder for legacy 32-bit hardware.
|
|
368
|
-
- **Headless SSH Environments**: Audio playback (`--play`) requires Termux-API or PulseAudio daemon running. To output directly without audio hardware, synthesize to `.wav` file.
|
|
369
|
-
|
|
370
|
-
---
|
|
371
|
-
|
|
372
|
-
## 10. 24/7 Unattended Background Execution Guide
|
|
373
|
-
|
|
374
|
-
Android aggressively kills background user-space processes running inside Termux unless battery and process monitor policies are explicitly configured. Follow these three stages to ensure uninterrupted 24/7 autonomous speech services:
|
|
375
|
-
|
|
376
|
-
### 10.1 Stage 1: Termux Wake-Lock
|
|
377
|
-
Prevent the Android kernel from entering deep CPU sleep states:
|
|
378
|
-
```bash
|
|
379
|
-
# Acquire persistent CPU wake-lock
|
|
380
|
-
termux-wake-lock
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
### 10.2 Stage 2: Android OS GUI Settings
|
|
384
|
-
1. Navigate to **Android Settings > Apps > Termux > Battery**.
|
|
385
|
-
2. Select **Unrestricted** (Disable battery optimization).
|
|
386
|
-
3. Under **Permissions**, grant **Notifications** and **Display over other apps** (if applicable).
|
|
387
|
-
|
|
388
|
-
### 10.3 Stage 3: ADB Phantom Process Killer Mitigation (Android 12+)
|
|
389
|
-
Android 12 introduced the Phantom Process Killer, which terminates child processes exceeding 32 instances or high CPU thresholds. Execute the following commands via PC ADB or wireless debugging:
|
|
390
|
-
|
|
391
|
-
```bash
|
|
392
|
-
# Disable Android Phantom Process Killer
|
|
393
|
-
adb shell device_config put activity_manager max_phantom_processes 2147483647
|
|
394
|
-
adb shell settings put global settings_enable_monitor_phantom_procs false
|
|
395
|
-
|
|
396
|
-
# Verify configuration
|
|
397
|
-
adb shell settings get global settings_enable_monitor_phantom_procs
|
|
398
|
-
# Expected output: false
|
|
399
|
-
```
|
|
400
|
-
|
|
401
|
-
---
|
|
402
|
-
|
|
403
|
-
## 11. Open Source License
|
|
404
|
-
|
|
405
|
-
Termux-TTS is open-sourced under the **Apache License, Version 2.0**.
|
|
406
|
-
|
|
407
|
-
```text
|
|
408
|
-
Copyright 2026 Eunho Kim (@uno-km) & AMEVA Open-Source Foundation.
|
|
409
|
-
|
|
410
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
411
|
-
you may not use this file except in compliance with the License.
|
|
412
|
-
You may obtain a copy of the License at
|
|
413
|
-
|
|
414
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
415
|
-
|
|
416
|
-
Unless required by applicable law or agreed to in writing, software
|
|
417
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
418
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
419
|
-
See the License for the specific language governing permissions and
|
|
420
|
-
limitations under the License.
|
|
421
|
-
```
|
|
422
|
-
|
|
423
|
-
### Key Licensing Permissions & Terms:
|
|
424
|
-
- **Commercial Use**: Permitted without royalty or proprietary source disclosure.
|
|
425
|
-
- **Modification & Distribution**: Permitted provided that modified files carry prominent notices.
|
|
426
|
-
- **Patent Grant**: Express grant of patent rights from contributors.
|
|
427
|
-
- **Trademark**: Does not grant permission to use project trademark names without prior written consent.
|
|
428
|
-
- **No Warranty & Limitation of Liability**: Software is provided strictly on an "AS IS" basis.
|
|
429
|
-
|
|
430
|
-
---
|
|
431
|
-
|
|
432
|
-
## 12. SEO Technical Keywords & Metadata
|
|
433
|
-
|
|
434
|
-
`tts`, `text-to-speech`, `vulkan`, `vulkan-compute`, `vits`, `piper-tts`, `sherpa-onnx`, `sherpa-ncnn`, `termux`, `android`, `on-device-ai`, `speech-synthesis`, `edge-ai`, `formant-synthesis`, `vocoder`, `mobile-ai`, `adreno`, `mali-gpu`, `dsp`, `rosenberg-glottal`, `biquad-filter`, `expressive-speech`, `voice-cloning`, `audio-generation`, `ncnn`, `arm64`, `snapdragon`, `exynos`, `real-time-factor`, `low-latency`, `zero-dependency`, `voice-assistant`, `headless-audio`, `embedded-systems`
|
|
435
|
-
|
|
436
|
-
---
|
|
437
|
-
|
|
438
|
-
## Official Documentation & Foundation Ecosystem
|
|
439
|
-
- **Official Documentation Portal**: [https://uno-km.vercel.app/lib/tts/](https://uno-km.vercel.app/lib/tts/)
|
|
440
|
-
- **GitHub Repository**: [https://github.com/uno-km/termux-tts](https://github.com/uno-km/termux-tts)
|
|
441
|
-
- **AMEVA Foundation Portal**: [https://uno-km.vercel.app/foundation/index.html](https://uno-km.vercel.app/foundation/index.html)
|
|
1
|
+
# Termux-TTS
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/termux-tts/)
|
|
4
|
+
[](https://pypi.org/project/termux-tts/)
|
|
5
|
+
[](https://www.npmjs.com/package/termux-tts)
|
|
6
|
+
[](https://github.com/uno-km/termux-tts)
|
|
7
|
+
|
|
8
|
+
> Production-Grade 4-Tier On-Device Speech Synthesis Framework (Multilingual Neural Orchestrator, Zero-Dependency DSP Formant & C++ Acceleration)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Architecture & Overview
|
|
13
|
+
|
|
14
|
+
Termux-TTS is an enterprise-grade, on-device text-to-speech framework optimized for mobile edge hardware and Android Termux environments. Built to eliminate heavy dependency stacks and fragile driver behaviors, it features a resilient 4-Tier architecture:
|
|
15
|
+
|
|
16
|
+
- **Multilingual Neural Orchestrator**: Dynamic cross-language code-switching mesh covering 9 official languages (Korean, English, Japanese, Chinese, Hindi, Russian, Spanish, French, German) with Unicode script tokenization and 50ms context-aware silence padding.
|
|
17
|
+
- **Resident C-API In-Memory Engine**: Direct C-API memory residency with `SherpaResidentManager` achieving sub-0.18x real-time factor with ARM NEON SIMD acceleration and zero subprocess lag.
|
|
18
|
+
- **Tier 1: Zero-Dependency Parametric DSP Formant Vocoder**: 0MB disk footprint, Rosenberg glottal pulse formulation, and 5-band biquad formant filters providing deterministic speech synthesis in under 50 milliseconds (RTF 0.013x).
|
|
19
|
+
- **Tier 2: Android System Native Voice Bridge**: Direct IPC integration to physical Samsung and Google speech engines via the Termux-API service layer.
|
|
20
|
+
- **Tier 3: Subprocess-Isolated Sherpa C++ CPU Engine**: Subprocess-isolated VITS acoustic modeling on ARM64 NEON with memory leak protection.
|
|
21
|
+
- **Tier 4: Pure Vulkan GPU Hardware Neural Engine**: High-performance GPU tensor synthesis via precompiled native C++ binaries (`sherpa-ncnn-offline-tts-vulkan`) running high-resolution studio models (`vits-piper-en_US-lessac-high-fp16`) with zero silent CPU fallback.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Empirical Hardware Benchmarks (Physical Devices)
|
|
26
|
+
|
|
27
|
+
Measurements gathered on physical Android 16 hardware running Termux ARM64:
|
|
28
|
+
|
|
29
|
+
| Target Device | Hardware Architecture | Synthesis Engine | Model Profile | Audio Length | Synthesis Time | Real-Time Factor (RTF) | Status |
|
|
30
|
+
| :--- | :--- | :--- | :--- | :--- | :---: | :---: | :---: |
|
|
31
|
+
| **Galaxy A53** | Exynos 1280 / ARM64 NEON | Multilingual Neural C-API | `KSS + Lessac` (Bilingual) | 10.50 s | **1.82 s** | **0.173x** | Validated (5.78x RT) |
|
|
32
|
+
| **Galaxy S25** | Snapdragon 8 Elite / Adreno 830 | Vulkan GPU Neural | `lessac-high-fp16` | 6.70 s | **6.65 s** | **0.993x** | Validated |
|
|
33
|
+
| **Galaxy S25** | Snapdragon 8 Elite / Adreno 830 | Vulkan GPU Neural | `lessac-medium` | 4.59 s | **1.21 s** | **0.264x** | Validated (3.79x RT) |
|
|
34
|
+
| **Galaxy A35** | Exynos 1380 / Mali-G68 MP5 | Vulkan GPU Neural | `lessac-medium` | 4.52 s | **5.18 s** | **1.146x** | Validated |
|
|
35
|
+
| **ARM64 CPU** | Cortex-A78 / A55 | Parametric DSP | 5-Band Biquad | 4.15 s | **0.054 s** | **0.0130x** | Validated (76x RT) |
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Installation & Automated Provisioning
|
|
40
|
+
|
|
41
|
+
### 1. Package Installation
|
|
42
|
+
```bash
|
|
43
|
+
# Python SDK & CLI
|
|
44
|
+
pip install termux-tts
|
|
45
|
+
|
|
46
|
+
# Node.js / TypeScript
|
|
47
|
+
npm install termux-tts
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 2. Automated Model Provisioning
|
|
51
|
+
Automate downloading and linking precompiled models to the official immutable path (`/data/data/com.termux/files/home/models/tts/`):
|
|
52
|
+
```bash
|
|
53
|
+
# Default lightweight installation (Korean KSS + English Lessac)
|
|
54
|
+
termux-tts install
|
|
55
|
+
|
|
56
|
+
# On-demand provision specific language models:
|
|
57
|
+
termux-tts install --models hi # Hindi (Piper Swara)
|
|
58
|
+
termux-tts install --models ja # Japanese (Piper Hina)
|
|
59
|
+
termux-tts install --models ru # Russian (Piper Dmitri)
|
|
60
|
+
termux-tts install --models zh # Chinese (AISHELL3)
|
|
61
|
+
termux-tts install --models all # All 9 official languages
|
|
62
|
+
|
|
63
|
+
# Provision Studio Vulkan GPU engine:
|
|
64
|
+
termux-tts install --tier high
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Quickstart
|
|
70
|
+
|
|
71
|
+
### Global Command-Line Interface (Zero-Config)
|
|
72
|
+
```bash
|
|
73
|
+
# 1. Zero-config synthesis with physical speaker playback
|
|
74
|
+
termux-tts "Hello 방가방가 나는 parrot 이라고 해." -o ~/out.wav --play
|
|
75
|
+
|
|
76
|
+
# 2. Flag-based syntax
|
|
77
|
+
termux-tts -t "Multilingual neural speech synthesis on device." --play
|
|
78
|
+
|
|
79
|
+
# 3. Force language pinning
|
|
80
|
+
termux-tts -l en -t "Pure English text output." --play
|
|
81
|
+
termux-tts -l ko -t "한국어 단독 신경망 음성 합성." --play
|
|
82
|
+
|
|
83
|
+
# 4. Instant DSP Formant synthesis (0MB footprint)
|
|
84
|
+
termux-tts synth -e dsp -t "Zero dependency DSP synthesis." -o dsp.wav
|
|
85
|
+
|
|
86
|
+
# 5. Direct Android system native speaker broadcast
|
|
87
|
+
termux-tts speak -t "Hardware speaker broadcast via Android service."
|
|
88
|
+
|
|
89
|
+
# 6. Hardware diagnostics
|
|
90
|
+
termux-tts doctor
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Python SDK
|
|
94
|
+
```python
|
|
95
|
+
import termux_tts as tts
|
|
96
|
+
|
|
97
|
+
# 1. Zero-Config Multilingual Neural Synthesis (Korean + English Code-Switching)
|
|
98
|
+
with tts.load() as engine:
|
|
99
|
+
result = engine.synthesize(
|
|
100
|
+
"Hello 방가방가 키키키키 나는 parrot 이라고 해.",
|
|
101
|
+
output="multilingual.wav"
|
|
102
|
+
)
|
|
103
|
+
print(f"Generated {result.duration_sec:.2f}s in {result.elapsed_ms:.1f}ms (RTF: {result.rtf:.4f}x)")
|
|
104
|
+
|
|
105
|
+
# 2. Pure Vulkan GPU Neural Synthesis (Studio Tier)
|
|
106
|
+
with tts.load(engine="vulkan", model_tier="high") as engine:
|
|
107
|
+
result = engine.synthesize("Pure Vulkan neural execution on mobile.", output="speech.wav")
|
|
108
|
+
print(f"Synthesized in {result.elapsed_ms:.1f}ms (RTF: {result.rtf:.4f}x)")
|
|
109
|
+
|
|
110
|
+
# 3. Zero-Dependency DSP Formant Synthesis
|
|
111
|
+
with tts.load(engine="dsp", preset="balanced") as engine:
|
|
112
|
+
result = engine.synthesize("Instant speech without model downloads.", output="dsp.wav")
|
|
113
|
+
print(f"DSP Latency: {result.elapsed_ms:.1f}ms")
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Node.js / TypeScript
|
|
117
|
+
```typescript
|
|
118
|
+
import * as tts from 'termux-tts';
|
|
119
|
+
|
|
120
|
+
async function main() {
|
|
121
|
+
const engine = tts.load({ engine: 'vulkan', tier: 'high' });
|
|
122
|
+
const res = await engine.synthesize("High performance speech synthesis.", { output: "speech.wav" });
|
|
123
|
+
console.log(`Synthesized in ${res.elapsedMs}ms`);
|
|
124
|
+
}
|
|
125
|
+
main();
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Official Documentation & Benchmarks
|
|
131
|
+
- [Official Architecture & API Reference](https://uno-km.vercel.app/lib/tts/)
|
|
132
|
+
- [Ecosystem Metrics & Registry Stats](https://uno-km.vercel.app/foundation/metrics)
|
|
133
|
+
- [AMEVA Open-Source Foundation Portal](https://uno-km.vercel.app/foundation/index.html)
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## License
|
|
138
|
+
Licensed under the Apache-2.0 License. Copyright (c) 2026 Eunho Kim ([@uno-km](https://github.com/uno-km)).
|