@tychenjiajun/pi-voice 0.0.0-stage → 0.2.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 (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +134 -2
  3. package/catalog/recommendations.json +710 -0
  4. package/index.ts +1 -0
  5. package/package.json +68 -4
  6. package/src/async-limiter.ts +77 -0
  7. package/src/audio-constants.ts +1 -0
  8. package/src/audio-errors.ts +14 -0
  9. package/src/audio.ts +109 -0
  10. package/src/catalog.generated.ts +1305 -0
  11. package/src/catalog.ts +89 -0
  12. package/src/chinese.ts +52 -0
  13. package/src/deferred.ts +30 -0
  14. package/src/dictation-controller.ts +315 -0
  15. package/src/file-audio.ts +164 -0
  16. package/src/file-transcription.ts +212 -0
  17. package/src/index.ts +135 -0
  18. package/src/install-migration.ts +47 -0
  19. package/src/keybindings.ts +119 -0
  20. package/src/languages.ts +22 -0
  21. package/src/log.ts +171 -0
  22. package/src/microphone-picker.ts +95 -0
  23. package/src/model-activation.ts +74 -0
  24. package/src/model-cells.ts +218 -0
  25. package/src/model-picker.ts +1026 -0
  26. package/src/model-ratings-help.md +41 -0
  27. package/src/model-ratings-help.ts +146 -0
  28. package/src/model-selection-controller.ts +185 -0
  29. package/src/models.ts +263 -0
  30. package/src/onboarding.ts +319 -0
  31. package/src/openai-asr.ts +247 -0
  32. package/src/pcm-chunker.ts +46 -0
  33. package/src/recommendation-picker.ts +512 -0
  34. package/src/recommendations.ts +423 -0
  35. package/src/runtime.ts +524 -0
  36. package/src/settings-menu.ts +638 -0
  37. package/src/settings-path.ts +19 -0
  38. package/src/settings.ts +273 -0
  39. package/src/shortcut-core.ts +85 -0
  40. package/src/shortcuts.ts +167 -0
  41. package/src/startup-shortcut.ts +24 -0
  42. package/src/transcript-preview.ts +52 -0
  43. package/src/transcription-service.ts +570 -0
  44. package/src/transcription.ts +203 -0
  45. package/src/try-it.ts +318 -0
  46. package/src/ui-components.ts +432 -0
  47. package/src/visualizer.ts +271 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Earendil Works contributors
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 CHANGED
@@ -1,3 +1,135 @@
1
- # Temporary Holding Version
1
+ # Pi Voice
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Speech-to-text for Pi — on-device model or OpenAI-compatible remote ASR.
4
+
5
+ Press a keyboard shortcut, talk, and the resulting transcript will be put directly into your chat.
6
+
7
+ > **Fork notice.** `@tychenjiajun/pi-voice` is a fork of [`@earendil-works/pi-voice`](https://github.com/earendil-works/pi-voice) that adds a remote ASR backend (any OpenAI-compatible `input_audio` chat-completions endpoint) with the local model kept as a fallback. It is published independently under a personal npm scope. See the [changelog](#changelog) for what changed.
8
+
9
+ ## Install
10
+
11
+ Install the npm package:
12
+
13
+ ```bash
14
+ pi install npm:@tychenjiajun/pi-voice
15
+ ```
16
+
17
+ If you prefer being on the development tip, you can install from GitHub:
18
+
19
+ ```bash
20
+ pi install ssh://git@github.com/tychenjiajun/pi-voice
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ The extension registers:
26
+
27
+ - a configurable terminal shortcut (`Ctrl+Alt+Z` by default) to start and stop recording;
28
+ - `/voice`, which does the same as the shortcut. While recording, `Space` also stops and transcribes, and `Escape` discards;
29
+ - a `transcribe_file` tool that the agent can use to transcribe local audio or video files;
30
+ - `/voice-settings` for preferred languages, model, transcription language, microphone, and shortcut settings.
31
+
32
+ `/transcribe` remains available as a compatibility alias for `/voice-settings`.
33
+
34
+ ## Remote ASR (OpenAI-compatible endpoint)
35
+
36
+ Pi Voice can send audio to a remote ASR service instead of transcribing with the local model. It speaks the OpenAI chat-completions `input_audio` dialect: the recording is uploaded as a base64 WAV data URL and the transcript is read from `choices[0].message.content`. Any endpoint that accepts that shape works.
37
+
38
+ Set it up in `/voice-settings` → **Transcription backend** → **Remote ASR (OpenAI-compatible)**. You are asked for:
39
+
40
+ 1. **Base URL** — endpoint root, without `/chat/completions`;
41
+ 2. **Model** — the model name your endpoint expects;
42
+ 3. **API key environment variable** — the *name* of an env var. The key itself is read from that variable at runtime and never written to settings.
43
+
44
+ Then export the key before starting Pi:
45
+
46
+ ```bash
47
+ export OPENAI_API_KEY=sk-...
48
+ ```
49
+
50
+ Behavior:
51
+
52
+ - **Local model stays as fallback.** If a remote request fails (network, quota, HTTP error, or the API key is unset), the full recording is transcribed with the configured local model instead; the failure is logged to `~/.pi/agent/pi-voice.log`. Aborted/cancelled transcriptions are never retried locally.
53
+ - **Batch-only.** Remote transcription happens when recording stops (the ASR request carries the whole clip), so there is no streaming preview.
54
+ - **16 kHz mono WAV** is uploaded as a base64 data URL.
55
+ - Switching back to **Local model** restores the original behavior; the local model is still required either way (it is the fallback and file transcription still needs it).
56
+
57
+ Transcripts still go through the **Chinese output** script conversion preference.
58
+
59
+ ## Upgrading from pi-transcribe
60
+
61
+ It's recommended to install Pi Voice via NPM. If you have an older install of pi-transcribe uninstall it via:
62
+
63
+ ```bash
64
+ pi remove git:github.com/earendil-works/pi-transcribe
65
+ ```
66
+
67
+ If you installed it into a project with `-l`, run `pi remove -l git:github.com/earendil-works/pi-transcribe` from that project instead. Then install Pi Voice with:
68
+
69
+ ```bash
70
+ pi install npm:@tychenjiajun/pi-voice
71
+ ```
72
+
73
+ ## File transcription and FFmpeg
74
+
75
+ The agent can call `transcribe_file` for local audio or video files. Decoded audio is limited to 128 MiB (about 35 minutes). File decoding requires the `ffmpeg` executable. Install FFmpeg with your system package manager if you don't already have it installed
76
+
77
+ ```bash
78
+ # macOS with Homebrew
79
+ brew install ffmpeg
80
+
81
+ # Debian or Ubuntu
82
+ sudo apt install ffmpeg
83
+
84
+ # Windows with winget
85
+ winget install Gyan.FFmpeg
86
+ ```
87
+
88
+ If FFmpeg is installed outside `PATH`, point Pi Voice at it before starting Pi:
89
+
90
+ ```bash
91
+ export PI_VOICE_FFMPEG_PATH=/path/to/ffmpeg
92
+ ```
93
+
94
+ The legacy `PI_TRANSCRIBE_FFMPEG_PATH` variable remains supported when `PI_VOICE_FFMPEG_PATH` is not set.
95
+
96
+ When FFmpeg is unavailable, `transcribe_file` reports platform-specific guidance to the agent. The agent should ask before running a package-manager command. Model setup is still explicit: run `/voice-settings` once in the interactive TUI to choose and, after confirmation, download a local model.
97
+
98
+ ## Changelog
99
+
100
+ ### 0.2.0
101
+
102
+ First release of `@tychenjiajun/pi-voice` — a fork of [`@earendil-works/pi-voice`](https://github.com/earendil-works/pi-voice) 0.1.0, published independently under the `@tychenjiajun` scope.
103
+
104
+ **Added — Remote ASR backend**
105
+
106
+ - Recordings can be transcribed by any OpenAI-compatible chat-completions ASR endpoint via the `input_audio` content block.
107
+ - Configure in `/voice-settings` → **Transcription backend** → **Remote ASR (OpenAI-compatible)**: base URL, model, and the *name* of an env var holding the API key (the key itself is never stored in settings).
108
+ - Audio is uploaded as a 16 kHz mono WAV base64 data URL. Remote transcription is batch-only (no streaming preview).
109
+ - **Local model fallback:** if a remote request fails (network, quota, HTTP error, or the API key is unset), the full recording is transcribed with the configured local model; the failure is logged to `~/.pi/agent/pi-voice.log`. Aborted/cancelled transcriptions are never retried locally.
110
+
111
+ **Changed**
112
+
113
+ - Package name, repository, homepage, and bugs URLs updated to the fork (`tychenjiajun/pi-voice`).
114
+ - Chinese script conversion for remote transcripts mirrors the local backend (applies only when the configured language is Chinese).
115
+
116
+ ### 0.1.0
117
+
118
+ Upstream `@earendil-works/pi-voice` initial release.
119
+
120
+ ## Developing & Building Pi Voice
121
+
122
+ To develop or run it from a checkout:
123
+
124
+ ```bash
125
+ git clone git@github.com:tychenjiajun/pi-voice.git
126
+ cd pi-voice
127
+ npm install --ignore-scripts
128
+ pi -e .
129
+ ```
130
+
131
+ If you want to be able to re-run onboarding you can enable the debug env var when starting Pi. This enables the `/voice-onboarding` command.
132
+
133
+ ```bash
134
+ PI_VOICE_DEBUG=1 pi -e /absolute/path/to/pi-voice
135
+ ```