pi-voicekit 0.1.0

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 (34) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +341 -0
  3. package/extensions/voice/config.ts +395 -0
  4. package/extensions/voice/deepgram.ts +33 -0
  5. package/extensions/voice/device.ts +382 -0
  6. package/extensions/voice/hold-to-talk.ts +69 -0
  7. package/extensions/voice/local.ts +1143 -0
  8. package/extensions/voice/model-download.ts +636 -0
  9. package/extensions/voice/onboarding.ts +739 -0
  10. package/extensions/voice/release-controller.ts +55 -0
  11. package/extensions/voice/settings-panel.ts +1602 -0
  12. package/extensions/voice/sherpa-engine.ts +464 -0
  13. package/extensions/voice/sherpa-loader.ts +143 -0
  14. package/extensions/voice/sherpa-onnx-node.d.ts +4 -0
  15. package/extensions/voice/speak.ts +430 -0
  16. package/extensions/voice/tts-deepgram.ts +454 -0
  17. package/extensions/voice/tts-engine.ts +653 -0
  18. package/extensions/voice/tts-install-progress.ts +257 -0
  19. package/extensions/voice/tts-local-models.ts +1255 -0
  20. package/extensions/voice/tts-onboarding-overlay.ts +186 -0
  21. package/extensions/voice/tts-onboarding.ts +87 -0
  22. package/extensions/voice/tts-playback-indicator.ts +127 -0
  23. package/extensions/voice/tts-playback.ts +675 -0
  24. package/extensions/voice/tts-text-filter.ts +404 -0
  25. package/extensions/voice/ui-aura.ts +272 -0
  26. package/extensions/voice/ui-help-overlay.ts +161 -0
  27. package/extensions/voice/ui-icons.ts +124 -0
  28. package/extensions/voice/ui-locale-labels.ts +110 -0
  29. package/extensions/voice/ui-picker.ts +209 -0
  30. package/extensions/voice/ui-render-ticker.ts +171 -0
  31. package/extensions/voice/ui-widget-base.ts +219 -0
  32. package/extensions/voice/ui-width.ts +112 -0
  33. package/extensions/voice.ts +3644 -0
  34. package/package.json +75 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 codexstar69
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.
package/README.md ADDED
@@ -0,0 +1,341 @@
1
+ [English](README.md) | [简体中文](i18n/README.zh-CN.md) | [日本語](i18n/README.ja.md) | [한국어](i18n/README.ko.md) | [Español](i18n/README.es.md) | [Français](i18n/README.fr.md) | [Português](i18n/README.pt-BR.md) | [हिन्दी](i18n/README.hi.md)
2
+
3
+ # pi-voicekit
4
+
5
+ > **Community continuation of [`codexstar69/pi-listen`](https://github.com/codexstar69/pi-listen)** (archived upstream, MIT).
6
+ > Not affiliated with the original author. Old name: `pi-listen`.
7
+
8
+ <p align="center">
9
+ <img src="https://raw.githubusercontent.com/CyFeng16/pi-voicekit/main/assets/banner.png" alt="pi-listen — Voice input for the Pi coding agent" width="100%" />
10
+ </p>
11
+
12
+ **Hold-to-talk voice input for [Pi](https://github.com/earendil-works/pi-coding-agent).** Cloud streaming via Deepgram or fully offline with local models.
13
+
14
+ [![npm version](https://img.shields.io/npm/v/pi-voicekit.svg)](https://www.npmjs.com/package/pi-voicekit)
15
+ [![license](https://img.shields.io/npm/l/pi-voicekit.svg)](https://github.com/CyFeng16/pi-voicekit/blob/main/LICENSE)
16
+ [![original author](https://img.shields.io/badge/original_author-@baanditeagle-1DA1F2?logo=x&logoColor=white)](https://x.com/baanditeagle)
17
+
18
+ > **v7.0.0 — World-class TTS UX** — pick models from `/voice-settings` Speak
19
+ > tab (no more JSON editing), auto-download on selection with progress, voice
20
+ > picker for every backend, first-run onboarding with smart-default
21
+ > recommendation by your system locale, and `ttsAutoSpeak: true` finally
22
+ > works — auto-speaks the agent's responses with code-block stripping and
23
+ > rate limiting. Diagnostic command `/voice-speak-info` shows everything.
24
+ > Resume-on-interrupt downloads. Plus all v6 features (14 local models from
25
+ > 25 MB Kitten Nano up, Deepgram Aura cloud, region-strict language matching,
26
+ > sentence-aware chunking). [Full changelog →](CHANGELOG.md)
27
+
28
+ ---
29
+
30
+ ## See How It Works
31
+
32
+ <p align="center">
33
+ <a href="https://github.com/CyFeng16/pi-voicekit/blob/main/assets/pi-listen.mp4">
34
+ <img src="https://raw.githubusercontent.com/CyFeng16/pi-voicekit/main/assets/banner.png" alt="Watch demo video" width="600" />
35
+ </a>
36
+ <br>
37
+ <em>Click to watch the demo video</em>
38
+ </p>
39
+
40
+ ---
41
+
42
+ ## Setup (2 minutes)
43
+
44
+ ### 1. Install the extension
45
+
46
+ ```bash
47
+ # In a regular terminal (not inside Pi)
48
+ pi install npm:pi-voicekit
49
+ ```
50
+
51
+ ### 2. Choose your backend
52
+
53
+ pi-listen supports two transcription backends:
54
+
55
+ | | Deepgram (cloud) | Local models (offline) |
56
+ | ---------------- | -------------------------------------------------------- | --------------------------------------------------- |
57
+ | **How it works** | Live streaming — text appears as you speak | Batch mode — transcribes after you finish recording |
58
+ | **Setup** | API key required | No API key, models auto-download on first use |
59
+ | **Internet** | Required | Not required after model download |
60
+ | **Latency** | Real-time interim results | 2–10 seconds after recording stops |
61
+ | **Languages** | 56+ with live streaming | Depends on model (1–57 languages) |
62
+ | **Cost** | $200 free credit (lasts 6–12 months for most developers) | Free forever |
63
+
64
+ Run `/voice-settings` inside Pi to choose your backend and configure everything from one panel.
65
+
66
+ #### Option A: Deepgram (recommended for live streaming)
67
+
68
+ Sign up at [dpgr.am/pi-voice](https://dpgr.am/pi-voice) — $200 free credit, no card needed.
69
+
70
+ ```bash
71
+ export DEEPGRAM_API_KEY="your-key-here" # add to ~/.zshrc or ~/.bashrc
72
+ ```
73
+
74
+ #### Option B: Local models (fully offline)
75
+
76
+ No setup needed — run `/voice-settings`, switch backend to Local, and select a model. It downloads automatically.
77
+
78
+ > **Note:** Local models use batch mode — they transcribe after you finish recording, not while you speak. For live streaming as you speak, use Deepgram.
79
+
80
+ ### 3. Open Pi
81
+
82
+ On first launch, pi-listen checks your setup and tells you what's ready:
83
+
84
+ - Backend configured (Deepgram key or local model)
85
+ - Audio capture tool detected (sox, ffmpeg, or arecord)
86
+ - If everything checks out, voice activates immediately
87
+
88
+ ### Audio capture
89
+
90
+ pi-listen auto-detects your audio tool. No manual install needed if you already have sox or ffmpeg.
91
+
92
+ | Priority | Tool | Platforms | Install |
93
+ | -------- | --------------- | --------------------- | ------------------------------------------------------------ |
94
+ | 1 | **SoX** (`rec`) | macOS, Linux, Windows | `brew install sox` / `apt install sox` / `choco install sox` |
95
+ | 2 | **ffmpeg** | macOS, Linux, Windows | `brew install ffmpeg` / `apt install ffmpeg` |
96
+ | 3 | **arecord** | Linux only | Pre-installed (ALSA) |
97
+
98
+ ---
99
+
100
+ ## Settings Panel
101
+
102
+ All configuration lives in one place: `/voice-settings`. Four tabs cover everything you need.
103
+
104
+ ### General — backend, language, scope
105
+
106
+ <img src="https://raw.githubusercontent.com/CyFeng16/pi-voicekit/main/assets/settings-general.png" alt="General settings — backend, model, language, scope, voice toggle" width="600" />
107
+
108
+ Toggle between Deepgram (cloud, live streaming) and Local (offline, batch mode). Change language, scope, and enable/disable voice — all with keyboard shortcuts.
109
+
110
+ ### Models — browse, search, install
111
+
112
+ <img src="https://raw.githubusercontent.com/CyFeng16/pi-voicekit/main/assets/settings-models.png" alt="Models tab — browse 19 models with accuracy/speed ratings" width="600" />
113
+
114
+ Browse 19 models from Parakeet, Whisper, Moonshine, SenseVoice, and GigaAM. Each model shows accuracy and speed ratings (●●●●○/●●●●○), fitness badges, and download status. Fuzzy search to find models fast. Press Enter to activate and download.
115
+
116
+ ### Downloaded — manage installed models
117
+
118
+ <img src="https://raw.githubusercontent.com/CyFeng16/pi-voicekit/main/assets/settings-downloaded.png" alt="Downloaded tab — manage installed models, activate or delete" width="600" />
119
+
120
+ See what's installed, total disk usage, and which model is active. Press Enter to activate, `x` to delete. Models from [Handy](https://github.com/cjpais/handy) are auto-detected and can be imported without re-downloading.
121
+
122
+ ### Device — hardware profile and dependencies
123
+
124
+ <img src="https://raw.githubusercontent.com/CyFeng16/pi-voicekit/main/assets/settings-device.png" alt="Device tab — hardware profile, dependencies, disk space" width="600" />
125
+
126
+ See your hardware profile (RAM, CPU, GPU), dependency status (sherpa-onnx runtime), available disk space, and total downloaded models. Model recommendations are based on this profile.
127
+
128
+ ---
129
+
130
+ ## Usage
131
+
132
+ ### Keybindings
133
+
134
+ | Action | Key | Notes |
135
+ | -------------------- | -------------------- | ----------------------------------------------------------------------- |
136
+ | **Record to editor** | Hold `SPACE` (≥1.2s) | Release to finalize. Pre-records during warmup so you don't miss words. |
137
+ | **Toggle recording** | `Ctrl+Shift+V` | Works in all terminals — press to start, press again to stop. |
138
+ | **Clear editor** | `Escape` × 2 | Double-tap within 500ms to clear all text. |
139
+
140
+ ### How recording works
141
+
142
+ 1. **Hold SPACE** — warmup countdown appears, audio capture starts immediately (pre-recording)
143
+ 2. **Keep holding** — live transcription streams into the editor (Deepgram) or audio buffers (local)
144
+ 3. **Release SPACE** — recording continues for 1.5s (tail recording) to catch your last word, then finalizes
145
+ 4. Text appears in the editor, ready to send
146
+
147
+ ### Commands
148
+
149
+ | Command | Description |
150
+ | ------------------------ | --------------------------------------------------------- |
151
+ | `/voice-settings` | Settings panel — backend, models, language, scope, device |
152
+ | `/voice-models` | Settings panel (Models tab) |
153
+ | `/voice-speak <text>` | Speak text out loud (TTS) |
154
+ | `/voice-speak-test` | Speak a sample sentence |
155
+ | `/voice-speak-toggle` | Enable / disable TTS |
156
+ | `/voice-autosubmit` `[on | off]` | Toggle: STT text auto-sent to the agent |
157
+ | `/voice-speak-models` | Browse / install TTS voice models |
158
+ | `/voice-speak-info` | Diagnose TTS state |
159
+ | `/voice-help` | Keyboard + command reference (or press `F1`) |
160
+ | `/voice test` | Full diagnostics — audio tool, mic, API key |
161
+ | `/voice on` / `off` | Enable or disable voice |
162
+ | `/voice dictate` | Continuous dictation (no key hold) |
163
+ | `/voice stop` | Stop active recording or dictation |
164
+ | `/voice history` | Recent transcriptions |
165
+ | `/voice` | Toggle on/off |
166
+
167
+ ### v7.1 keyboard
168
+
169
+ While in the settings panel:
170
+
171
+ | Key | Action |
172
+ | ------ | ----------------------------------- |
173
+ | `← →` | switch tab |
174
+ | `↑ ↓` | navigate row (skips group headings) |
175
+ | `↵` | select / activate |
176
+ | `esc` | back to main / close panel |
177
+ | `type` | filter (search) |
178
+ | `bksp` | clear last search char |
179
+
180
+ While an install widget or playback indicator is mounted (no overlay
181
+ in front):
182
+
183
+ | Key | Action |
184
+ | ----- | ------------------------------------------------------------- |
185
+ | `esc` | cancel active install (most-recent first), then stop playback |
186
+ | `F1` | open help overlay (always available) |
187
+
188
+ ---
189
+
190
+ ## Local Models
191
+
192
+ 19 models across 5 families. Sorted by quality — best models first.
193
+
194
+ ### Top picks
195
+
196
+ | Model | Accuracy | Speed | Size | Languages | Notes |
197
+ | ------------------- | -------- | ----- | ------ | ---------------- | -------------------------- |
198
+ | **Parakeet TDT v3** | ●●●●○ | ●●●●○ | 671 MB | 25 (auto-detect) | Best overall. WER 6.3%. |
199
+ | **Parakeet TDT v2** | ●●●●● | ●●●●○ | 661 MB | English | Best English. WER 6.0%. |
200
+ | **Whisper Turbo** | ●●●●○ | ●●○○○ | 1.0 GB | 57 | Broadest language support. |
201
+
202
+ ### Fast and lightweight
203
+
204
+ | Model | Accuracy | Speed | Size | Languages | Notes |
205
+ | --------------------- | -------- | ----- | ------ | --------------- | ------------------------------------ |
206
+ | **Moonshine v2 Tiny** | ●●○○○ | ●●●●● | 43 MB | English | 34ms latency. Raspberry Pi friendly. |
207
+ | **Moonshine Base** | ●●●○○ | ●●●●● | 287 MB | English | Handles accents well. |
208
+ | **SenseVoice Small** | ●●●○○ | ●●●●● | 228 MB | zh/en/ja/ko/yue | Best for CJK languages. |
209
+
210
+ ### Specialist
211
+
212
+ | Model | Accuracy | Speed | Size | Languages | Notes |
213
+ | -------------------- | -------- | ----- | ------ | --------- | -------------------------------------- |
214
+ | **GigaAM v3** | ●●●●○ | ●●●●○ | 225 MB | Russian | 50% lower WER than Whisper on Russian. |
215
+ | **Whisper Medium** | ●●●●○ | ●●●○○ | 946 MB | 57 | Good accuracy, medium speed. |
216
+ | **Whisper Large v3** | ●●●●○ | ●○○○○ | 1.8 GB | 57 | Highest Whisper accuracy. Slow on CPU. |
217
+
218
+ Plus 8 language-specialized Moonshine v2 variants for Japanese, Korean, Arabic, Chinese, Ukrainian, Vietnamese, and Spanish.
219
+
220
+ ### How local models work
221
+
222
+ ```
223
+ Hold SPACE → audio captured to memory buffer
224
+ ↓
225
+ Release SPACE → buffer sent to sherpa-onnx (in-process)
226
+ ↓
227
+ ONNX inference on CPU (2–10 seconds)
228
+ ↓
229
+ Final transcript inserted into editor
230
+ ```
231
+
232
+ Models download automatically on first use. Downloads are resumable, verified after completion, and deduplicated (no double-downloads). The settings panel shows real-time download progress with speed and ETA.
233
+
234
+ Models from [Handy](https://github.com/cjpais/handy) (`~/Library/Application Support/com.pais.handy/models/`) are auto-detected and can be imported via symlink (zero disk duplication).
235
+
236
+ ---
237
+
238
+ ## Features
239
+
240
+ | Feature | Description |
241
+ | -------------------------------- | ---------------------------------------------------------------------------------------- |
242
+ | **Dual backend** | Deepgram (cloud, live streaming) or local models (offline, batch) — switch in settings |
243
+ | **19 local models** | Parakeet, Whisper, Moonshine, SenseVoice, GigaAM — with accuracy/speed ratings |
244
+ | **Unified settings panel** | One overlay panel for all configuration — `/voice-settings` |
245
+ | **Device-aware recommendations** | Scores models against your hardware. Only best-in-class models get [recommended]. |
246
+ | **Enterprise download pipeline** | Pre-checks (disk, network, permissions), live progress with speed/ETA, post-verification |
247
+ | **Handy integration** | Auto-detects models from Handy app, imports via symlink |
248
+ | **Audio fallback chain** | Tries sox, ffmpeg, arecord in order |
249
+ | **Pre-recording** | Audio capture starts during warmup — you never miss the first word |
250
+ | **Tail recording** | Keeps recording 1.5s after release so your last word isn't clipped |
251
+ | **Live streaming** | Deepgram Nova 3 WebSocket — interim transcripts as you speak |
252
+ | **56+ languages** | Deepgram: 56+ with live streaming. Local: up to 57 depending on model. |
253
+ | **Continuous dictation** | `/voice dictate` for long-form input without holding keys |
254
+ | **Typing cooldown** | Space holds within 400ms of typing are ignored |
255
+ | **Sound feedback** | macOS system sounds for start, stop, and error events |
256
+ | **Cross-platform** | macOS, Windows, Linux — Kitty protocol + non-Kitty fallback |
257
+
258
+ ---
259
+
260
+ ## Architecture
261
+
262
+ ```
263
+ extensions/voice.ts Main extension — state machine, recording, UI, settings panel
264
+ extensions/voice/config.ts Config loading, saving, migration
265
+ extensions/voice/onboarding.ts First-run wizard, language picker
266
+ extensions/voice/deepgram.ts Deepgram URL builder, API key resolver
267
+ extensions/voice/local.ts Model catalog (19 models), in-process transcription
268
+ extensions/voice/device.ts Device profiling — RAM, GPU, CPU, container detection
269
+ extensions/voice/model-download.ts Download manager — resume, progress, verification, Handy import
270
+ extensions/voice/sherpa-engine.ts sherpa-onnx bindings — recognizer lifecycle, inference
271
+ extensions/voice/settings-panel.ts Settings panel — Component interface, overlay, 4 tabs
272
+ ```
273
+
274
+ ---
275
+
276
+ ## Configuration
277
+
278
+ Settings stored in Pi's settings files under the `voice` key:
279
+
280
+ | Scope | Path |
281
+ | ------- | ----------------------------- |
282
+ | Global | `~/.pi/agent/settings.json` |
283
+ | Project | `<project>/.pi/settings.json` |
284
+
285
+ ```json
286
+ {
287
+ "voice": {
288
+ "version": 2,
289
+ "enabled": true,
290
+ "language": "en",
291
+ "backend": "local",
292
+ "localModel": "parakeet-v3",
293
+ "scope": "global",
294
+ "onboarding": { "completed": true, "schemaVersion": 2 }
295
+ }
296
+ }
297
+ ```
298
+
299
+ `DEEPGRAM_API_KEY` from your shell is used at runtime and is not copied back
300
+ into `~/.pi/agent/settings.json`. If you paste a key during onboarding, that is
301
+ an explicit save and it still goes to `~/.env.secrets` or `~/.zshrc`.
302
+
303
+ ---
304
+
305
+ ## Troubleshooting
306
+
307
+ Run `/voice test` inside Pi for full diagnostics.
308
+
309
+ | Problem | Solution |
310
+ | ------------------------------------------------ | --------------------------------------------------------------------------------------------------------------- |
311
+ | "DEEPGRAM_API_KEY not set" | [Get a key](https://dpgr.am/pi-voice) → `export DEEPGRAM_API_KEY="..."` in `~/.zshrc` |
312
+ | "No audio capture tool found" | `brew install sox` or `brew install ffmpeg` |
313
+ | Space doesn't activate voice | Run `/voice-settings` — voice may be disabled |
314
+ | Local model not transcribing | Check `/voice-settings` → Device tab for sherpa-onnx status |
315
+ | Download failed | Partial downloads auto-resume on retry. Check disk space in Device tab. |
316
+ | `dyld: Library not loaded: libsimdjson` on macOS | Homebrew Node ABI mismatch — run `brew reinstall node` or switch to version-managed Node (`mise`, `fnm`, `nvm`) |
317
+
318
+ ---
319
+
320
+ ## Security
321
+
322
+ - **Cloud STT** — audio is sent to Deepgram for transcription (Deepgram backend only)
323
+ - **Local STT** — audio never leaves your machine (local backend)
324
+ - **No telemetry** — pi-listen does not collect or transmit usage data
325
+ - **API key** — stored in env var or Pi settings, never logged
326
+
327
+ See [SECURITY.md](SECURITY.md) for vulnerability reporting.
328
+
329
+ ---
330
+
331
+ ## License
332
+
333
+ [MIT](LICENSE) — original by [@baanditeagle](https://x.com/baanditeagle), maintained by [CyFeng16](https://github.com/CyFeng16)
334
+
335
+ ---
336
+
337
+ <p align="center">
338
+ <strong>Continuation of pi-listen by <a href="https://x.com/baanditeagle">@baanditeagle</a>, maintained by <a href="https://github.com/CyFeng16">CyFeng16</a></strong>
339
+ <br><br>
340
+ <a href="https://abhishektiwari.co">Website</a> · <a href="https://x.com/baanditeagle">𝕏 Twitter</a> · <a href="https://github.com/CyFeng16/pi-voicekit">GitHub</a> · <a href="https://www.npmjs.com/package/pi-voicekit">npm</a> · <a href="https://github.com/CyFeng16/pi-voicekit/issues">Report a Bug</a> · <a href="https://github.com/earendil-works/pi-coding-agent">Pi CLI</a>
341
+ </p>