termux-stt 1.0.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.
- termux_stt-1.0.0/LICENSE +21 -0
- termux_stt-1.0.0/PKG-INFO +436 -0
- termux_stt-1.0.0/README.md +416 -0
- termux_stt-1.0.0/pyproject.toml +49 -0
- termux_stt-1.0.0/setup.cfg +4 -0
- termux_stt-1.0.0/setup.py +19 -0
- termux_stt-1.0.0/termux_stt/__init__.py +91 -0
- termux_stt-1.0.0/termux_stt/audio/__init__.py +4 -0
- termux_stt-1.0.0/termux_stt/audio/loader.py +83 -0
- termux_stt-1.0.0/termux_stt/audio/mic.py +41 -0
- termux_stt-1.0.0/termux_stt/audio/preprocessor.py +92 -0
- termux_stt-1.0.0/termux_stt/audio/vad.py +107 -0
- termux_stt-1.0.0/termux_stt/cli/__init__.py +4 -0
- termux_stt-1.0.0/termux_stt/cli/benchmark.py +46 -0
- termux_stt-1.0.0/termux_stt/cli/diarize.py +37 -0
- termux_stt-1.0.0/termux_stt/cli/doctor.py +71 -0
- termux_stt-1.0.0/termux_stt/cli/listen.py +30 -0
- termux_stt-1.0.0/termux_stt/cli/main.py +80 -0
- termux_stt-1.0.0/termux_stt/cli/models_cmd.py +21 -0
- termux_stt-1.0.0/termux_stt/cli/transcribe.py +55 -0
- termux_stt-1.0.0/termux_stt/diarization/__init__.py +5 -0
- termux_stt-1.0.0/termux_stt/diarization/clustering.py +109 -0
- termux_stt-1.0.0/termux_stt/diarization/mapper.py +50 -0
- termux_stt-1.0.0/termux_stt/diarization/xvector.py +26 -0
- termux_stt-1.0.0/termux_stt/engine/__init__.py +122 -0
- termux_stt-1.0.0/termux_stt/engine/base.py +154 -0
- termux_stt-1.0.0/termux_stt/engine/hybrid_engine.py +159 -0
- termux_stt-1.0.0/termux_stt/engine/sherpa_engine.py +218 -0
- termux_stt-1.0.0/termux_stt/engine/vosk_engine.py +274 -0
- termux_stt-1.0.0/termux_stt/engine/whisper_engine.py +330 -0
- termux_stt-1.0.0/termux_stt/export/__init__.py +6 -0
- termux_stt-1.0.0/termux_stt/export/json_export.py +22 -0
- termux_stt-1.0.0/termux_stt/export/result.py +61 -0
- termux_stt-1.0.0/termux_stt/export/rttm.py +20 -0
- termux_stt-1.0.0/termux_stt/export/srt.py +30 -0
- termux_stt-1.0.0/termux_stt/export/vtt.py +30 -0
- termux_stt-1.0.0/termux_stt/models/__init__.py +4 -0
- termux_stt-1.0.0/termux_stt/models/hub.py +126 -0
- termux_stt-1.0.0/termux_stt/models/quantization.py +39 -0
- termux_stt-1.0.0/termux_stt/models/registry.py +54 -0
- termux_stt-1.0.0/termux_stt/platform/__init__.py +4 -0
- termux_stt-1.0.0/termux_stt/platform/hardware.py +97 -0
- termux_stt-1.0.0/termux_stt/platform/installer.py +92 -0
- termux_stt-1.0.0/termux_stt/platform/mobile_guard.py +76 -0
- termux_stt-1.0.0/termux_stt/platform/process_pool.py +65 -0
- termux_stt-1.0.0/termux_stt.egg-info/PKG-INFO +436 -0
- termux_stt-1.0.0/termux_stt.egg-info/SOURCES.txt +58 -0
- termux_stt-1.0.0/termux_stt.egg-info/dependency_links.txt +1 -0
- termux_stt-1.0.0/termux_stt.egg-info/entry_points.txt +3 -0
- termux_stt-1.0.0/termux_stt.egg-info/requires.txt +5 -0
- termux_stt-1.0.0/termux_stt.egg-info/top_level.txt +1 -0
- termux_stt-1.0.0/tests/test_audio_preprocessor.py +8 -0
- termux_stt-1.0.0/tests/test_cli.py +8 -0
- termux_stt-1.0.0/tests/test_diarization.py +11 -0
- termux_stt-1.0.0/tests/test_export_formats.py +22 -0
- termux_stt-1.0.0/tests/test_hybrid_engine.py +5 -0
- termux_stt-1.0.0/tests/test_model_hub.py +8 -0
- termux_stt-1.0.0/tests/test_sherpa_engine.py +5 -0
- termux_stt-1.0.0/tests/test_vosk_engine.py +5 -0
- termux_stt-1.0.0/tests/test_whisper_engine.py +8 -0
termux_stt-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Eunho Kim (@uno-km)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: termux-stt
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Android on-device STT framework for Termux β whisper.cpp, vosk, sherpa-onnx unified
|
|
5
|
+
Author: Eunho Kim (@uno-km)
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/uno-km/termux-stt
|
|
8
|
+
Project-URL: Repository, https://github.com/uno-km/termux-stt
|
|
9
|
+
Project-URL: Documentation, https://github.com/uno-km/termux-stt#readme
|
|
10
|
+
Project-URL: Issues, https://github.com/uno-km/termux-stt/issues
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Provides-Extra: dev
|
|
15
|
+
Requires-Dist: pytest; extra == "dev"
|
|
16
|
+
Requires-Dist: ruff; extra == "dev"
|
|
17
|
+
Requires-Dist: mypy; extra == "dev"
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
Dynamic: requires-python
|
|
20
|
+
|
|
21
|
+
# Termux-STT
|
|
22
|
+
|
|
23
|
+
<div align="center">
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
ββββββββββββββββββββββββ ββββ βββββββ ββββββ βββ ββββββββββββββββββββββββββ
|
|
27
|
+
ββββββββββββββββββββββββββββββ ββββββββ βββββββββββ ββββββββββββββββββββββββββ
|
|
28
|
+
βββ ββββββ ββββββββββββββββββββββ βββ ββββββ ββββββββββββββ βββ βββ
|
|
29
|
+
βββ ββββββ ββββββββββββββββββββββ βββ ββββββ ββββββββββββββ βββ βββ
|
|
30
|
+
βββ βββββββββββ ββββββ βββ ββββββββββββββββ βββ ββββββββ βββ βββ
|
|
31
|
+
βββ βββββββββββ ββββββ βββ βββββββ βββ βββ ββββββββ βββ βββ
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Production-Grade On-Device Speech-to-Text & Speaker Diarization Framework for Android Termux**
|
|
35
|
+
*Dual-Engine Architecture (Python & Node.js / TypeScript) with Native Bionic ARM64 Acceleration & 0 PyTorch Dependency*
|
|
36
|
+
|
|
37
|
+
<p align="center">
|
|
38
|
+
<a href="https://pypi.org/project/termux-stt/"><img src="https://img.shields.io/pypi/v/termux-stt.svg?color=blue&style=for-the-badge&logo=pypi&logoColor=white" alt="PyPI Version" /></a>
|
|
39
|
+
<a href="https://www.npmjs.com/package/termux-stt"><img src="https://img.shields.io/npm/v/termux-stt.svg?color=red&style=for-the-badge&logo=npm&logoColor=white" alt="npm Version" /></a>
|
|
40
|
+
<a href="https://uno-km.github.io/termux-stt/showcase.html"><img src="https://img.shields.io/badge/Live_Showcase-βΆ_Audio_Player-00f5d4?style=for-the-badge&logo=googlechrome&logoColor=0b132b" alt="Live Audio Showcase" /></a>
|
|
41
|
+
<a href="https://uno-km.github.io/termux-stt/"><img src="https://img.shields.io/badge/Docs-uno--km.github.io-004499?style=for-the-badge&logo=googlechrome&logoColor=white" alt="Live Docs" /></a>
|
|
42
|
+
<a href="https://github.com/uno-km/termux-stt/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-MIT-green.svg?style=for-the-badge" alt="License" /></a>
|
|
43
|
+
</p>
|
|
44
|
+
|
|
45
|
+
<p align="center">
|
|
46
|
+
<img src="https://img.shields.io/badge/Platform-Android%20Termux%20(ARM64%2Faarch64)-00887A?style=flat-square&logo=android&logoColor=white" alt="Platform" />
|
|
47
|
+
<img src="https://img.shields.io/badge/Engines-whisper.cpp%20%7C%20Vosk%20%7C%20Sherpa--ONNX-38bdf8?style=flat-square" alt="Engines" />
|
|
48
|
+
<img src="https://img.shields.io/badge/Diarization-128d%20X--Vector%20+%20Pure%20Python-a855f7?style=flat-square" alt="Diarization" />
|
|
49
|
+
<img src="https://img.shields.io/badge/RAM-Under%20350MB%20(Tiny%2FBase)-10b981?style=flat-square&logo=shield&logoColor=white" alt="RAM" />
|
|
50
|
+
<img src="https://img.shields.io/badge/Python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-f59e0b?style=flat-square&logo=python&logoColor=white" alt="Python" />
|
|
51
|
+
<img src="https://img.shields.io/badge/Node.js-16%20%7C%2018%20%7C%2020%20%7C%2022-3178c6?style=flat-square&logo=nodedotjs&logoColor=white" alt="Node" />
|
|
52
|
+
</p>
|
|
53
|
+
|
|
54
|
+
<br/>
|
|
55
|
+
|
|
56
|
+
**[π§ Live Audio Showcase & Demo](https://uno-km.github.io/termux-stt/showcase.html)** β’ **[π Official Documentation Site](https://uno-km.github.io/termux-stt/)** β’ **[β‘ Quickstart](#1-quick-scenario-playbook)** β’ **[ποΈ Architecture](#2-why-termux-stt-architectural-pillars)** β’ **[π Benchmarks](#3-empirical-benchmarks-galaxy-a35--exynos-1380)** β’ **[π 15-Part Blog Series](#7-15-part-empirical-research-blog-series)**
|
|
57
|
+
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## ποΈ λ¨ 3μ€λ‘ λλ΄λ μλλ‘μ΄λ Termux μ¨λλ°μ΄μ€ μμ±μΈμ
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from termux_stt import create_engine
|
|
66
|
+
|
|
67
|
+
# 1. μμ§ μ΄κΈ°ν (μ΅μ΄ 1ν λͺ¨λΈ μλ λ€μ΄λ‘λ λ° μΊμ±)
|
|
68
|
+
engine = create_engine("whisper", model="base", lang="en")
|
|
69
|
+
|
|
70
|
+
# 2. μ€λμ€ μ μ¬ λ° μλ§ μμ± (WAV, MP3, M4A, FLAC, OGG μλ 16kHz λ³ν)
|
|
71
|
+
result = engine.transcribe("speech.mp3")
|
|
72
|
+
|
|
73
|
+
print(result.text) # μ 체 ν
μ€νΈ
|
|
74
|
+
print(result.to_srt()) # νμ€ SRT μλ§
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# λλ ν°λ―Έλμμ 1μ€ CLI μ€ν
|
|
79
|
+
termux-stt transcribe --engine whisper --model base speech.mp3
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## π§ Live Audio Showcase & On-Device Transcription Proof
|
|
85
|
+
|
|
86
|
+
> **[βΆ μΉ λΈλΌμ°μ μμ μ€μκ° μμ± λ° λκΈ°ν μλ§ μ²΄ννκΈ° (Live Audio Showcase)](https://uno-km.github.io/termux-stt/showcase.html)**
|
|
87
|
+
|
|
88
|
+
### 1. μ€μΈ‘ μ€λμ€ μ€ν & μ μ¬ νμλΌμΈ
|
|
89
|
+
|
|
90
|
+
* **μ
λ ₯ μ€λμ€**: `continuous_speech.wav` (37.91μ΄, 16000Hz Mono PCM)
|
|
91
|
+
* **μΆλ‘ μμ§**: `whisper.cpp Base` (On-Device Local CPU)
|
|
92
|
+
* **μ²λ¦¬ μκ°**: **32.79μ΄** (RTF: **0.865x**, μ€μκ°λ³΄λ€ λΉ λ¦)
|
|
93
|
+
* **λ¬Έμ₯ λ°λ³΅λ₯ **: **0%** (λͺ¨λ λ°ν ꡬκ°μ΄ κ°κΈ° λ€λ₯Έ λ΄μ©μΌλ‘ κ³ μ νκ² μ μ¬λ¨)
|
|
94
|
+
|
|
95
|
+
| No. | νμμ€ν¬ν (μμ β μ’
λ£) | μ μ¬λ λ¬Έμ₯ (Transcribed Text) |
|
|
96
|
+
| :---: | :---: | :--- |
|
|
97
|
+
| **01** | `00:00.00 β 00:09.36` | *"And so my fellow Americans, ask not what your country can do for you, ask what you can"* |
|
|
98
|
+
| **02** | `00:09.36 β 00:11.60` | *"do for your country."* |
|
|
99
|
+
| **03** | `00:11.60 β 00:16.18` | *He hoped there would be stew for dinner, turnips and carrots and bruised potatoes and* |
|
|
100
|
+
| **04** | `00:16.18 β 00:22.00` | *fat mutton pieces to be ladled out in thick, peppered flour-fatten sauce.* |
|
|
101
|
+
| **05** | `00:22.00 β 00:25.36` | *Stuff it into you, his belly counseled him.* |
|
|
102
|
+
| **06** | `00:25.36 β 00:29.88` | *After early nightfall, the yellow lamps would light up here and there, the squalid quarter* |
|
|
103
|
+
| **07** | `00:29.88 β 00:37.14` | *of the brothels.* |
|
|
104
|
+
|
|
105
|
+
### 2. μλ μμ±λ SRT μλ§ νμΌ
|
|
106
|
+
|
|
107
|
+
```srt
|
|
108
|
+
1
|
|
109
|
+
00:00:00,000 --> 00:00:09,360
|
|
110
|
+
"And so my fellow Americans, ask not what your country can do for you, ask what you can
|
|
111
|
+
|
|
112
|
+
2
|
|
113
|
+
00:00:09,360 --> 00:00:11,600
|
|
114
|
+
do for your country."
|
|
115
|
+
|
|
116
|
+
3
|
|
117
|
+
00:00:11,600 --> 00:00:16,180
|
|
118
|
+
He hoped there would be stew for dinner, turnips and carrots and bruised potatoes and
|
|
119
|
+
|
|
120
|
+
4
|
|
121
|
+
00:00:16,180 --> 00:00:22,000
|
|
122
|
+
fat mutton pieces to be ladled out in thick, peppered flour-fatten sauce.
|
|
123
|
+
|
|
124
|
+
5
|
|
125
|
+
00:00:22,000 --> 00:00:25,360
|
|
126
|
+
Stuff it into you, his belly counseled him.
|
|
127
|
+
|
|
128
|
+
6
|
|
129
|
+
00:00:25,360 --> 00:00:29,880
|
|
130
|
+
After early nightfall, the yellow lamps would light up here and there, the squalid quarter
|
|
131
|
+
|
|
132
|
+
7
|
|
133
|
+
00:00:29,880 --> 00:00:37,140
|
|
134
|
+
of the brothels.
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## π‘ What is termux-stt?
|
|
140
|
+
|
|
141
|
+
`termux-stt` is an all-in-one, production-ready speech-to-text and speaker diarization framework engineered natively for **Android Termux (ARM64 / aarch64)**.
|
|
142
|
+
|
|
143
|
+
Standard mobile STT setups force developers to endure 30+ minutes of manual CMake builds, broken PyPI wheels on Android Bionic, 2GB+ PyTorch binaries that trigger Android Low Memory Killer (OOM), and broken platform guards.
|
|
144
|
+
|
|
145
|
+
**`termux-stt` eliminates all friction with a 3-line unified API:**
|
|
146
|
+
- **Zero-PyTorch Dependency**: Replaces heavy ML frameworks with C++ binary subprocess isolation and Pure Python clustering math.
|
|
147
|
+
- **Multi-Engine Unification**: Run `whisper.cpp`, `Vosk`, or `Sherpa-ONNX` via the exact same `create_engine()` interface.
|
|
148
|
+
- **Built-in Hybrid Diarization**: Combines Vosk 128d X-Vector voice fingerprints with Whisper STT under 1.5 GB RAM.
|
|
149
|
+
- **Empirically Proven**: Engineered from 15 comprehensive benchmarks on Samsung Galaxy A35 (Exynos 1380, 6GB RAM).
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## 1. Quick Scenario Playbook
|
|
154
|
+
|
|
155
|
+
### [Install] Scenario 1: Clean Install (Fresh Setup on Android Termux)
|
|
156
|
+
|
|
157
|
+
#### [Python] Python (`pip`):
|
|
158
|
+
```bash
|
|
159
|
+
# 1. Grant Storage & Microphone Permissions in Termux
|
|
160
|
+
termux-setup-storage
|
|
161
|
+
|
|
162
|
+
# 2. Install Dependencies & Provision Native Engines
|
|
163
|
+
pkg update -y && pkg install python clang make cmake git ffmpeg termux-api -y
|
|
164
|
+
pip install termux-stt && termux-stt-install
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
#### [Node.js] Node.js / TypeScript (`npm`):
|
|
168
|
+
```bash
|
|
169
|
+
# 1. Grant Storage & Microphone Permissions
|
|
170
|
+
termux-setup-storage
|
|
171
|
+
|
|
172
|
+
# 2. Install Dependencies & Provision Native Engines
|
|
173
|
+
pkg update -y && pkg install nodejs-lts clang make cmake git ffmpeg termux-api -y
|
|
174
|
+
npm install -g termux-stt && npx termux-stt install
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
### [Instant] Scenario 2: Instant Transcription (Ready to Run)
|
|
180
|
+
|
|
181
|
+
#### Option A: One-Line CLI
|
|
182
|
+
```bash
|
|
183
|
+
# Transcribe audio file with default Whisper engine (Korean)
|
|
184
|
+
termux-stt transcribe meeting.wav
|
|
185
|
+
|
|
186
|
+
# Export directly to Subtitles (SRT or VTT)
|
|
187
|
+
termux-stt transcribe --format srt meeting.wav > subtitles.srt
|
|
188
|
+
|
|
189
|
+
# Use ultra-fast Vosk engine
|
|
190
|
+
termux-stt transcribe --engine vosk --model small-ko voice_memo.wav
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
#### Option B: Python SDK Integration
|
|
194
|
+
```python
|
|
195
|
+
from termux_stt import create_engine
|
|
196
|
+
|
|
197
|
+
# 1. Initialize Engine (auto-downloads model on first call)
|
|
198
|
+
engine = create_engine("whisper", model="base", lang="ko")
|
|
199
|
+
|
|
200
|
+
# 2. Transcribe Audio
|
|
201
|
+
result = engine.transcribe("meeting.wav")
|
|
202
|
+
|
|
203
|
+
print("Transcript:", result.text)
|
|
204
|
+
print("Detected Language:", result.language)
|
|
205
|
+
print("Duration:", f"{result.duration:.2f}s")
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
#### Option C: Node.js / TypeScript Integration
|
|
209
|
+
```javascript
|
|
210
|
+
const { createEngine } = require("termux-stt");
|
|
211
|
+
|
|
212
|
+
async function main() {
|
|
213
|
+
const engine = createEngine("whisper", { model: "base", lang: "ko" });
|
|
214
|
+
const result = await engine.transcribe("meeting.wav");
|
|
215
|
+
|
|
216
|
+
console.log("Transcript:", result.text);
|
|
217
|
+
console.log("SRT Subtitles:\n", result.toSrt());
|
|
218
|
+
}
|
|
219
|
+
main();
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
### [Streaming] Scenario 3: Real-Time Microphone Streaming
|
|
225
|
+
|
|
226
|
+
Speak into your smartphone microphone and receive real-time transcribed text with sub-second latency:
|
|
227
|
+
|
|
228
|
+
```python
|
|
229
|
+
from termux_stt import create_engine
|
|
230
|
+
|
|
231
|
+
# Use ultra-lightweight Tiny model (RTF 0.80 on Exynos 1380)
|
|
232
|
+
engine = create_engine("whisper", model="tiny", lang="ko")
|
|
233
|
+
|
|
234
|
+
print("ποΈ Listening... Speak into your phone microphone (Ctrl+C to stop)")
|
|
235
|
+
for segment in engine.stream_mic():
|
|
236
|
+
print(f"[{segment.start:.1f}s -> {segment.end:.1f}s] {segment.text}")
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
### [Diarize] Scenario 4: Hybrid Speaker Diarization ("Who Spoke When?")
|
|
242
|
+
|
|
243
|
+
Run high-precision speaker diarization without PyTorch or CUDA:
|
|
244
|
+
|
|
245
|
+
```python
|
|
246
|
+
from termux_stt import create_engine
|
|
247
|
+
|
|
248
|
+
# Hybrid Pipeline: Vosk 128d X-Vector + Whisper STT + Pure Python K-Means
|
|
249
|
+
engine = create_engine("hybrid", lang="ko", num_speakers=2)
|
|
250
|
+
result = engine.diarize("interview.wav")
|
|
251
|
+
|
|
252
|
+
for seg in result.segments:
|
|
253
|
+
print(f"[{seg.speaker}] ({seg.start:.1f}s - {seg.end:.1f}s): {seg.text}")
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
*Output Example:*
|
|
257
|
+
```text
|
|
258
|
+
[Speaker_0] (0.0s - 3.5s): μ€λ κ²½μ λΈλ¦¬νμ μμνκ² μ΅λλ€.
|
|
259
|
+
[Speaker_1] (3.8s - 7.2s): λ€, μ€λ μ½μ€νΌ μ§μκ° μΈκ΅μΈ μλ§€μλ‘ μμΉ λ§κ°νμ΅λλ€.
|
|
260
|
+
[Speaker_0] (7.5s - 10.1s): λ°λ체 μΉν° λν₯μ μ΄λ€κ°μ?
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## 2. ποΈ Why termux-stt? Architectural Pillars
|
|
266
|
+
|
|
267
|
+
```
|
|
268
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
269
|
+
β termux-stt Architecture β
|
|
270
|
+
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββ€
|
|
271
|
+
β User Interface Layer β Engine Abstraction β Output / Export Layer β
|
|
272
|
+
β β’ Python API β β’ EngineRegistry β β’ JSON / SRT / VTT β
|
|
273
|
+
β β’ Node.js API β β’ create_engine() β β’ RTTM (Diarization) β
|
|
274
|
+
β β’ CLI (termux-stt) β β’ ModelHub & Cache β β’ Streaming Callback β
|
|
275
|
+
ββββββββββββββββββββββββββΌβββββββββββββββββββββββββΌββββββββββββββββββββββββββββ€
|
|
276
|
+
β Core Pipeline Layer β
|
|
277
|
+
β Audio Loader (7 Formats) β Preprocessor (16kHz Mono) β Silero-VAD Filter β
|
|
278
|
+
β β Multi-Engine STT (whisper.cpp / Vosk / Sherpa-ONNX) β
|
|
279
|
+
β β Hybrid Diarizer (128d X-Vector β Pure Python Cosine/K-Means β Time Align)β
|
|
280
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
|
|
281
|
+
β Platform & Process Isolation β
|
|
282
|
+
β β’ Subprocess Isolation (Host Python never crashes on C++ Segfault) β
|
|
283
|
+
β β’ MobileGuard (WakeLock, Doze Mode Bypass, Phantom Process Killer Shield) β
|
|
284
|
+
β β’ Bionic ARM64 NEON & FP16 SIMD Acceleration β
|
|
285
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
1. **Subprocess Isolation**: C++ inference runs in isolated native subprocesses. Memory errors or Segfaults never kill the host Python/Node.js application.
|
|
289
|
+
2. **Pure Python Clustering**: Cosine distance matrix and K-Means clustering are implemented with 0 external dependencies (`numpy` / `scikit-learn` optional, not required).
|
|
290
|
+
3. **Automated Android Bionic Fixes**: Solves `sys.platform = 'linux'` spoofing, libvosk CFFI extraction, and ffmpeg audio format normalization (`16kHz / 1ch / PCM s16le`) under the hood.
|
|
291
|
+
4. **Mobile Battery & CPU Guard**: Manages Android WakeLocks and background task states to prevent process termination when the screen locks.
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## 3. π Empirical Benchmarks (Galaxy A35 / Exynos 1380)
|
|
296
|
+
|
|
297
|
+
> *Measured on Samsung Galaxy A35 5G (Exynos 1380 4x A78 + 4x A55, 6GB RAM, Android 14 Termux).*
|
|
298
|
+
|
|
299
|
+
| Engine / Pipeline | Model | Peak RAM | RTF (Speed) | KO Accuracy | Diarization Support | Termux Rating |
|
|
300
|
+
| :--- | :--- | :---: | :---: | :---: | :---: | :---: |
|
|
301
|
+
| **whisper.cpp** | `ggml-tiny` (39M) | **~150 MB** | **0.80** | 85% | β External | βββββ |
|
|
302
|
+
| **whisper.cpp** | `ggml-base` (74M) | ~250 MB | 1.20 | 88% | β External | ββββ |
|
|
303
|
+
| **whisper.cpp** | `ggml-medium` (769M) | ~1.5 GB | 3.40 | **95%+** | β External | βββ (Golden Acc) |
|
|
304
|
+
| **Vosk** | `small-ko-0.22` (42M) | **~100 MB** | **0.25** | 78% | β
128d X-Vector | βββ |
|
|
305
|
+
| **Sherpa-ONNX** | `Zipformer` | ~300 MB | **0.42** | 86% | β
CAM++ | ββββ |
|
|
306
|
+
| **Pyannote.audio 3.1** | `diarization-3.1` | **> 3.5 GB** | 2.80~3.50 | N/A | β
Gold Standard | β OOM Crashes |
|
|
307
|
+
| **termux-stt (Hybrid)** | `Vosk + Whisper Base`| **~350 MB** | **1.45** | **92%+** | **β
Built-in K-Means** | **βββββ (Recommended)** |
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## 4. βοΈ Engine Comparison Matrix
|
|
312
|
+
|
|
313
|
+
| Feature | `whisper.cpp` | `Vosk` | `Sherpa-ONNX` | `Hybrid (Vosk+Whisper)` |
|
|
314
|
+
| :--- | :---: | :---: | :---: | :---: |
|
|
315
|
+
| **Primary Strength** | Highest Text Accuracy | Ultra-Low RAM & Fast | Ultra-Low Latency | **STT + Diarization Combined** |
|
|
316
|
+
| **Memory Footprint** | 150MB ~ 1.5GB | **< 100MB** | 300MB ~ 500MB | **~ 350MB** |
|
|
317
|
+
| **Real-Time Factor (RTF)** | 0.80 (Tiny) | **0.25 (Blazing)** | **0.42 (Fast)** | 1.45 (Full Pipeline) |
|
|
318
|
+
| **Speaker Diarization** | β None | β οΈ Basic X-Vector | β οΈ CAM++ C++ | **β
High-Precision Aligned** |
|
|
319
|
+
| **Recommended Use Case** | Quality Transcripts | Embedded / Low Spec | Live Voice Assistant | **Meetings / Interviews** |
|
|
320
|
+
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
## 5. π Complete API Reference Summary
|
|
324
|
+
|
|
325
|
+
### Python API
|
|
326
|
+
|
|
327
|
+
```python
|
|
328
|
+
import termux_stt
|
|
329
|
+
|
|
330
|
+
# Create Engine
|
|
331
|
+
engine = termux_stt.create_engine(
|
|
332
|
+
engine="whisper", # "whisper" | "vosk" | "sherpa" | "hybrid"
|
|
333
|
+
model="base", # "tiny" | "base" | "small" | "medium" | "custom"
|
|
334
|
+
lang="ko", # ISO 639-1 language code
|
|
335
|
+
num_speakers=0, # 0 = disabled, 2+ = enable diarization
|
|
336
|
+
threads=4, # CPU threads (defaults to big cores count)
|
|
337
|
+
vad=True, # Enable Silero-VAD silence stripping
|
|
338
|
+
quantization="q5_1" # "f16" | "q8_0" | "q5_1" | "q4_0"
|
|
339
|
+
)
|
|
340
|
+
|
|
341
|
+
# Transcribe File
|
|
342
|
+
result = engine.transcribe("audio.wav")
|
|
343
|
+
# Returns: TranscriptResult(text=str, segments=List[Segment], language=str, duration=float)
|
|
344
|
+
|
|
345
|
+
# Export Methods
|
|
346
|
+
result.to_json() # Structured JSON string
|
|
347
|
+
result.to_srt() # Standard SRT subtitle format
|
|
348
|
+
result.to_vtt() # WebVTT subtitle format
|
|
349
|
+
result.to_rttm() # NIST RTTM diarization format
|
|
350
|
+
|
|
351
|
+
# Stream Microphone
|
|
352
|
+
for seg in engine.stream_mic(duration=30.0):
|
|
353
|
+
print(f"[{seg.speaker}] {seg.text}")
|
|
354
|
+
|
|
355
|
+
# Speaker Diarization
|
|
356
|
+
diar_result = engine.diarize("meeting.wav", num_speakers=2)
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### CLI Reference
|
|
360
|
+
|
|
361
|
+
```bash
|
|
362
|
+
# General Syntax
|
|
363
|
+
termux-stt [COMMAND] [OPTIONS] [FILE]
|
|
364
|
+
|
|
365
|
+
# Commands
|
|
366
|
+
termux-stt transcribe [FILE] # Transcribe audio file
|
|
367
|
+
termux-stt listen # Real-time microphone transcription
|
|
368
|
+
termux-stt diarize [FILE] # Perform speaker diarization
|
|
369
|
+
termux-stt models list # List installed and available models
|
|
370
|
+
termux-stt models download [M] # Download specific model
|
|
371
|
+
termux-stt doctor # Run hardware and environment diagnostics
|
|
372
|
+
termux-stt benchmark # Run performance benchmark suite
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
## 6. π οΈ Troubleshooting & Android FAQs
|
|
378
|
+
|
|
379
|
+
### Q1: `pip install vosk` fails with CMake or wheel error on Android
|
|
380
|
+
* **Cause**: Vosk does not publish official prebuilt aarch64-android wheels on PyPI.
|
|
381
|
+
* **Solution**: `termux-stt-install` automatically extracts `libvosk.so` from the official Android AAR and generates the CFFI bindings.
|
|
382
|
+
|
|
383
|
+
### Q2: Whisper crashes on 44.1kHz stereo MP3/M4A files
|
|
384
|
+
* **Cause**: Whisper models strictly require single-channel 16,000Hz 16-bit PCM WAV.
|
|
385
|
+
* **Solution**: `termux-stt` automatically runs `ffmpeg` normalization on any audio format (`mp3`, `m4a`, `flac`, `ogg`, `opus`, `webm`).
|
|
386
|
+
|
|
387
|
+
### Q3: Process killed after 10 minutes in background
|
|
388
|
+
* **Cause**: Android Phantom Process Killer terminates background tasks.
|
|
389
|
+
* **Solution**: Enable Termux WakeLock (`termux-wake-lock`) and disable battery optimization for Termux in Android Settings.
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
## 7. π 15-Part Empirical Research Blog Series
|
|
394
|
+
|
|
395
|
+
This framework is built upon the exhaustive 15-part research series published on [Eunho Kim's Technical Blog (μ°λ
Έν΄ ν°μ€ν 리)](https://uno-kim.tistory.com/):
|
|
396
|
+
|
|
397
|
+
1. [[Whisper.cpp] #1. Edge Agent AI: Whisper.cpp Speech Processing (Base vs Tiny)](https://uno-kim.tistory.com/467)
|
|
398
|
+
2. [[Audio Extraction] #2. Extracting Specific Audio Segments on Android](https://uno-kim.tistory.com/468)
|
|
399
|
+
3. [[Whisper.cpp] #3. Korean STT Conversion Comparison (4 Models)](https://uno-kim.tistory.com/469)
|
|
400
|
+
4. [[Comparison-1] #4. STT + Speaker Diarization: 3 Lightweight Engines + Pyannote](https://uno-kim.tistory.com/472)
|
|
401
|
+
5. [[Comparison-2] #5. Sherpa-ONNX Execution, Diarization, and Troubleshooting](https://uno-kim.tistory.com/473)
|
|
402
|
+
6. [[Comparison-3] #6. Speaker Diarization using Pyannote Model](https://uno-kim.tistory.com/471)
|
|
403
|
+
7. [[Pyannote] Troubleshooting Diarization in Mobile/Termux/ARM Environments](https://uno-kim.tistory.com/470)
|
|
404
|
+
8. [[Comparison-4] #7. Vosk Execution, Speaker Diarization, and Troubleshooting](https://uno-kim.tistory.com/475)
|
|
405
|
+
9. [[Vosk] Troubleshooting Vosk in Mobile/Termux/ARM Environments](https://uno-kim.tistory.com/474)
|
|
406
|
+
10. [[Comparison-5] #8. Vosk / Pyannote / Sherpa-ONNX / Whisper.cpp Comprehensive Comparison](https://uno-kim.tistory.com/476)
|
|
407
|
+
11. [[Comparison-6] #9. Vosk + Whisper.cpp Hybrid Pipeline & X-Vector Diarization](https://uno-kim.tistory.com/477)
|
|
408
|
+
12. [[Development-1] #10. Large-Scale Batch Automation & Task Management Architecture](https://uno-kim.tistory.com/478)
|
|
409
|
+
13. [[Comparison-7] #11. STT + Diarization Final: Small vs Turbo & Optimization Magic (4-Model Benchmark)](https://uno-kim.tistory.com/479)
|
|
410
|
+
14. [[Development-2] #12. Domain-Specific STT Training: Whisper Tiny Fine-Tuning on CPU](https://uno-kim.tistory.com/480)
|
|
411
|
+
15. [[Comparison-8] #13. Vanilla Model vs Custom Fine-Tuned Model (Economics/News Domain)](https://uno-kim.tistory.com/481)
|
|
412
|
+
|
|
413
|
+
---
|
|
414
|
+
|
|
415
|
+
## π The AMEVA Mobile AI & Automation Ecosystem
|
|
416
|
+
|
|
417
|
+
* **π¨ [Termux-Diffusion](https://github.com/uno-km/termux-diffusion)** ([PyPI](https://pypi.org/project/termux-diffusion/) | [npm](https://www.npmjs.com/package/termux-diffusion) | [Docs](https://uno-km.github.io/termux-diffusion/)): Production on-device Stable Diffusion image generation for Android Termux.
|
|
418
|
+
* **π [Termux-Playwright](https://github.com/uno-km/termux-playwright-demo)** ([PyPI](https://pypi.org/project/termux-playwright/) | [npm](https://www.npmjs.com/package/termux-playwright) | [Docs](https://uno-km.github.io/termux-playwright-demo/)): Production headless Chromium browser automation & scraping for Android Termux.
|
|
419
|
+
* **π§ [termux-train](https://github.com/uno-km/termux-train)**: On-device Autograd deep learning training & LoRA fine-tuning for Android Termux.
|
|
420
|
+
* **π₯οΈ [AMEVA Workstation Web](https://github.com/uno-km/AMEVA-Workstation-Web)** ([Live Demo](https://ameva-workstation-web-core.vercel.app/)): 100% on-device WebGPU AI workspace & multimedia document intelligence.
|
|
421
|
+
* **β‘ [AMEVA-Forge](https://github.com/uno-km/ameva-forge)** ([Docs](https://uno-km.github.io/ameva-forge/)): Real-time WebGPU 3D neural studio & visualization engine.
|
|
422
|
+
|
|
423
|
+
---
|
|
424
|
+
|
|
425
|
+
## βοΈ Disclaimer (λ©΄μ±
μ‘°ν)
|
|
426
|
+
|
|
427
|
+
> **Disclaimer:**
|
|
428
|
+
> *termux-stt is an independent open-source project developed for the Android Termux environment and is not officially affiliated with, endorsed by, or sponsored by the Termux project, OpenAI, or any other third party.*
|
|
429
|
+
>
|
|
430
|
+
> *(λ³Έ νλ‘μ νΈλ μλλ‘μ΄λ Termux νκ²½μ μν΄ κ°λ°λ λ
립μ μΈ μ€νμμ€ λΌμ΄λΈλ¬λ¦¬μ΄λ©°, Termux 곡μ νλ‘μ νΈ, OpenAI λ° κΈ°ν μ 3μμ μ§μ μ μΈ μ ν΄ κ΄κ³κ° μλλλ€.)*
|
|
431
|
+
|
|
432
|
+
---
|
|
433
|
+
|
|
434
|
+
## π License
|
|
435
|
+
|
|
436
|
+
Released under the **MIT License**. Maintained by **uno-km (μ©μ΄λ³΄μ½λ©λ¨) / Eunho Kim**.
|