@tychenjiajun/pi-voice 0.0.0-stage → 0.3.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.
- package/LICENSE +21 -0
- package/README.md +163 -2
- package/catalog/recommendations.json +710 -0
- package/index.ts +1 -0
- package/package.json +68 -4
- package/src/async-limiter.ts +77 -0
- package/src/audio-constants.ts +1 -0
- package/src/audio-errors.ts +14 -0
- package/src/audio.ts +109 -0
- package/src/catalog.generated.ts +1305 -0
- package/src/catalog.ts +89 -0
- package/src/chinese.ts +52 -0
- package/src/deferred.ts +30 -0
- package/src/dictation-controller.ts +315 -0
- package/src/file-audio.ts +164 -0
- package/src/file-transcription.ts +222 -0
- package/src/index.ts +135 -0
- package/src/install-migration.ts +47 -0
- package/src/keybindings.ts +119 -0
- package/src/languages.ts +22 -0
- package/src/log.ts +171 -0
- package/src/microphone-picker.ts +95 -0
- package/src/model-activation.ts +74 -0
- package/src/model-cells.ts +218 -0
- package/src/model-picker.ts +1026 -0
- package/src/model-ratings-help.md +41 -0
- package/src/model-ratings-help.ts +146 -0
- package/src/model-selection-controller.ts +185 -0
- package/src/models.ts +263 -0
- package/src/onboarding.ts +328 -0
- package/src/openai-asr.ts +247 -0
- package/src/pcm-chunker.ts +46 -0
- package/src/polish.ts +165 -0
- package/src/recommendation-picker.ts +512 -0
- package/src/recommendations.ts +423 -0
- package/src/runtime.ts +531 -0
- package/src/settings-menu.ts +781 -0
- package/src/settings-path.ts +19 -0
- package/src/settings.ts +299 -0
- package/src/shortcut-core.ts +85 -0
- package/src/shortcuts.ts +167 -0
- package/src/startup-shortcut.ts +24 -0
- package/src/transcript-preview.ts +52 -0
- package/src/transcription-service.ts +570 -0
- package/src/transcription.ts +203 -0
- package/src/try-it.ts +318 -0
- package/src/ui-components.ts +432 -0
- 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,164 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Pi Voice
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Speech-to-text for Pi — on-device model or OpenAI-compatible remote ASR, with optional compaction-style post-processing.
|
|
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, plus compaction-style post-processing that refines a transcript with Pi's own model. 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, post-processing, 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
|
+
## Post-processing (compaction-style refinement)
|
|
60
|
+
|
|
61
|
+
After ASR produces a transcript, Pi Voice can refine it with the same model (and provider credentials) Pi agents already use for tasks like conversation compaction. The cleanup fixes obvious speech-recognition errors, punctuation, and capitalization, and strips filler words and false starts — without a separate endpoint to configure.
|
|
62
|
+
|
|
63
|
+
Set it up in `/voice-settings` → **Post-processing** → **On**. You then choose the model:
|
|
64
|
+
|
|
65
|
+
- **Pi's current model** (default) — whichever model the agent is using, exactly like compaction;
|
|
66
|
+
- **a different model** — any model from Pi's registry, using that provider's configured authentication.
|
|
67
|
+
|
|
68
|
+
Pi Voice makes a small nested request through Pi's model registry, so it automatically reuses Pi's model definitions and API keys (or OAuth). No base URL, key, or timeout is stored in Pi Voice settings.
|
|
69
|
+
|
|
70
|
+
Behavior:
|
|
71
|
+
|
|
72
|
+
- **Best-effort only.** If post-processing fails (no usable model, abort, provider/network error, or an empty response), the raw transcript is used unchanged and the failure is logged to `~/.pi/agent/pi-voice.log`. An override that is no longer in the registry falls back to the agent's current model.
|
|
73
|
+
- **Reasoning-safe.** A provider's thinking is ignored (Pi reports it as `thinking` blocks), and inline reasoning tags a model may embed in its text are stripped. If only reasoning comes back, the raw transcript is kept.
|
|
74
|
+
- **Discrete, not streaming.** Refinement happens after the full transcript is produced, so there is no live preview of the polished text.
|
|
75
|
+
- **Applies to all transcription.** Microphone dictation and the `transcribe_file` tool both go through the same post-processing step when it is enabled.
|
|
76
|
+
|
|
77
|
+
## Upgrading from pi-transcribe
|
|
78
|
+
|
|
79
|
+
It's recommended to install Pi Voice via NPM. If you have an older install of pi-transcribe uninstall it via:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
pi remove git:github.com/earendil-works/pi-transcribe
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
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:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
pi install npm:@tychenjiajun/pi-voice
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## File transcription and FFmpeg
|
|
92
|
+
|
|
93
|
+
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
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# macOS with Homebrew
|
|
97
|
+
brew install ffmpeg
|
|
98
|
+
|
|
99
|
+
# Debian or Ubuntu
|
|
100
|
+
sudo apt install ffmpeg
|
|
101
|
+
|
|
102
|
+
# Windows with winget
|
|
103
|
+
winget install Gyan.FFmpeg
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
If FFmpeg is installed outside `PATH`, point Pi Voice at it before starting Pi:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
export PI_VOICE_FFMPEG_PATH=/path/to/ffmpeg
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
The legacy `PI_TRANSCRIBE_FFMPEG_PATH` variable remains supported when `PI_VOICE_FFMPEG_PATH` is not set.
|
|
113
|
+
|
|
114
|
+
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.
|
|
115
|
+
|
|
116
|
+
## Changelog
|
|
117
|
+
|
|
118
|
+
### 0.3.0
|
|
119
|
+
|
|
120
|
+
**Added — Post-processing (compaction-style refinement)**
|
|
121
|
+
|
|
122
|
+
- After ASR, transcripts can be refined with the agent's current model and provider, reusing the same nested-model path as conversation compaction.
|
|
123
|
+
- Configure in `/voice-settings` → **Post-processing**: toggle **Off / On**, then use **Pi's current model** or pick a different model from Pi's registry (its model definitions and authentication are reused).
|
|
124
|
+
- **Best-effort only:** no usable model, aborts, provider failures, and empty responses all keep the raw transcript; an override that disappears falls back to the agent's current model. Diagnostics go to `~/.pi/agent/pi-voice.log`.
|
|
125
|
+
- **Reasoning-safe:** provider thinking blocks are ignored, inline reasoning tags (`think` … `response`) are stripped, and a response that is only reasoning keeps the raw transcript.
|
|
126
|
+
- Applies to both microphone dictation and the `transcribe_file` tool.
|
|
127
|
+
- Existing settings remain valid: post-processing defaults to **Off**.
|
|
128
|
+
|
|
129
|
+
### 0.2.0
|
|
130
|
+
|
|
131
|
+
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.
|
|
132
|
+
|
|
133
|
+
**Added — Remote ASR backend**
|
|
134
|
+
|
|
135
|
+
- Recordings can be transcribed by any OpenAI-compatible chat-completions ASR endpoint via the `input_audio` content block.
|
|
136
|
+
- 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).
|
|
137
|
+
- Audio is uploaded as a 16 kHz mono WAV base64 data URL. Remote transcription is batch-only (no streaming preview).
|
|
138
|
+
- **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.
|
|
139
|
+
|
|
140
|
+
**Changed**
|
|
141
|
+
|
|
142
|
+
- Package name, repository, homepage, and bugs URLs updated to the fork (`tychenjiajun/pi-voice`).
|
|
143
|
+
- Chinese script conversion for remote transcripts mirrors the local backend (applies only when the configured language is Chinese).
|
|
144
|
+
|
|
145
|
+
### 0.1.0
|
|
146
|
+
|
|
147
|
+
Upstream `@earendil-works/pi-voice` initial release.
|
|
148
|
+
|
|
149
|
+
## Developing & Building Pi Voice
|
|
150
|
+
|
|
151
|
+
To develop or run it from a checkout:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
git clone git@github.com:tychenjiajun/pi-voice.git
|
|
155
|
+
cd pi-voice
|
|
156
|
+
npm install --ignore-scripts
|
|
157
|
+
pi -e .
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
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.
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
PI_VOICE_DEBUG=1 pi -e /absolute/path/to/pi-voice
|
|
164
|
+
```
|