@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/src/settings.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import { DynamicBorder, type ExtensionContext } from "@earendil-works/pi-coding-agent";
2
2
  import {
3
3
  Container,
4
+ decodeKittyPrintable,
4
5
  fuzzyFilter,
5
6
  Key,
6
7
  matchesKey,
8
+ parseKey,
7
9
  type Component,
8
10
  type SelectItem,
9
11
  SelectList,
@@ -14,9 +16,7 @@ import {
14
16
  } from "@earendil-works/pi-tui";
15
17
  import { basename } from "node:path";
16
18
  import {
17
- DEFAULT_MACOS_PRINTABLE_SHORTCUT,
18
19
  DEFAULT_RECORD_SAMPLE_RATE,
19
- DEFAULT_SHORTCUT,
20
20
  DEFAULT_STREAM_VAD_THRESHOLD,
21
21
  DEFAULT_STREAM_FLUSH_MS,
22
22
  DEFAULT_TRANSCRIBE_SAMPLE_RATE,
@@ -24,6 +24,7 @@ import {
24
24
  import {
25
25
  env,
26
26
  expandConfigPath,
27
+ getShortcutSettingValue,
27
28
  getTranscriptionMode,
28
29
  getTranscriptionModeProfile,
29
30
  reloadMicmeConfig,
@@ -31,7 +32,7 @@ import {
31
32
  } from "./config.ts";
32
33
  import { discoverAudioDevices } from "./audio.ts";
33
34
  import { formatBackendLabel, resolveTranscriptionPlan } from "./backends.ts";
34
- import { discoverPythonWhisperModels, discoverWhisperCppModels, ensureWhisperCppModel, resolveWhisperCppModel } from "./models.ts";
35
+ import { discoverPythonWhisperModels, discoverWhisperCppModels, ensureWhisperCppModel, getPythonWhisperModelName, resolveWhisperCppModel } from "./models.ts";
35
36
  import { findExecutable } from "./processes.ts";
36
37
  import type { AudioDeviceCandidate, ModelCandidate, ResolvedTranscriptionPlan } from "./types.ts";
37
38
 
@@ -65,6 +66,27 @@ const CONFIGURATION_CATEGORIES: ConfigurationCategory[] = [
65
66
 
66
67
  const TWO_PANE_MIN_WIDTH = 72;
67
68
  const MAX_SETTINGS_ROWS = 10;
69
+ const LANGUAGE_LABELS: Record<string, string> = {
70
+ auto: "Auto detect",
71
+ en: "English",
72
+ bs: "Bosnian",
73
+ hr: "Croatian",
74
+ sr: "Serbian",
75
+ de: "German",
76
+ es: "Spanish",
77
+ fr: "French",
78
+ it: "Italian",
79
+ pt: "Portuguese",
80
+ nl: "Dutch",
81
+ pl: "Polish",
82
+ tr: "Turkish",
83
+ };
84
+ const TRANSCRIPTION_LANGUAGE_VALUES = ["en", "auto", "bs", "hr", "sr", "de", "es", "fr", "it", "pt", "nl", "pl", "tr"];
85
+ const TRANSLATION_SOURCE_LANGUAGE_VALUES = ["bs", "hr", "sr", "de", "es", "fr", "it", "pt", "nl", "pl", "tr"];
86
+ const TRANSLATE_FROM_VALUE_LABELS: Record<string, string> = {
87
+ off: "Off",
88
+ ...Object.fromEntries(TRANSLATION_SOURCE_LANGUAGE_VALUES.map((language) => [language, `${LANGUAGE_LABELS[language] ?? language} → English`])),
89
+ };
68
90
 
69
91
  export async function showConfiguration(ctx: ExtensionContext) {
70
92
  if (ctx.mode !== "tui") {
@@ -109,6 +131,8 @@ class ConfigurationScreen implements Component {
109
131
  private searchQuery = "";
110
132
  private selectedSearchIndex = 0;
111
133
  private submenuComponent: Component | null = null;
134
+ private editingShortcutItem: ConfigurationItem | null = null;
135
+ private pendingShortcutValue = "";
112
136
  private saving = false;
113
137
  private statusText = "";
114
138
 
@@ -148,6 +172,11 @@ class ConfigurationScreen implements Component {
148
172
  return;
149
173
  }
150
174
 
175
+ if (this.editingShortcutItem) {
176
+ this.handleShortcutCaptureInput(data);
177
+ return;
178
+ }
179
+
151
180
  if (matchesKey(data, Key.ctrl("c")) || data === "q" || data === "Q") {
152
181
  this.onDone();
153
182
  return;
@@ -348,6 +377,10 @@ class ConfigurationScreen implements Component {
348
377
  const selected = this.getSelectedSetting();
349
378
  const category = this.currentCategory();
350
379
  const selection = this.getSelectionText();
380
+ if (this.editingShortcutItem) {
381
+ const hint = this.pendingShortcutValue ? `Captured ${this.pendingShortcutValue} • Enter save • Esc cancel` : "Press desired key or key combination • Enter save • Esc cancel";
382
+ return `${selection} • ${this.statusText || hint}`;
383
+ }
351
384
  const search = this.searchActive ? `Search: ${this.searchQuery || "type to filter all settings"}` : "";
352
385
  const lead = this.statusText || search;
353
386
  const description = selected?.description ?? category.description;
@@ -356,6 +389,7 @@ class ConfigurationScreen implements Component {
356
389
 
357
390
  private formatValue(item: ConfigurationItem, width: number) {
358
391
  if (width <= 0) return "";
392
+ if (this.editingShortcutItem?.id === item.id) return this.pendingShortcutValue ? this.theme.fg("accent", fitAnsi(this.pendingShortcutValue, width)) : "";
359
393
  const raw = item.rawValue;
360
394
  if (!raw) return this.theme.fg("dim", fitAnsi(item.emptyLabel ?? displayConfigurationValue(item.id, raw), width));
361
395
 
@@ -465,6 +499,11 @@ class ConfigurationScreen implements Component {
465
499
  const item = displayItems[this.getSelectedSettingIndex(displayItems.length)];
466
500
  if (!item) return;
467
501
 
502
+ if (item.id === "MICME_SHORTCUT") {
503
+ this.startShortcutCapture(item);
504
+ return;
505
+ }
506
+
468
507
  if (item.submenu) {
469
508
  this.submenuComponent = item.submenu(item.rawValue, (selectedValue?: string) => {
470
509
  this.submenuComponent = null;
@@ -480,6 +519,50 @@ class ConfigurationScreen implements Component {
480
519
  this.saveSetting(item, nextValue);
481
520
  }
482
521
 
522
+ private startShortcutCapture(item: ConfigurationItem) {
523
+ this.editingShortcutItem = item;
524
+ this.pendingShortcutValue = "";
525
+ this.statusText = "";
526
+ this.requestRender();
527
+ }
528
+
529
+ private handleShortcutCaptureInput(data: string) {
530
+ const item = this.editingShortcutItem;
531
+ if (!item) return;
532
+
533
+ if (matchesKey(data, Key.escape)) {
534
+ this.editingShortcutItem = null;
535
+ this.pendingShortcutValue = "";
536
+ this.statusText = "";
537
+ this.requestRender();
538
+ return;
539
+ }
540
+
541
+ if (matchesKey(data, Key.enter)) {
542
+ if (!this.pendingShortcutValue) {
543
+ this.statusText = "Press a shortcut before confirming";
544
+ this.requestRender();
545
+ return;
546
+ }
547
+ const nextValue = this.pendingShortcutValue;
548
+ this.editingShortcutItem = null;
549
+ this.pendingShortcutValue = "";
550
+ this.saveSetting(item, nextValue);
551
+ return;
552
+ }
553
+
554
+ const captured = getShortcutInput(data);
555
+ if (!captured) {
556
+ this.statusText = "Shortcut input not recognized";
557
+ this.requestRender();
558
+ return;
559
+ }
560
+
561
+ this.pendingShortcutValue = captured;
562
+ this.statusText = "";
563
+ this.requestRender();
564
+ }
565
+
483
566
  private saveSetting(item: ConfigurationItem, nextValue: string) {
484
567
  this.saving = true;
485
568
  this.statusText = `Saving ${item.id}…`;
@@ -525,6 +608,12 @@ class ConfigurationScreen implements Component {
525
608
  model.currentValue = displayConfigurationValue(model.id, model.rawValue);
526
609
  }
527
610
 
611
+ const pythonModel = this.items.find((candidate) => candidate.id === "MICME_WHISPER_MODEL");
612
+ if (pythonModel) {
613
+ pythonModel.rawValue = getPythonWhisperModelName();
614
+ pythonModel.currentValue = pythonModel.rawValue;
615
+ }
616
+
528
617
  const mode = this.items.find((candidate) => candidate.id === "MICME_TRANSCRIPTION_MODE");
529
618
  if (mode) {
530
619
  const base = "Changing this applies the matching profile: stable clip defaults or low-latency stream settings.";
@@ -603,14 +692,16 @@ export function buildConfigurationItems(
603
692
  const whisperCppBinValues = uniqueStrings([env("MICME_WHISPER_CPP_BIN") ?? "", findExecutable(["whisper-cli"]) ?? "", findExecutable(["whisper-cpp"]) ?? "", "whisper-cli", "whisper-cpp"]);
604
693
  const whisperStreamBinValues = uniqueStrings([env("MICME_WHISPER_STREAM_BIN") ?? "", findExecutable(["whisper-stream"]) ?? "", "whisper-stream"]);
605
694
  const audioFilter = env("MICME_AUDIO_FILTER") ?? "highpass=f=80,lowpass=f=7600";
606
- const macosPrintableShortcut = env("MICME_PRINTABLE_SHORTCUTS") ?? (process.platform === "darwin" ? DEFAULT_MACOS_PRINTABLE_SHORTCUT : "");
695
+ const shortcut = getShortcutSettingValue();
696
+ const translateToEnglish = env("MICME_TRANSLATE_TO_ENGLISH") ?? "off";
607
697
  const plan = resolveTranscriptionPlan({ transcriptionMode: getTranscriptionMode() });
608
698
  const backendValues = ["whisper.cpp", "python"] as const;
609
699
  const backendLabels = Object.fromEntries(backendValues.map((value) => [value, formatBackendLabel(value)]));
610
700
  const uiBackendValue = getUiBackendValue(plan);
611
701
  const whisperCppVisible = (candidate: ResolvedTranscriptionPlan) => getUiBackendValue(candidate) === "whisper.cpp";
612
702
  const pythonVisible = (candidate: ResolvedTranscriptionPlan) => getUiBackendValue(candidate) === "python";
613
- const pythonModelValues = uniqueStrings([env("MICME_WHISPER_MODEL") ?? "base.en", ...pythonModelCandidates.map((candidate) => candidate.value)]);
703
+ const currentPythonModel = getPythonWhisperModelName();
704
+ const pythonModelValues = uniqueStrings([currentPythonModel, env("MICME_WHISPER_MODEL") ?? "", ...pythonModelCandidates.map((candidate) => candidate.value)]);
614
705
  const pythonModelLabels = Object.fromEntries(pythonModelCandidates.map((candidate) => [candidate.value, candidate.label]));
615
706
  const modelPathCandidates = [{ label: "Use default model", value: "", description: "Clear explicit path override and use Micme's default whisper.cpp model path.", installed: true, kind: "path" as const }, ...modelCandidates];
616
707
 
@@ -629,10 +720,22 @@ export function buildConfigurationItems(
629
720
  id: "MICME_LANGUAGE",
630
721
  categoryId: "general",
631
722
  label: "Language",
632
- description: "Use a fixed language for accuracy/speed, or auto for detection.",
723
+ description: "Transcription language when translation is off. Use auto for detection.",
633
724
  rawValue: env("MICME_LANGUAGE") ?? "en",
634
725
  currentValue: env("MICME_LANGUAGE") ?? "en",
635
- values: ["en", "auto", "bs", "hr", "sr", "de", "es", "fr", "it", "pt", "nl", "pl", "tr"],
726
+ values: [...TRANSCRIPTION_LANGUAGE_VALUES],
727
+ valueLabels: LANGUAGE_LABELS,
728
+ displayKind: "text",
729
+ },
730
+ {
731
+ id: "MICME_TRANSLATE_TO_ENGLISH",
732
+ categoryId: "general",
733
+ label: "Translate from",
734
+ description: "Off by default. Choose the spoken source language to output English.",
735
+ rawValue: translateToEnglish,
736
+ currentValue: translateToEnglish,
737
+ values: ["off", ...TRANSLATION_SOURCE_LANGUAGE_VALUES],
738
+ valueLabels: TRANSLATE_FROM_VALUE_LABELS,
636
739
  displayKind: "text",
637
740
  },
638
741
  {
@@ -685,8 +788,8 @@ export function buildConfigurationItems(
685
788
  categoryId: "transcription",
686
789
  label: "Model",
687
790
  description: "Model name passed to the OpenAI Whisper Python CLI.",
688
- rawValue: env("MICME_WHISPER_MODEL") ?? "base.en",
689
- currentValue: env("MICME_WHISPER_MODEL") ?? "base.en",
791
+ rawValue: currentPythonModel,
792
+ currentValue: currentPythonModel,
690
793
  values: pythonModelValues,
691
794
  valueLabels: pythonModelLabels,
692
795
  displayKind: "text",
@@ -778,12 +881,22 @@ export function buildConfigurationItems(
778
881
  {
779
882
  id: "MICME_RECORD_SAMPLE_RATE",
780
883
  categoryId: "audio",
781
- label: "Record sample rate",
782
- description: "Raw recording sample rate. 48000 is usually best for macOS devices.",
884
+ label: "Sample rate override",
885
+ description: "Advanced. Leave auto so ffmpeg uses the selected input's native sample rate.",
783
886
  rawValue: env("MICME_RECORD_SAMPLE_RATE") ?? String(DEFAULT_RECORD_SAMPLE_RATE),
784
887
  currentValue: env("MICME_RECORD_SAMPLE_RATE") ?? String(DEFAULT_RECORD_SAMPLE_RATE),
785
- values: ["48000", "44100", "16000"],
786
- displayKind: "number",
888
+ values: ["auto", "48000", "44100", "16000", "96000"],
889
+ displayKind: "text",
890
+ },
891
+ {
892
+ id: "MICME_RECORD_SYNC",
893
+ categoryId: "audio",
894
+ label: "Record timing sync",
895
+ description: "Automatically preserve wall-clock recording duration from ffmpeg timestamps. Keep on unless debugging recorder timing.",
896
+ rawValue: env("MICME_RECORD_SYNC") ?? "1",
897
+ currentValue: env("MICME_RECORD_SYNC") ?? "1",
898
+ values: ["1", "0"],
899
+ displayKind: "boolean",
787
900
  },
788
901
  {
789
902
  id: "MICME_TRANSCRIBE_SAMPLE_RATE",
@@ -795,6 +908,30 @@ export function buildConfigurationItems(
795
908
  values: ["16000", "48000", "44100"],
796
909
  displayKind: "number",
797
910
  },
911
+ {
912
+ id: "MICME_RECORD_METER",
913
+ categoryId: "audio",
914
+ label: "Live meter pipe",
915
+ description: "Stream a second PCM branch from ffmpeg for the waveform meter. Leave off if recordings crackle or sound shortened.",
916
+ rawValue: env("MICME_RECORD_METER") ?? "0",
917
+ currentValue: env("MICME_RECORD_METER") ?? "0",
918
+ values: ["0", "1"],
919
+ displayKind: "boolean",
920
+ },
921
+ ...(process.platform === "darwin"
922
+ ? [
923
+ {
924
+ id: "MICME_AVFOUNDATION_DROP_LATE_FRAMES",
925
+ categoryId: "audio" as const,
926
+ label: "AVF drop late frames",
927
+ description: "macOS only. Keep off to preserve audio timing when devices or virtual routes lag.",
928
+ rawValue: env("MICME_AVFOUNDATION_DROP_LATE_FRAMES") ?? "0",
929
+ currentValue: env("MICME_AVFOUNDATION_DROP_LATE_FRAMES") ?? "0",
930
+ values: ["0", "1"],
931
+ displayKind: "boolean" as const,
932
+ },
933
+ ]
934
+ : []),
798
935
  {
799
936
  id: "MICME_AUDIO_FILTER",
800
937
  categoryId: "audio",
@@ -840,7 +977,7 @@ export function buildConfigurationItems(
840
977
  id: "MICME_KEEP_AUDIO",
841
978
  categoryId: "audio",
842
979
  label: "Keep audio",
843
- description: "Keep raw.wav and clip.wav in /tmp after successful transcription for debugging.",
980
+ description: "Keep raw.wav and clip.wav under ./micme-rec/rec-###/ after successful transcription for debugging.",
844
981
  rawValue: env("MICME_KEEP_AUDIO") ?? "0",
845
982
  currentValue: env("MICME_KEEP_AUDIO") ?? "0",
846
983
  values: ["0", "1"],
@@ -849,21 +986,10 @@ export function buildConfigurationItems(
849
986
  {
850
987
  id: "MICME_SHORTCUT",
851
988
  categoryId: "general",
852
- label: "Terminal shortcut",
853
- description: "Shortcut when your terminal sends real Alt/Ctrl keys. Requires /reload or restart after changing.",
854
- rawValue: env("MICME_SHORTCUT") ?? DEFAULT_SHORTCUT,
855
- currentValue: env("MICME_SHORTCUT") ?? DEFAULT_SHORTCUT,
856
- values: ["alt+m", "ctrl+shift+m", "ctrl+space", "f8", "f9"],
857
- displayKind: "text",
858
- },
859
- {
860
- id: "MICME_PRINTABLE_SHORTCUTS",
861
- categoryId: "general",
862
- label: "macOS printable shortcut",
863
- description: "Toggle-only fallback for terminals where Option+M inserts a character instead of sending Alt+M. Use /reload after changing.",
864
- rawValue: macosPrintableShortcut,
865
- currentValue: displayConfigurationValue("MICME_PRINTABLE_SHORTCUTS", macosPrintableShortcut),
866
- values: [DEFAULT_MACOS_PRINTABLE_SHORTCUT, "µ", ""],
989
+ label: "Shortcut",
990
+ description: "Press Enter, then press the desired key or key combination, and press Enter again to confirm.",
991
+ rawValue: shortcut,
992
+ currentValue: displayConfigurationValue("MICME_SHORTCUT", shortcut),
867
993
  displayKind: "text",
868
994
  emptyLabel: "not set",
869
995
  },
@@ -921,7 +1047,7 @@ export function createModelSelector(candidates: ModelCandidate[], theme: MicmeTh
921
1047
  export async function saveConfigurationValue(ctx: ExtensionContext, id: string, value: string): Promise<Record<string, string>> {
922
1048
  if (!id.startsWith("MICME_")) return {};
923
1049
 
924
- const valuesToWrite = id === "MICME_TRANSCRIPTION_MODE" ? getTranscriptionModeProfile(value === "stream" ? "stream" : "clip") : { [id]: value };
1050
+ const valuesToWrite = getConfigurationValuesToWrite(id, value);
925
1051
  if (id === "MICME_WHISPER_CPP_MODEL" && value) {
926
1052
  await ensureWhisperCppModel(expandConfigPath(value), ctx);
927
1053
  }
@@ -947,8 +1073,7 @@ function getUiBackendValue(plan: ResolvedTranscriptionPlan): "whisper.cpp" | "py
947
1073
  }
948
1074
 
949
1075
  function getCurrentWhisperCppModelValue() {
950
- const explicit = env("MICME_WHISPER_CPP_MODEL")?.trim();
951
- return explicit ? expandConfigPath(explicit) : resolveWhisperCppModel().path;
1076
+ return resolveWhisperCppModel().path;
952
1077
  }
953
1078
 
954
1079
  export function uniqueStrings(values: string[]) {
@@ -963,13 +1088,19 @@ export function uniqueStrings(values: string[]) {
963
1088
  return output.length > 0 ? output : [""];
964
1089
  }
965
1090
 
1091
+ function getConfigurationValuesToWrite(id: string, value: string) {
1092
+ if (id === "MICME_TRANSCRIPTION_MODE") return getTranscriptionModeProfile(value === "stream" ? "stream" : "clip");
1093
+ if (id === "MICME_SHORTCUT") return { MICME_SHORTCUT: value, MICME_PRINTABLE_SHORTCUTS: undefined };
1094
+ return { [id]: value };
1095
+ }
1096
+
966
1097
  function formatSaveStatus(id: string, value: string) {
967
- const writtenKeys = id === "MICME_TRANSCRIPTION_MODE" ? Object.keys(getTranscriptionModeProfile(value === "stream" ? "stream" : "clip")) : [id];
1098
+ const writtenKeys = Object.keys(getConfigurationValuesToWrite(id, value));
968
1099
  const overriddenKeys = writtenKeys.filter((key) => process.env[key] !== undefined);
969
1100
  const reloadHint = id === "MICME_SHORTCUT" ? "/reload required for shortcut changes" : id === "MICME_PRINTABLE_SHORTCUTS" ? "/reload recommended for printable shortcuts" : "";
970
1101
 
971
1102
  if (id === "MICME_TRANSCRIPTION_MODE" && overriddenKeys.length) return `Shell env still overrides ${overriddenKeys.join(", ")}`;
972
- if (overriddenKeys.includes(id)) return reloadHint ? `Shell env still overrides ${id} • ${reloadHint}` : `Shell env still overrides ${id}`;
1103
+ if (overriddenKeys.length) return reloadHint ? `Shell env still overrides ${overriddenKeys.join(", ")} • ${reloadHint}` : `Shell env still overrides ${overriddenKeys.join(", ")}`;
973
1104
  return reloadHint;
974
1105
  }
975
1106
 
@@ -1015,6 +1146,12 @@ function isTruthyConfigValue(value: string) {
1015
1146
  return /^(1|true|yes|on)$/i.test(value);
1016
1147
  }
1017
1148
 
1149
+ function getShortcutInput(data: string) {
1150
+ const parsed = parseKey(data);
1151
+ if (parsed && parsed !== "enter" && parsed !== "escape" && parsed !== "esc") return parsed;
1152
+ return decodeKittyPrintable(data) ?? getPrintableInput(data);
1153
+ }
1154
+
1018
1155
  function getPrintableInput(data: string) {
1019
1156
  if (!data || data.includes("\x1b")) return "";
1020
1157
  if (matchesKey(data, Key.space)) return " ";
package/src/streaming.ts CHANGED
@@ -3,6 +3,7 @@ import { MAX_CAPTURED_OUTPUT_CHARS } from "./constants.ts";
3
3
  import {
4
4
  env,
5
5
  envFlag,
6
+ getTranslateToEnglishLanguage,
6
7
  getStreamFlushMs,
7
8
  getStreamKeepContext,
8
9
  getStreamKeepMs,
@@ -54,8 +55,13 @@ export function buildWhisperStreamCommand(binary: string, modelPath: string, tem
54
55
  const capture = env("MICME_STREAM_CAPTURE");
55
56
  if (capture?.trim()) args.push("--capture", capture.trim());
56
57
 
57
- const language = env("MICME_LANGUAGE");
58
- if (language?.trim()) args.push("-l", language.trim());
58
+ const translateLanguage = getTranslateToEnglishLanguage();
59
+ if (translateLanguage) {
60
+ args.push("-tr", "-l", translateLanguage);
61
+ } else {
62
+ const language = env("MICME_LANGUAGE");
63
+ if (language?.trim()) args.push("-l", language.trim());
64
+ }
59
65
 
60
66
  return { command: binary, args, display: `${binary} ${args.map(shellQuote).join(" ")}` };
61
67
  }
@@ -3,8 +3,8 @@ import { existsSync } from "node:fs";
3
3
  import { readFile } from "node:fs/promises";
4
4
  import { basename, join } from "node:path";
5
5
  import { resolveTranscriptionPlan, formatTranscriptionPlan } from "./backends.ts";
6
- import { env, getTranscribeTimeoutMs } from "./config.ts";
7
- import { ensureWhisperCppModel } from "./models.ts";
6
+ import { env, getTranscribeTimeoutMs, getTranslateToEnglishLanguage } from "./config.ts";
7
+ import { ensureWhisperCppModel, getPythonWhisperModelName } from "./models.ts";
8
8
  import { formatRunExit, replacePlaceholders, runProcess, runShell } from "./processes.ts";
9
9
 
10
10
  export { getWhisperCppBinary, getWhisperStreamBinary, resolveExecutableConfig } from "./backends.ts";
@@ -56,8 +56,13 @@ export async function transcribeWithWhisperCpp(
56
56
  await ensureWhisperCppModel(modelPath, ctx, options);
57
57
  const outputBase = join(tempDir, "whisper-cpp");
58
58
  const args = ["-m", modelPath, "-f", audioPath, "-otxt", "-of", outputBase, "-nt", "-np", "-nf", "-sns"];
59
- const language = env("MICME_LANGUAGE");
60
- if (language?.trim()) args.push("-l", language.trim());
59
+ const translateLanguage = getTranslateToEnglishLanguage();
60
+ if (translateLanguage) {
61
+ args.push("-tr", "-l", translateLanguage);
62
+ } else {
63
+ const language = env("MICME_LANGUAGE");
64
+ if (language?.trim()) args.push("-l", language.trim());
65
+ }
61
66
 
62
67
  const result = await runProcess(binary, args, getTranscribeTimeoutMs());
63
68
  if (result.code !== 0) {
@@ -74,7 +79,7 @@ export async function transcribeWithWhisperCpp(
74
79
  }
75
80
 
76
81
  export async function transcribeWithOpenAiWhisper(binary: string, audioPath: string, tempDir: string, modelName?: string) {
77
- const model = modelName || env("MICME_WHISPER_MODEL") || "base.en";
82
+ const model = modelName || getPythonWhisperModelName();
78
83
  const args = [
79
84
  audioPath,
80
85
  "--model",
@@ -89,8 +94,13 @@ export async function transcribeWithOpenAiWhisper(binary: string, audioPath: str
89
94
  "False",
90
95
  ];
91
96
 
92
- const language = env("MICME_LANGUAGE");
93
- if (language?.trim() && language.trim().toLowerCase() !== "auto") args.push("--language", language.trim());
97
+ const translateLanguage = getTranslateToEnglishLanguage();
98
+ if (translateLanguage) {
99
+ args.push("--task", "translate", "--language", translateLanguage);
100
+ } else {
101
+ const language = env("MICME_LANGUAGE");
102
+ if (language?.trim() && language.trim().toLowerCase() !== "auto") args.push("--language", language.trim());
103
+ }
94
104
 
95
105
  const device = env("MICME_WHISPER_DEVICE");
96
106
  if (device?.trim()) args.push("--device", device.trim());
package/src/types.ts CHANGED
@@ -13,6 +13,7 @@ export type ResolvedWhisperCppModel = {
13
13
  configuredValue?: string;
14
14
  exists: boolean;
15
15
  downloadable: boolean;
16
+ translationFallbackFrom?: string;
16
17
  };
17
18
 
18
19
  export type ResolvedTranscriptionPlan = {