@senad-d/micme 0.2.1 → 0.3.1

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/CHANGELOG.md CHANGED
@@ -10,6 +10,10 @@ All notable changes to Micme will be documented in this file.
10
10
  - Add an interactive npm publishing script that prompts for a version, validates the package, creates the release commit/tag, and publishes with public scoped-package access.
11
11
  - Keep publication on hold until package name, metadata, security review, validation, and smoke tests are complete.
12
12
  - Add explicit transcription backend selection with backend-specific `/micme conf` model rows, doctor diagnostics, schema, and docs.
13
+ - Add a single `MICME_TRANSLATE_TO_ENGLISH` setting that translates selected source languages to English and switches default Whisper model names to multilingual variants.
14
+ - Store kept audio in sequential project directories under `./micme-rec/rec-###/` instead of the system temp directory.
15
+ - Make the recorder quality-safe by default: preserve recorder timing from ffmpeg timestamps, disable the stdout meter branch, and ask macOS AVFoundation not to drop late frames.
16
+ - Rename the translation UI to “Translate from” and automatically route translation away from non-translation Whisper turbo models to the closest translate-capable model.
13
17
 
14
18
  ## 0.1.0 - 2026-06-18
15
19
 
package/README.md CHANGED
@@ -15,15 +15,15 @@
15
15
 
16
16
  ---
17
17
 
18
- Micme is a pi extension for short coding prompts. It records your microphone with `ffmpeg`, transcribes locally with `whisper.cpp` or another local backend, and inserts the transcript into pi.
18
+ MicMe is a Pi extension for coding prompts. It records your microphone with `ffmpeg`, transcribes locally with `whisper.cpp` or another local backend, and inserts the transcript into pi.
19
19
 
20
20
  <table align="center">
21
21
  <tr>
22
- <th>Micme demo</th>
22
+ <th>MicMe demo</th>
23
23
  </tr>
24
24
  <tr>
25
25
  <td align="center">
26
- <img src="img/demo.gif" alt="Micme demo: record voice and paste the transcript into pi" title="Micme demo" width="760">
26
+ <img src="img/demo.gif" alt="MicMe demo: record voice and paste the transcript into pi" title="MicMe demo" width="760">
27
27
  </td>
28
28
  </tr>
29
29
  </table>
@@ -120,7 +120,7 @@ Micme does not bundle recorder, transcriber, or model binaries.
120
120
 
121
121
  | OS | Install | Device setting |
122
122
  | --- | --- | --- |
123
- | macOS | `brew install ffmpeg whisper-cpp` | `MICME_AUDIO_DEVICE=0` or `MICME_AVFOUNDATION_INPUT=:0` |
123
+ | macOS | `brew install ffmpeg whisper-cpp` | Run `/micme devices`, then set `MICME_AUDIO_DEVICE=<audio id>` or `MICME_AVFOUNDATION_INPUT=:<audio id>`. |
124
124
  | Linux | Install `ffmpeg` and `whisper.cpp` with your package manager, Nix, Homebrew, or source build. | `MICME_PULSE_SOURCE=default` |
125
125
  | Windows | `winget install Gyan.FFmpeg`, then install/build `whisper.cpp`. | `MICME_DSHOW_AUDIO_DEVICE=Microphone Name` |
126
126
 
@@ -147,7 +147,7 @@ MICME_WHISPER_CPP_MODEL=/path/to/ggml-small.en.bin
147
147
 
148
148
  ## Configuration
149
149
 
150
- Micme reads settings from shell environment variables and from the global Micme config file at `~/.pi/agent/micme.json`. Shell variables win. `/micme conf` writes only `MICME_*` keys to that JSON file, so settings follow you across pi projects on the same machine.
150
+ MicMe reads settings from shell environment variables and from the global Micme config file at `~/.pi/agent/micme.json`. Shell variables win. `/micme conf` writes only `MICME_*` keys to that JSON file, so settings follow you across pi projects on the same machine.
151
151
 
152
152
  The usual setup path is to run:
153
153
 
