pi-voice-input 0.2.8 → 0.2.9
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/README.md +5 -5
- package/extensions/voice-input.ts +30 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,13 +10,13 @@ A publishable, pure TypeScript [pi](https://pi.dev/) extension for Linux and mac
|
|
|
10
10
|
Current scope:
|
|
11
11
|
|
|
12
12
|
- Linux uses `pw-record` from PipeWire tools or `arecord` from alsa-utils.
|
|
13
|
-
- macOS uses
|
|
13
|
+
- macOS uses `afrecord` when present, otherwise `ffmpeg` with AVFoundation.
|
|
14
14
|
- A VolcEngine Speech API key is required.
|
|
15
15
|
- This is not a local/offline ASR engine.
|
|
16
16
|
|
|
17
17
|
The provider layer is intended to be extensible. **Current version supports only VolcEngine WebSocket ASR.**
|
|
18
18
|
|
|
19
|
-
No Python, `uv`, upload service
|
|
19
|
+
No Python, `uv`, or upload service is required for normal shortcut usage. On macOS systems without `afrecord`, install `ffmpeg` for recording.
|
|
20
20
|
|
|
21
21
|
## Architecture
|
|
22
22
|
|
|
@@ -26,7 +26,7 @@ pi extension: extensions/voice-input.ts
|
|
|
26
26
|
├─ starts/stops a local recorder process
|
|
27
27
|
│ ├─ Linux preferred: pw-record
|
|
28
28
|
│ ├─ Linux fallback: arecord
|
|
29
|
-
│ └─ macOS: afrecord
|
|
29
|
+
│ └─ macOS: afrecord, or ffmpeg/AVFoundation fallback
|
|
30
30
|
├─ records a temporary 16 kHz mono 16-bit WAV
|
|
31
31
|
├─ parses the WAV container in TypeScript and extracts raw PCM
|
|
32
32
|
├─ sends PCM frames to the configured ASR provider via ws
|
|
@@ -44,9 +44,9 @@ System dependency, one of:
|
|
|
44
44
|
|
|
45
45
|
- Linux: `pw-record` from PipeWire tools, preferred
|
|
46
46
|
- Linux: `arecord` from alsa-utils, fallback
|
|
47
|
-
- macOS: `afrecord
|
|
47
|
+
- macOS: `afrecord` when present, or `ffmpeg` from Homebrew (`brew install ffmpeg`) as the AVFoundation fallback
|
|
48
48
|
|
|
49
|
-
On macOS, grant Terminal or your pi host app microphone permission when prompted. If macOS has previously denied microphone access, enable it in System Settings → Privacy & Security → Microphone.
|
|
49
|
+
On macOS, grant Terminal, ffmpeg, or your pi host app microphone permission when prompted. If macOS has previously denied microphone access, enable it in System Settings → Privacy & Security → Microphone.
|
|
50
50
|
|
|
51
51
|
## Install / Update
|
|
52
52
|
|
|
@@ -217,7 +217,10 @@ function commandOutput(command: string, args: string[], timeoutMs = 1500): strin
|
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
function selectRecorderExecutable(): string {
|
|
220
|
-
if (platform() === "darwin"
|
|
220
|
+
if (platform() === "darwin") {
|
|
221
|
+
if (commandExists("afrecord")) return "afrecord";
|
|
222
|
+
if (commandExists("ffmpeg")) return "ffmpeg";
|
|
223
|
+
}
|
|
221
224
|
if (commandExists("pw-record")) return "pw-record";
|
|
222
225
|
if (commandExists("arecord")) return "arecord";
|
|
223
226
|
return "";
|
|
@@ -237,7 +240,31 @@ function recorderCommand(config: VoiceConfig, outputPath: string): string[] {
|
|
|
237
240
|
if (executable === "afrecord") {
|
|
238
241
|
return ["afrecord", "-f", "WAVE", "-d", "LEI16@16000", "-c", "1", outputPath];
|
|
239
242
|
}
|
|
240
|
-
|
|
243
|
+
if (executable === "ffmpeg" && platform() === "darwin") {
|
|
244
|
+
return [
|
|
245
|
+
"ffmpeg",
|
|
246
|
+
"-hide_banner",
|
|
247
|
+
"-loglevel",
|
|
248
|
+
"error",
|
|
249
|
+
"-nostdin",
|
|
250
|
+
"-y",
|
|
251
|
+
"-f",
|
|
252
|
+
"avfoundation",
|
|
253
|
+
"-i",
|
|
254
|
+
config.recorderTarget || "none:default",
|
|
255
|
+
"-vn",
|
|
256
|
+
"-acodec",
|
|
257
|
+
"pcm_s16le",
|
|
258
|
+
"-ar",
|
|
259
|
+
"16000",
|
|
260
|
+
"-ac",
|
|
261
|
+
"1",
|
|
262
|
+
"-f",
|
|
263
|
+
"wav",
|
|
264
|
+
outputPath,
|
|
265
|
+
];
|
|
266
|
+
}
|
|
267
|
+
throw new Error("No recorder found. On Linux, install PipeWire tools (pw-record) or alsa-utils (arecord). On macOS, install ffmpeg (brew install ffmpeg) if afrecord is not available.");
|
|
241
268
|
}
|
|
242
269
|
|
|
243
270
|
type PipeWireSource = {
|
|
@@ -326,6 +353,7 @@ function recordingDeviceName(config: VoiceConfig, recorderExecutable: string): s
|
|
|
326
353
|
if (recorderExecutable === "pw-record") return pipeWireSourceName(config.recorderTarget);
|
|
327
354
|
if (recorderExecutable === "arecord") return "ALSA default microphone";
|
|
328
355
|
if (recorderExecutable === "afrecord") return "macOS default microphone";
|
|
356
|
+
if (recorderExecutable === "ffmpeg" && platform() === "darwin") return "macOS default microphone (ffmpeg/AVFoundation)";
|
|
329
357
|
return config.recorderTarget || "default microphone";
|
|
330
358
|
}
|
|
331
359
|
|