@@ -161,6 +161,7 @@ You can also edit the JSON manually. Minimal `~/.pi/agent/micme.json`:
161
161
  {
162
162
  "$schema": "https://raw.githubusercontent.com/senad-d/micme/main/micme.schema.json",
163
163
  "MICME_LANGUAGE": "en",
164
+ "MICME_TRANSLATE_TO_ENGLISH": "off",
164
165
  "MICME_TRANSCRIBE_BACKEND": "auto",
165
166
  "MICME_AUTO_DOWNLOAD_MODEL": "1",
166
167
  "MICME_DEFAULT_WHISPER_CPP_MODEL": "small.en",
@@ -178,14 +179,19 @@ Common settings:
178
179
  | `MICME_TRANSCRIBE_BACKEND=auto` | Backend selector. `auto` preserves priority: custom command, whisper.cpp, then Python Whisper. |
179
180
  | `MICME_TRANSCRIPTION_MODE=clip` | Stable default: transcribe after recording stops. |
180
181
  | `MICME_TRANSCRIPTION_MODE=stream` | Experimental append-only live dictation with `whisper-stream`; requires whisper.cpp. |
182
+ | `MICME_LANGUAGE=en` | Transcription language when translation is off. Use `auto` for detection. |
183
+ | `MICME_TRANSLATE_TO_ENGLISH=off` | “Translate from” option. Leave `off`, or set the spoken source language code such as `hr`, `bs`, `de`, or `tr` to output English. |
181
184
  | `MICME_STREAM_KEEP_CONTEXT=0` | Stream default: avoid Whisper prompt carry-over so live chunks are less likely to rewrite each other. |
182
185
  | `MICME_STREAM_FLUSH_MS=650` | Stream profile quiet interval before tentative words are committed append-only. |
183
186
  | `MICME_STREAM_FINALIZE_WITH_CLIP=0` | Keep the append-only live transcript on stop. Set `1` to opt in to final clip replacement. |
184
187
  | `MICME_AUTO_SUBMIT=0` | Paste for review. Set `1` to send automatically. |
185
- | `MICME_SHORTCUT=alt+m` | Toggle shortcut. Restart or `/reload` after changing. |
186
- | `MICME_PRINTABLE_SHORTCUTS=§` | macOS Option-key fallback. |
188
+ | `MICME_SHORTCUT=alt+m` | Toggle shortcut. Use terminal syntax (`alt+m`, `ctrl+space`, `f8`) or a printable character such as `§`. Restart or `/reload` after changing. |
187
189
  | `MICME_VALIDATE_AUDIO=1` | Reject near-silent recordings. |
188
- | `MICME_KEEP_AUDIO=0` | Delete successful temp audio. Set `1` for debugging. |
190
+ | `MICME_RECORD_SAMPLE_RATE=auto` | Raw recording sample-rate override. Leave `auto` so ffmpeg uses the selected input's native rate. |
191
+ | `MICME_RECORD_SYNC=1` | Automatically preserve wall-clock recording duration from ffmpeg timestamps. |
192
+ | `MICME_RECORD_METER=0` | Quality-safe default: meter from `raw.wav` instead of a second ffmpeg stdout branch. Set `1` to restore the legacy live meter pipe. |
193
+ | `MICME_AVFOUNDATION_DROP_LATE_FRAMES=0` | macOS only: ask AVFoundation not to drop late frames when capture lags. |
194
+ | `MICME_KEEP_AUDIO=0` | Delete successful recording audio. Set `1` to keep each recording under `./micme-rec/rec-###/` for debugging. |
189
195
  | `MICME_MODEL_DIR=~/.cache/whisper.cpp` | Model cache/discovery directory. |
190
196
 
191
197
  See [`micme.example.json`](micme.example.json) for the full JSON template.
@@ -211,10 +217,8 @@ Streaming mode treats `whisper-stream` output as repeated, overlapping hypothese
211
217
 
212
218
  Micme supports these backend values in JSON/env config:
213
219
 
214
- - `auto` (default): custom command when configured, otherwise whisper.cpp, otherwise Python Whisper.
215
220
  - `whisper.cpp`: uses `whisper-cli`/`whisper-cpp` and a ggml/gguf model path.
216
221
  - `python`: uses the OpenAI Whisper `whisper` CLI and a Python model name.
217
- - `custom`: runs `MICME_TRANSCRIBE_COMMAND`; Micme treats the model as unknown.
218
222
 
219
223
  `/micme conf` keeps the interactive backend picker focused on `whisper.cpp` and `Python Whisper`, then shows only the model/binary fields for the selected backend. For whisper.cpp, `MICME_WHISPER_CPP_MODEL` is the selected ggml/gguf model path; if it is unset, Micme falls back to `${MICME_MODEL_DIR}/ggml-${MICME_DEFAULT_WHISPER_CPP_MODEL}.bin`. For Python Whisper, `MICME_WHISPER_MODEL` is passed as the CLI model name.
220
224
 
@@ -224,12 +228,12 @@ With `MICME_AUTO_DOWNLOAD_MODEL=1`, Micme downloads missing standard whisper.cpp
224
228
  MICME_AUTO_DOWNLOAD_MODEL=0
225
229
  ```
226
230
 
227
- Recommended model progression: `base.en` for speed, `small.en` for a stronger default, `medium.en` for accuracy.
231
+ Recommended model progression: `base.en` for speed, `small.en` for a stronger default, `medium.en` for accuracy. Translation uses Whisper's built-in translate task and needs translate-capable multilingual models; when `MICME_TRANSLATE_TO_ENGLISH` is enabled, Micme maps `.en` model names to multilingual defaults (`small.en` → `small`, `base.en` → `base`) and maps non-translation turbo models to the closest translate-capable model (`large-v3-turbo` → `large-v3`).
228
232
 
229
233
  Advanced users can replace the recorder or transcriber:
230
234
 
231
235
  ```env
232
- MICME_RECORD_COMMAND=ffmpeg -hide_banner -loglevel error -f avfoundation -i :0 -ac 1 -ar 16000 -y {audio}
236
+ MICME_RECORD_COMMAND=ffmpeg -hide_banner -loglevel error -f avfoundation -i :0 -af aresample=async=1:first_pts=0 -ac 1 -y {audio}
233
237
  MICME_TRANSCRIBE_COMMAND=whisper-cli -m /path/to/model.bin -f {audio} -otxt -of {tempDirRaw}/out -nt -np && cat {tempDirRaw}/out.txt
234
238
  ```
235
239
 
@@ -243,6 +247,7 @@ MICME_TRANSCRIBE_COMMAND=whisper-cli -m /path/to/model.bin -f {audio} -otxt -of
243
247
  | --- | --- |
244
248
  | No backend found | Use `/micme conf` to choose `whisper.cpp` or Python Whisper, install the selected backend, or configure a trusted custom command manually. |
245
249
  | Wrong microphone | Run `/micme devices`, then set the OS-specific device variable. |
250
+ | Crackling or shortened audio | Keep `MICME_RECORD_SYNC=1` and `MICME_RECORD_METER=0`; on macOS keep `MICME_AVFOUNDATION_DROP_LATE_FRAMES=0`, and avoid Aggregate/BlackHole devices unless intentionally routing audio. |
246
251
  | Unrelated transcript | You probably recorded silence. Set `MICME_KEEP_AUDIO=1` and check `/micme audio`. |
247
252
  | Slow transcription | Use `whisper.cpp`, a smaller model, and shorter recordings. |
248
253
  | Option/Alt inserts `§` or `µ` | Set `MICME_PRINTABLE_SHORTCUTS=§` or change `MICME_SHORTCUT`, then `/reload`. |
package/SECURITY.md CHANGED
@@ -23,7 +23,7 @@ The default recorder uses `ffmpeg` and your operating system's microphone APIs:
23
23
  - Linux: PulseAudio through `ffmpeg -f pulse`
24
24
  - Windows: DirectShow through `ffmpeg -f dshow`
25
25
 
26
- Micme writes temporary audio files under the operating system temp directory while a recording is being processed. After successful transcription, those files are removed by default. Set `MICME_KEEP_AUDIO=1` only when you intentionally want to keep the last raw/preprocessed audio for debugging.
26
+ Micme writes temporary audio files under the operating system temp directory by default. After successful transcription, those files are removed. Set `MICME_KEEP_AUDIO=1` only when you intentionally want to keep raw/preprocessed audio for debugging; kept recordings are written to per-recording project directories such as `./micme-rec/rec-001/`.
27
27
 
28
28
  ## Local process execution
29
29
 
@@ -1,18 +1,21 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/senad-d/micme/main/micme.schema.json",
3
3
  "MICME_SHORTCUT": "alt+m",
4
- "MICME_PRINTABLE_SHORTCUTS": "§",
5
4
  "MICME_TRANSCRIPTION_MODE": "clip",
6
5
  "MICME_TRANSCRIBE_BACKEND": "auto",
7
6
  "MICME_AUTO_SUBMIT": "0",
8
7
  "MICME_LANGUAGE": "en",
8
+ "MICME_TRANSLATE_TO_ENGLISH": "off",
9
9
  "MICME_TRANSCRIBE_TIMEOUT_MS": "120000",
10
10
  "MICME_AUTO_DOWNLOAD_MODEL": "1",
11
11
  "MICME_DEFAULT_WHISPER_CPP_MODEL": "small.en",
12
12
  "MICME_MODEL_DIR": "${HOME}/.cache/whisper.cpp",
13
13
  "MICME_AUDIO_DEVICE": "0",
14
- "MICME_RECORD_SAMPLE_RATE": "48000",
14
+ "MICME_RECORD_SAMPLE_RATE": "auto",
15
15
  "MICME_TRANSCRIBE_SAMPLE_RATE": "16000",
16
+ "MICME_RECORD_SYNC": "1",
17
+ "MICME_RECORD_METER": "0",
18
+ "MICME_AVFOUNDATION_DROP_LATE_FRAMES": "0",
16
19
  "MICME_PROCESS_AUDIO": "1",
17
20
  "MICME_AUDIO_FILTER": "highpass=f=80,lowpass=f=7600",
18
21
  "MICME_VALIDATE_AUDIO": "1",
package/micme.schema.json CHANGED
@@ -10,11 +10,13 @@
10
10
  },
11
11
  "MICME_SHORTCUT": {
12
12
  "type": "string",
13
- "default": "alt+m"
13
+ "default": "alt+m",
14
+ "description": "Unified toggle shortcut. Use terminal syntax such as alt+m/ctrl+space/f8, or a printable character such as §."
14
15
  },
15
16
  "MICME_PRINTABLE_SHORTCUTS": {
16
17
  "type": "string",
17
- "default": "§"
18
+ "default": "§",
19
+ "description": "Legacy printable-character fallback. Prefer MICME_SHORTCUT with a printable character."
18
20
  },
19
21
  "MICME_TRANSCRIPTION_MODE": {
20
22
  "type": "string",
@@ -32,7 +34,14 @@
32
34
  },
33
35
  "MICME_LANGUAGE": {
34
36
  "type": "string",
35
- "default": "en"
37
+ "default": "en",
38
+ "description": "Transcription language when translation is off. Use auto for language detection."
39
+ },
40
+ "MICME_TRANSLATE_TO_ENGLISH": {
41
+ "type": "string",
42
+ "enum": ["off", "bs", "hr", "sr", "de", "es", "fr", "it", "pt", "nl", "pl", "tr"],
43
+ "default": "off",
44
+ "description": "Translate from control. off disables translation; any language code means translate speech in that source language to English."
36
45
  },
37
46
  "MICME_AUTO_DOWNLOAD_MODEL": {
38
47
  "$ref": "#/$defs/stringFlag"
@@ -63,6 +72,28 @@
63
72
  "type": "string",
64
73
  "default": "0"
65
74
  },
75
+ "MICME_RECORD_SAMPLE_RATE": {
76
+ "type": ["string", "number"],
77
+ "default": "auto",
78
+ "description": "Raw recording sample-rate override. Leave auto/unset so ffmpeg uses the selected input's native sample rate."
79
+ },
80
+ "MICME_RECORD_SYNC": {
81
+ "$ref": "#/$defs/stringFlag",
82
+ "default": "1",
83
+ "description": "Preserve wall-clock recording duration from ffmpeg timestamps with aresample async correction. Defaults on."
84
+ },
85
+ "MICME_RECORD_METER": {
86
+ "$ref": "#/$defs/stringFlag",
87
+ "description": "Enable the legacy ffmpeg stdout PCM branch for live metering. Defaults off to avoid recorder backpressure; the UI can still meter by polling raw.wav."
88
+ },
89
+ "MICME_AVFOUNDATION_DROP_LATE_FRAMES": {
90
+ "$ref": "#/$defs/stringFlag",
91
+ "description": "macOS AVFoundation only. Defaults off so ffmpeg is asked not to drop late frames when capture lags."
92
+ },
93
+ "MICME_AVFOUNDATION_INPUT_SAMPLE_RATE": {
94
+ "type": ["string", "number"],
95
+ "description": "Advanced macOS fallback used only when MICME_RECORD_SYNC=0. Reinterpret input samples with this source rate before resampling."
96
+ },
66
97
  "MICME_KEEP_AUDIO": {
67
98
  "$ref": "#/$defs/stringFlag"
68
99
  },
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@senad-d/micme",
3
- "version": "0.2.1",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
- "description": "Local voice-to-text for pi, optimized for fast Whisper-style backends.",
5
+ "description": "Local voice dictation for Pi coding prompts. Press Alt+M, speak, review, send.",
6
6
  "license": "MIT",
7
7
  "author": "Senad Dizdarević <112484166+senad-d@users.noreply.github.com>",
8
8
  "repository": {
@@ -16,12 +16,22 @@
16
16
  "keywords": [
17
17
  "pi-package",
18
18
  "pi-extension",
19
+ "pi-agent",
20
+ "pi-coding-agent",
19
21
  "voice-to-text",
20
22
  "speech-to-text",
23
+ "voice-input",
21
24
  "dictation",
22
25
  "whisper",
23
- "whisper.cpp",
24
- "local-first"
26
+ "whisper-cpp",
27
+ "local-first",
28
+ "offline",
29
+ "privacy",
30
+ "developer-tools",
31
+ "cli",
32
+ "terminal",
33
+ "typescript",
34
+ "coding-agent"
25
35
  ],
26
36
  "engines": {
27
37
  "node": ">=22.19.0"
@@ -56,7 +66,8 @@
56
66
  "pi": {
57
67
  "extensions": [
58
68
  "./src/extension.ts"
59
- ]
69
+ ],
70
+ "image": "https://raw.githubusercontent.com/senad-d/micme/main/img/demo.gif"
60
71
  },
61
72
  "peerDependencies": {
62
73
  "@earendil-works/pi-coding-agent": "*",
@@ -13,6 +13,7 @@ const forbiddenChecks = [
13
13
  { label: "node_modules", test: (path) => path.startsWith("node_modules/") || path.includes("/node_modules/") },
14
14
  { label: "planning specs", test: (path) => path.startsWith("specs/") },
15
15
  { label: "Micme cache", test: (path) => path.startsWith(".micme/") || path.includes("/.micme/") },
16
+ { label: "Micme recordings", test: (path) => path.startsWith("micme-rec/") || path.includes("/micme-rec/") },
16
17
  { label: "token insight files", test: (path) => path.includes("token-insights") },
17
18
  { label: "npm tarballs", test: (path) => /(^|\/)micme-[^/]+\.tgz$/i.test(path) || path.endsWith(".tgz") },
18
19
  { label: "audio artifacts", test: (path) => /\.(wav|mp3|m4a|flac|ogg|opus|aiff?|pcm)$/i.test(path) },
@@ -102,16 +102,43 @@ function getTranscriptionMode() {
102
102
  return env("MICME_TRANSCRIPTION_MODE") === "stream" ? "stream" : "clip";
103
103
  }
104
104
 
105
+ function getTranslateToEnglishLanguage() {
106
+ const value = env("MICME_TRANSLATE_TO_ENGLISH")?.trim();
107
+ if (!value || /^(0|false|no|off)$/i.test(value)) return undefined;
108
+ return value;
109
+ }
110
+
111
+ function toMultilingualWhisperModelName(modelName) {
112
+ return modelName.replace(/\.en$/i, "");
113
+ }
114
+
115
+ function getTranslationAwareWhisperModelName(modelName) {
116
+ return getTranslateToEnglishLanguage() ? toMultilingualWhisperModelName(modelName) : modelName;
117
+ }
118
+
119
+ function isEnglishOnlyWhisperModelName(modelName) {
120
+ return Boolean(modelName && /\.en$/i.test(modelName));
121
+ }
122
+
123
+ function inferWhisperCppModelName(modelPath) {
124
+ return modelPath.match(/(?:^|[/\\])ggml-(.+)\.(?:bin|gguf)$/i)?.[1];
125
+ }
126
+
127
+ function getPythonWhisperModelName() {
128
+ return getTranslationAwareWhisperModelName(env("MICME_WHISPER_MODEL") || "base.en");
129
+ }
130
+
105
131
  function resolveWhisperCppModelSummary() {
106
132
  const explicit = envPath("MICME_WHISPER_CPP_MODEL");
107
133
  if (explicit) {
108
134
  return {
109
135
  path: explicit,
136
+ modelName: inferWhisperCppModelName(explicit),
110
137
  source: "MICME_WHISPER_CPP_MODEL explicit path",
111
138
  exists: existsSync(explicit),
112
139
  };
113
140
  }
114
- const defaultModel = env("MICME_DEFAULT_WHISPER_CPP_MODEL") || "small.en";
141
+ const defaultModel = getTranslationAwareWhisperModelName(env("MICME_DEFAULT_WHISPER_CPP_MODEL") || "small.en");
115
142
  const modelDir = expandConfigValue(env("MICME_MODEL_DIR") || join(homedir(), ".cache", "whisper.cpp"));
116
143
  const path = join(modelDir, `ggml-${defaultModel}.bin`);
117
144
  return {
@@ -156,13 +183,13 @@ function resolveBackendPlan({ whisperCpp, whisperStream, whisper, transcribeComm
156
183
  return { requestedBackend, effectiveBackend: "none", effectiveModel: "unavailable", reason: "MICME_TRANSCRIBE_BACKEND=whisper.cpp but whisper.cpp was not found.", warnings };
157
184
  }
158
185
  if (requestedBackend === "python") {
159
- if (pythonAvailable) return { requestedBackend, effectiveBackend: "python", binary: whisper, effectiveModel: env("MICME_WHISPER_MODEL") || "base.en", reason: "MICME_TRANSCRIBE_BACKEND=python", warnings };
186
+ if (pythonAvailable) return { requestedBackend, effectiveBackend: "python", binary: whisper, effectiveModel: getPythonWhisperModelName(), reason: "MICME_TRANSCRIBE_BACKEND=python", warnings };
160
187
  return { requestedBackend, effectiveBackend: "none", effectiveModel: "unavailable", reason: "MICME_TRANSCRIBE_BACKEND=python but the `whisper` CLI was not found.", warnings };
161
188
  }
162
189
 
163
190
  if (transcribeCommand?.trim()) return { requestedBackend, effectiveBackend: "custom", effectiveModel: "unknown", reason: "auto selected custom command because MICME_TRANSCRIBE_COMMAND is configured", warnings };
164
191
  if (whisperCppAvailable) return { requestedBackend, effectiveBackend: "whisper.cpp", binary: whisperCpp, model, effectiveModel: model.path, reason: "auto selected whisper.cpp because a whisper.cpp binary is available", warnings };
165
- if (pythonAvailable) return { requestedBackend, effectiveBackend: "python", binary: whisper, effectiveModel: env("MICME_WHISPER_MODEL") || "base.en", reason: "auto selected Python Whisper because whisper.cpp is unavailable", warnings };
192
+ if (pythonAvailable) return { requestedBackend, effectiveBackend: "python", binary: whisper, effectiveModel: getPythonWhisperModelName(), reason: "auto selected Python Whisper because whisper.cpp is unavailable", warnings };
166
193
  return { requestedBackend, effectiveBackend: "none", effectiveModel: "unavailable", reason: "No Micme transcription backend found.", warnings };
167
194
  }
168
195
 
@@ -178,6 +205,16 @@ function printBackendPlanDiagnostics(plan) {
178
205
  } else if (plan.effectiveBackend === "python") info("effective model", plan.effectiveModel);
179
206
  else info("effective model", "unavailable");
180
207
 
208
+ const translateLanguage = getTranslateToEnglishLanguage();
209
+ if (translateLanguage) {
210
+ ok("translation", `${translateLanguage} -> English`);
211
+ if (plan.effectiveBackend === "custom") warn("translation backend", "custom transcribe commands must implement translation themselves");
212
+ if (plan.effectiveBackend === "whisper.cpp" && isEnglishOnlyWhisperModelName(plan.model?.modelName)) warn("translation model", `${plan.model.modelName} appears to be English-only; use a multilingual model`);
213
+ if (plan.effectiveBackend === "python" && isEnglishOnlyWhisperModelName(plan.effectiveModel)) warn("translation model", `${plan.effectiveModel} appears to be English-only; use a multilingual model`);
214
+ } else {
215
+ info("translation", "off");
216
+ }
217
+
181
218
  for (const warning of plan.warnings) warn("backend warning", warning);
182
219
  }
183
220
 
@@ -229,7 +266,7 @@ async function main() {
229
266
  warn("MICME_WHISPER_CPP_MODEL is set but not readable", auto ? `${whisperCppModel} (Micme will try to download if it is a standard ggml model path)` : whisperCppModel);
230
267
  }
231
268
  } else {
232
- const defaultModel = env("MICME_DEFAULT_WHISPER_CPP_MODEL") || "small.en";
269
+ const defaultModel = getTranslationAwareWhisperModelName(env("MICME_DEFAULT_WHISPER_CPP_MODEL") || "small.en");
233
270
  const modelDir = expandConfigValue(env("MICME_MODEL_DIR") || join(homedir(), ".cache", "whisper.cpp"));
234
271
  info("MICME_WHISPER_CPP_MODEL", `not set; Micme defaults to ${modelDir}/ggml-${defaultModel}.bin and auto-downloads when needed`);
235
272
  }
@@ -250,7 +287,7 @@ async function main() {
250
287
 
251
288
  console.log("\nRecommended macOS setup:");
252
289
  console.log(" brew install ffmpeg whisper-cpp");
253
- console.log(" # Then use /micme conf, or let Micme auto-download ggml-small.en.bin on first use.");
290
+ console.log(" # Then use /micme conf, or let Micme auto-download the default model on first use.");
254
291
 
255
292
  if (process.platform === "darwin" && ffmpeg) {
256
293
  console.log("\nmacOS microphone devices:");
package/src/audio.ts CHANGED
@@ -2,7 +2,7 @@ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-a
2
2
  import { sliceByColumn, visibleWidth, type Component } from "@earendil-works/pi-tui";
3
3
  import { join } from "node:path";
4
4
  import { AUDIO_VALIDATION_TIMEOUT_MS } from "./constants.ts";
5
- import { env, envFlag, getAudioFilter, getMinMaxVolumeDb, getRecordSampleRate, getTranscribeSampleRate } from "./config.ts";
5
+ import { env, envFlag, getAudioFilter, getAvfoundationDropLateFrames, getAvfoundationInputSampleRate, getMinMaxVolumeDb, getRecordMeter, getRecordSampleRate, getRecordSync, getTranscribeSampleRate } from "./config.ts";
6
6
  import { findExecutable, formatRunExit, replacePlaceholders, runProcess, shellCommand, shellQuote } from "./processes.ts";
7
7
  import type { AudioDeviceCandidate, AudioDiagnostics, CommandSpec, RunResult } from "./types.ts";
8
8
 
@@ -58,6 +58,7 @@ const DEVICE_PANEL_MESSAGE_TYPE = "micme-devices";
58
58
  const DEVICE_PANEL_DEFAULT_WIDTH = 92;
59
59
  const DEVICE_PANEL_MAX_WIDTH = 100;
60
60
  const DEVICE_PANEL_MIN_WIDTH = 36;
61
+ const RECORD_TIMING_SYNC_FILTER = "aresample=async=1:first_pts=0";
61
62
 
62
63
  let deviceMessageRendererRegistered = false;
63
64
 
@@ -337,7 +338,11 @@ function sendDevicePanelMessage(pi: ExtensionAPI | undefined, options: DevicePan
337
338
  }
338
339
 
339
340
  class DevicePanelMessageComponent implements Component {
340
- constructor(private readonly options: DevicePanelOptions) {}
341
+ private readonly options: DevicePanelOptions;
342
+
343
+ constructor(options: DevicePanelOptions) {
344
+ this.options = options;
345
+ }
341
346
 
342
347
  render(width: number): string[] {
343
348
  return renderDevicePanel(this.options, Math.min(width, DEVICE_PANEL_MAX_WIDTH)).split("\n");
@@ -644,31 +649,45 @@ export function buildRecorderCommand(audioPath: string): CommandSpec {
644
649
  throw new Error("Micme needs ffmpeg for recording, or set MICME_RECORD_COMMAND.");
645
650
  }
646
651
 
647
- const recordSampleRate = String(getRecordSampleRate());
652
+ const recordSampleRate = getRecordSampleRate()?.toString();
653
+ const recordMeter = getRecordMeter();
654
+ const recordSync = getRecordSync();
655
+ const timingFilters = recordSync ? [RECORD_TIMING_SYNC_FILTER] : [];
648
656
 
649
657
  if (process.platform === "darwin") {
650
658
  const input = env("MICME_AVFOUNDATION_INPUT") || `:${env("MICME_AUDIO_DEVICE") || "0"}`;
651
- const args = buildMeteredFfmpegRecorderArgs("avfoundation", input, audioPath, recordSampleRate);
652
- return { command: ffmpeg, args, display: `${ffmpeg} ${args.map(shellQuote).join(" ")}`, meterFromStdout: true, stopInput: "q\n" };
659
+ const avfoundationInputSampleRate = getAvfoundationInputSampleRate();
660
+ const args = buildFfmpegRecorderArgs("avfoundation", input, audioPath, recordSampleRate, {
661
+ meter: recordMeter,
662
+ inputOptions: ["-drop_late_frames", getAvfoundationDropLateFrames() ? "true" : "false"],
663
+ audioFilters: recordSync ? timingFilters : avfoundationInputSampleRate ? [`asetrate=${avfoundationInputSampleRate}`] : [],
664
+ });
665
+ return { command: ffmpeg, args, display: `${ffmpeg} ${args.map(shellQuote).join(" ")}`, meterFromStdout: recordMeter, stopInput: "q\n" };
653
666
  }
654
667
 
655
668
  if (process.platform === "linux") {
656
669
  const input = env("MICME_PULSE_SOURCE") || "default";
657
- const args = buildMeteredFfmpegRecorderArgs("pulse", input, audioPath, recordSampleRate);
658
- return { command: ffmpeg, args, display: `${ffmpeg} ${args.map(shellQuote).join(" ")}`, meterFromStdout: true, stopInput: "q\n" };
670
+ const args = buildFfmpegRecorderArgs("pulse", input, audioPath, recordSampleRate, { meter: recordMeter, audioFilters: timingFilters });
671
+ return { command: ffmpeg, args, display: `${ffmpeg} ${args.map(shellQuote).join(" ")}`, meterFromStdout: recordMeter, stopInput: "q\n" };
659
672
  }
660
673
 
661
674
  if (process.platform === "win32") {
662
675
  const input = `audio=${env("MICME_DSHOW_AUDIO_DEVICE") || "default"}`;
663
- const args = buildMeteredFfmpegRecorderArgs("dshow", input, audioPath, recordSampleRate);
664
- return { command: ffmpeg, args, display: `${ffmpeg} ${args.map(shellQuote).join(" ")}`, meterFromStdout: true, stopInput: "q\n" };
676
+ const args = buildFfmpegRecorderArgs("dshow", input, audioPath, recordSampleRate, { meter: recordMeter, audioFilters: timingFilters });
677
+ return { command: ffmpeg, args, display: `${ffmpeg} ${args.map(shellQuote).join(" ")}`, meterFromStdout: recordMeter, stopInput: "q\n" };
665
678
  }
666
679
 
667
680
  throw new Error(`Micme has no default recorder for ${process.platform}. Set MICME_RECORD_COMMAND.`);
668
681
  }
669
682
 
670
- export function buildMeteredFfmpegRecorderArgs(inputFormat: string, input: string, audioPath: string, recordSampleRate: string) {
671
- return [
683
+ type FfmpegRecorderOptions = {
684
+ meter?: boolean;
685
+ inputOptions?: string[];
686
+ audioFilters?: string[];
687
+ };
688
+
689
+ export function buildFfmpegRecorderArgs(inputFormat: string, input: string, audioPath: string, recordSampleRate: string | undefined, options: FfmpegRecorderOptions = {}) {
690
+ const inputArgs = [
672
691
  "-hide_banner",
673
692
  "-loglevel",
674
693
  "error",
@@ -676,21 +695,28 @@ export function buildMeteredFfmpegRecorderArgs(inputFormat: string, input: strin
676
695
  "4096",
677
696
  "-f",
678
697
  inputFormat,
698
+ ...(options.inputOptions ?? []),
679
699
  "-i",
680
700
  input,
701
+ ];
702
+ const fileOutputArgs = ["-ac", "1", ...formatOptionalSampleRateArgs(recordSampleRate), "-c:a", "pcm_s16le", "-vn", "-y", audioPath];
703
+ const audioFilters = (options.audioFilters ?? []).filter(Boolean);
704
+
705
+ if (options.meter === false && audioFilters.length === 0) {
706
+ return [...inputArgs, "-map", "0:a:0", ...fileOutputArgs];
707
+ }
708
+
709
+ if (options.meter === false) {
710
+ return [...inputArgs, "-filter_complex", buildFileOnlyAudioFilterGraph(audioFilters), "-map", "[micme_file]", ...fileOutputArgs];
711
+ }
712
+
713
+ return [
714
+ ...inputArgs,
681
715
  "-filter_complex",
682
- "[0:a]asplit=2[micme_file][micme_meter]",
716
+ buildMeteredAudioFilterGraph(audioFilters),
683
717
  "-map",
684
718
  "[micme_file]",
685
- "-ac",
686
- "1",
687
- "-ar",
688
- recordSampleRate,
689
- "-c:a",
690
- "pcm_s16le",
691
- "-vn",
692
- "-y",
693
- audioPath,
719
+ ...fileOutputArgs,
694
720
  "-map",
695
721
  "[micme_meter]",
696
722
  "-ac",
@@ -702,3 +728,20 @@ export function buildMeteredFfmpegRecorderArgs(inputFormat: string, input: strin
702
728
  "pipe:1",
703
729
  ];
704
730
  }
731
+
732
+ export function buildMeteredFfmpegRecorderArgs(inputFormat: string, input: string, audioPath: string, recordSampleRate: string | undefined) {
733
+ return buildFfmpegRecorderArgs(inputFormat, input, audioPath, recordSampleRate, { meter: true });
734
+ }
735
+
736
+ function formatOptionalSampleRateArgs(recordSampleRate: string | undefined) {
737
+ return recordSampleRate ? ["-ar", recordSampleRate] : [];
738
+ }
739
+
740
+ function buildFileOnlyAudioFilterGraph(audioFilters: string[]) {
741
+ return audioFilters.length > 0 ? `[0:a]${audioFilters.join(",")}[micme_file]` : "[0:a]anull[micme_file]";
742
+ }
743
+
744
+ function buildMeteredAudioFilterGraph(audioFilters: string[]) {
745
+ const prefix = audioFilters.length > 0 ? `${audioFilters.join(",")},` : "";
746
+ return `[0:a]${prefix}asplit=2[micme_file][micme_meter]`;
747
+ }
package/src/backends.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import type { TranscribeBackend, TranscriptionMode, ResolvedTranscriptionPlan, ResolvedWhisperCppModel } from "./types.ts";
3
3
  import { DEFAULT_TRANSCRIBE_BACKEND } from "./constants.ts";
4
- import { env, expandConfigPath, getTranscribeBackend, isTranscribeBackend } from "./config.ts";
5
- import { getPythonWhisperModelName, resolveWhisperCppModel } from "./models.ts";
4
+ import { env, expandConfigPath, getTranscribeBackend, getTranslateToEnglishLanguage, isTranscribeBackend } from "./config.ts";
5
+ import { getPythonWhisperModelName, isEnglishOnlyWhisperModelName, isTranslationUnsupportedWhisperModelName, resolveWhisperCppModel } from "./models.ts";
6
6
  import { findExecutable } from "./processes.ts";
7
7
 
8
8
  export type ResolveTranscriptionPlanOptions = {
@@ -174,6 +174,10 @@ function whisperCppPlan(requestedBackend: TranscribeBackend, binary: string, mod
174
174
  } else if (!model.exists && !model.downloadable) {
175
175
  warnings.push(`Whisper.cpp model is missing and is not a standard downloadable model: ${model.path}`);
176
176
  }
177
+ if (model.translationFallbackFrom && model.modelName) {
178
+ warnings.push(`Translation to English uses ${model.modelName} instead of ${model.translationFallbackFrom} because the selected model does not support translation.`);
179
+ }
180
+ warnings.push(...getTranslationModelWarnings(model.modelName));
177
181
  return {
178
182
  requestedBackend,
179
183
  effectiveBackend: "whisper.cpp",
@@ -195,10 +199,17 @@ function pythonPlan(requestedBackend: TranscribeBackend, binary: string, modelNa
195
199
  binary,
196
200
  modelName,
197
201
  modelSource: "python-name",
198
- warnings: [],
202
+ warnings: getTranslationModelWarnings(modelName),
199
203
  };
200
204
  }
201
205
 
206
+ function getTranslationModelWarnings(modelName: string | undefined) {
207
+ if (!getTranslateToEnglishLanguage()) return [];
208
+ if (isEnglishOnlyWhisperModelName(modelName)) return [`Translation to English requires a multilingual Whisper model; ${modelName} appears to be English-only.`];
209
+ if (isTranslationUnsupportedWhisperModelName(modelName)) return [`Translation to English is not supported by ${modelName}; choose large-v3 or another multilingual translate-capable model.`];
210
+ return [];
211
+ }
212
+
202
213
  function nonePlan(requestedBackend: TranscribeBackend, reason: string, warnings: string[]): ResolvedTranscriptionPlan {
203
214
  return {
204
215
  requestedBackend,