@hxnnxs/opencode-voice 0.2.3 → 0.2.4

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/lib/engine.js CHANGED
@@ -2,6 +2,7 @@ import fs from "node:fs";
2
2
  import os from "node:os";
3
3
  import path from "node:path";
4
4
  import { createRequire } from "node:module";
5
+ import { randomUUID } from "node:crypto";
5
6
  import { spawn, spawnSync } from "node:child_process";
6
7
  import { fileURLToPath } from "node:url";
7
8
  import { createGunzip } from "node:zlib";
@@ -580,7 +581,6 @@ function childEnv(options = {}) {
580
581
 
581
582
  function normalizeWindowsAudioInput(device = "") {
582
583
  const value = String(device).trim();
583
- if (!value || value === "default") return "audio=default";
584
584
  if (value.startsWith("audio=") || value.startsWith("video=")) return value;
585
585
  return `audio=${value}`;
586
586
  }
@@ -588,7 +588,7 @@ function normalizeWindowsAudioInput(device = "") {
588
588
  function formatCommand(command, args) {
589
589
  const quote = (value) => {
590
590
  const text = String(value);
591
- if (/^[^\s"\\]+$/.test(text)) return text;
591
+ if (/^[a-zA-Z0-9_./=:+-]+$/.test(text)) return text;
592
592
  return `"${text.replace(/(\\*)"/g, "$1$1\\\"").replace(/(\\*)$/g, "$1$1")}"`;
593
593
  };
594
594
  return [command, ...args].map(quote).join(" ");
@@ -605,10 +605,11 @@ function parseWindowsMicrophones(stderr) {
605
605
  }
606
606
 
607
607
  export function listMicrophones(options = {}) {
608
+ const platform = options.platform || process.platform;
608
609
  const arecordCommand = resolveCommand("arecord", options);
609
610
  const ffmpegCommand = resolveCommand("ffmpeg", options);
610
611
 
611
- if (process.platform === "linux" && arecordCommand) {
612
+ if (platform === "linux" && arecordCommand) {
612
613
  const result = spawnSync(arecordCommand, ["-L"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
613
614
  const devices = result.stdout
614
615
  .split(/\r?\n/)
@@ -617,7 +618,7 @@ export function listMicrophones(options = {}) {
617
618
  return ["default", ...devices.filter((item) => item !== "default")];
618
619
  }
619
620
 
620
- if (process.platform === "darwin" && ffmpegCommand) {
621
+ if (platform === "darwin" && ffmpegCommand) {
621
622
  const result = spawnSync(ffmpegCommand, ["-hide_banner", "-f", "avfoundation", "-list_devices", "true", "-i", ""], {
622
623
  encoding: "utf8",
623
624
  stdio: ["ignore", "ignore", "pipe"],
@@ -629,10 +630,11 @@ export function listMicrophones(options = {}) {
629
630
  .map((id) => `:${id}`);
630
631
  }
631
632
 
632
- if (process.platform === "win32" && ffmpegCommand) {
633
+ if (platform === "win32" && ffmpegCommand) {
633
634
  const result = spawnSync(ffmpegCommand, ["-hide_banner", "-f", "dshow", "-list_devices", "true", "-i", "dummy"], {
634
635
  encoding: "utf8",
635
636
  stdio: ["ignore", "ignore", "pipe"],
637
+ timeout: 5000,
636
638
  });
637
639
  const devices = parseWindowsMicrophones(result.stderr || "");
638
640
  return ["default", ...devices.filter((device) => device !== "default")];
@@ -642,13 +644,14 @@ export function listMicrophones(options = {}) {
642
644
  }
643
645
 
644
646
  function buildRecorders(file, settings = {}) {
645
- const mic = settings.mic || "";
647
+ const mic = (settings.mic || "").trim();
646
648
  const recorders = [];
649
+ const platform = settings.platform || process.platform;
647
650
  const arecordCommand = resolveCommand("arecord", settings);
648
651
  const ffmpegCommand = resolveCommand("ffmpeg", settings);
649
652
  const soxCommand = resolveCommand("sox", settings);
650
653
 
651
- if (process.platform === "linux" && arecordCommand) {
654
+ if (platform === "linux" && arecordCommand) {
652
655
  recorders.push({
653
656
  label: mic ? `arecord (${mic})` : "arecord (default)",
654
657
  command: arecordCommand,
@@ -656,7 +659,7 @@ function buildRecorders(file, settings = {}) {
656
659
  });
657
660
  }
658
661
 
659
- if (process.platform === "linux" && ffmpegCommand) {
662
+ if (platform === "linux" && ffmpegCommand) {
660
663
  if (!mic) {
661
664
  recorders.push({
662
665
  label: "ffmpeg pulse (default)",
@@ -672,7 +675,7 @@ function buildRecorders(file, settings = {}) {
672
675
  });
673
676
  }
674
677
 
675
- if (process.platform === "darwin" && ffmpegCommand) {
678
+ if (platform === "darwin" && ffmpegCommand) {
676
679
  recorders.push({
677
680
  label: `ffmpeg avfoundation (${mic || ":0"})`,
678
681
  command: ffmpegCommand,
@@ -680,27 +683,21 @@ function buildRecorders(file, settings = {}) {
680
683
  });
681
684
  }
682
685
 
683
- if (process.platform === "win32" && ffmpegCommand) {
684
- const ffmpegCmd = ffmpegCommand;
685
- if (ffmpegCmd) {
686
- const configuredInput = mic && mic !== "default" ? normalizeWindowsAudioInput(mic) : "";
687
- // DirectShow does not provide a reliable "audio=default" alias. Try each
688
- // enumerated device before retaining it as a final fallback for custom setups.
689
- const detectedInputs = listMicrophones(settings)
690
- .filter((device) => device !== "default")
691
- .map(normalizeWindowsAudioInput);
692
- const inputs = [...new Set([configuredInput, ...detectedInputs, "audio=default"].filter(Boolean))];
693
- for (const input of inputs) {
694
- recorders.push({
695
- label: `ffmpeg dshow (${input.replace(/^audio=/, "")})`,
696
- command: ffmpegCmd,
697
- args: ["-hide_banner", "-loglevel", "error", "-y", "-f", "dshow", "-i", input, "-ac", "1", "-ar", "16000", file],
698
- });
699
- }
686
+ if (platform === "win32" && ffmpegCommand) {
687
+ const inputs = mic && mic !== "default" && mic !== "audio=default"
688
+ ? [normalizeWindowsAudioInput(mic)]
689
+ : listMicrophones(settings).filter((device) => device !== "default").map(normalizeWindowsAudioInput);
690
+ for (const input of new Set(inputs)) {
691
+ recorders.push({
692
+ label: `ffmpeg dshow (${input.replace(/^audio=/, "")})`,
693
+ command: ffmpegCommand,
694
+ args: ["-hide_banner", "-loglevel", "error", "-y", "-f", "dshow", "-i", input, "-ac", "1", "-ar", "16000", "-flush_packets", "1", file],
695
+ gracefulStop: true,
696
+ });
700
697
  }
701
698
  }
702
699
 
703
- if (soxCommand) {
700
+ if (soxCommand && platform !== "win32") {
704
701
  recorders.push({
705
702
  label: "sox default",
706
703
  command: soxCommand,
@@ -708,7 +705,10 @@ function buildRecorders(file, settings = {}) {
708
705
  });
709
706
  }
710
707
 
711
- if (!recorders.length) throw new Error("No recorder found. Install ffmpeg, arecord, or sox.");
708
+ if (!recorders.length) {
709
+ if (platform === "win32" && ffmpegCommand) throw new Error("No DirectShow audio devices found. Select a microphone in /voice-settings.");
710
+ throw new Error("No recorder found. Install ffmpeg, arecord, or sox.");
711
+ }
712
712
  return recorders;
713
713
  }
714
714
 
@@ -755,49 +755,85 @@ function lastLine(value) {
755
755
  return value.trim().split("\n").filter(Boolean).pop() || "";
756
756
  }
757
757
 
758
- function startRecorder(recorder, file) {
758
+ function startRecorder(recorder, file, log, signal) {
759
759
  return new Promise((resolve, reject) => {
760
760
  let stderr = "";
761
- let exited = false;
762
- let exitCode = null;
761
+ let timer;
762
+ let settled = false;
763
+ let stopReason;
764
+ const started = Date.now();
763
765
  const commandLine = formatCommand(recorder.command, recorder.args);
764
- const failure = (detail) => new Error(`${recorder.label}: ${detail}\nCommand: ${commandLine}${stderr.trim() ? `\nffmpeg stderr:\n${stderr.trim()}` : ""}`);
766
+ log(`Starting ${recorder.label}\nCommand: ${commandLine}\nArguments: ${JSON.stringify(recorder.args)}`);
767
+ const finish = (error, active) => {
768
+ if (settled) return;
769
+ settled = true;
770
+ clearTimeout(timer);
771
+ signal.removeEventListener("abort", abort);
772
+ if (error) {
773
+ log(error.message);
774
+ reject(error);
775
+ } else {
776
+ resolve(active);
777
+ }
778
+ };
779
+ const failure = (detail) => new Error(`${recorder.label}: ${detail}\nCommand: ${commandLine}${stderr.trim() ? `\nstderr:\n${stderr.trim()}` : ""}`);
765
780
 
766
781
  let proc;
782
+ const abort = async () => {
783
+ clearTimeout(timer);
784
+ stopReason = "recording cancelled";
785
+ try { proc.kill("SIGKILL"); } catch {}
786
+ await waitForExit(proc);
787
+ finish(failure(stopReason));
788
+ };
767
789
  try {
768
- proc = spawn(recorder.command, recorder.args, { stdio: ["ignore", "ignore", "pipe"] });
790
+ proc = spawn(recorder.command, recorder.args, { stdio: [recorder.gracefulStop ? "pipe" : "ignore", "ignore", "pipe"] });
769
791
  } catch (error) {
770
- reject(failure(error instanceof Error ? error.message : String(error)));
792
+ finish(failure(error instanceof Error ? error.message : String(error)));
771
793
  return;
772
794
  }
795
+ proc.stdin?.on("error", () => {});
773
796
  proc.stderr.on("data", (chunk) => {
774
797
  stderr += chunk.toString();
798
+ log(`stderr: ${chunk.toString().trimEnd()}`);
775
799
  });
776
800
  proc.once("error", (error) => {
777
- exited = true;
778
- reject(failure(error.message));
801
+ finish(failure(error.message));
779
802
  });
780
- proc.once("exit", (code) => {
781
- exited = true;
782
- exitCode = code;
803
+ proc.once("close", (code, exitSignal) => {
804
+ log(`Exited: code=${code}, signal=${exitSignal}, elapsed=${Date.now() - started}ms`);
805
+ finish(failure(stopReason || lastLine(stderr) || `exited with code ${code}`));
783
806
  });
784
-
785
- setTimeout(() => {
786
- if (exited) {
787
- reject(failure(lastLine(stderr) || `exited with code ${exitCode}`));
807
+ const check = async () => {
808
+ if (signal.aborted) return;
809
+ let stat;
810
+ try {
811
+ stat = fs.statSync(file, { throwIfNoEntry: false });
812
+ } catch (error) {
813
+ stopReason = error.message;
814
+ try { proc.kill("SIGKILL"); } catch {}
815
+ await waitForExit(proc);
816
+ finish(failure(stopReason));
788
817
  return;
789
818
  }
790
-
791
- if (!fs.existsSync(file)) {
792
- try {
793
- proc.kill("SIGKILL");
794
- } catch {}
795
- reject(failure("did not create an audio file"));
819
+ const size = stat?.size || 0;
820
+ if (proc.exitCode === null && proc.signalCode === null && stat && (!recorder.gracefulStop || size > RECORDING_MIN_BYTES)) {
821
+ log(`Recording ready after ${Date.now() - started}ms (${size} bytes)`);
822
+ finish(null, { proc, file, recorder, stderr: () => stderr, log });
796
823
  return;
797
824
  }
798
-
799
- resolve({ proc, file, recorder, stderr: () => stderr });
800
- }, 650);
825
+ if (Date.now() - started >= 5000) {
826
+ stopReason = stat ? "did not write audio data within 5 seconds" : "did not create an audio file within 5 seconds";
827
+ try { proc.kill("SIGKILL"); } catch {}
828
+ await waitForExit(proc);
829
+ finish(failure(stopReason));
830
+ return;
831
+ }
832
+ timer = setTimeout(check, 100);
833
+ };
834
+ signal.addEventListener("abort", abort, { once: true });
835
+ if (signal.aborted) void abort();
836
+ else timer = setTimeout(check, 100);
801
837
  });
802
838
  }
803
839
 
@@ -805,7 +841,8 @@ export class VoiceRuntime {
805
841
  constructor(options = {}) {
806
842
  this.options = options;
807
843
  this.recording = null;
808
- this.recordingError = "";
844
+ this.starting = null;
845
+ this.recorderLog = "";
809
846
  this.transcription = null;
810
847
  this.pendingSubmit = false;
811
848
  }
@@ -820,7 +857,18 @@ export class VoiceRuntime {
820
857
 
821
858
  async start(settings = {}) {
822
859
  if (this.recording) return this.recording.file;
860
+ if (this.starting) return this.starting.promise;
861
+ const controller = new AbortController();
862
+ const promise = this.startRecording(settings, controller.signal);
863
+ this.starting = { controller, promise };
864
+ try {
865
+ return await promise;
866
+ } finally {
867
+ this.starting = null;
868
+ }
869
+ }
823
870
 
871
+ async startRecording(settings, signal) {
824
872
  const dir = getAudioDir(this.options, settings);
825
873
  await ensureDir(dir);
826
874
  const recorderSettings = { ...this.options, ...settings, downloadDir: settings.downloadDir || this.options.downloadDir };
@@ -830,26 +878,43 @@ export class VoiceRuntime {
830
878
  });
831
879
  if (recorderReady?.resolvedBinary) recorderSettings.ffmpeg = recorderReady.resolvedBinary;
832
880
 
833
- const file = path.join(dir, `voice-${Date.now()}.wav`);
834
- const recorders = buildRecorders(file, recorderSettings);
881
+ const stem = path.join(dir, `voice-${Date.now()}-${randomUUID()}`);
882
+ const file = `${stem}.wav`;
883
+ this.recorderLog = `${stem}.log`;
884
+ const logFile = this.recorderLog;
885
+ const log = (message) => {
886
+ try {
887
+ fs.appendFileSync(logFile, `[${new Date().toISOString()}] ${message}\n`);
888
+ } catch {}
889
+ };
890
+ log(`Platform: ${recorderSettings.platform || process.platform}; microphone: ${settings.mic || "default"}`);
891
+ let recorders;
892
+ try {
893
+ recorders = buildRecorders(file, recorderSettings);
894
+ } catch (error) {
895
+ log(error.message);
896
+ throw new Error(`${error.message}\nRecorder log: ${logFile}`);
897
+ }
835
898
  const errors = [];
836
- this.recordingError = "";
837
899
 
838
- for (const recorder of recorders) {
839
- await fs.promises.unlink(file).catch(() => {});
900
+ for (const [index, recorder] of recorders.entries()) {
901
+ signal.throwIfAborted();
902
+ const attemptFile = index === 0 ? file : `${stem}-${index}.wav`;
903
+ recorder.args[recorder.args.length - 1] = attemptFile;
840
904
  try {
841
- const active = await startRecorder(recorder, file);
842
- active.proc.on("exit", () => {
843
- if (this.recording?.proc === active.proc) this.recording = null;
844
- });
905
+ const active = await startRecorder(recorder, attemptFile, log, signal);
906
+ if (signal.aborted) {
907
+ try { active.proc.kill("SIGKILL"); } catch {}
908
+ signal.throwIfAborted();
909
+ }
845
910
  this.recording = active;
846
- return file;
911
+ return attemptFile;
847
912
  } catch (error) {
848
913
  errors.push(error instanceof Error ? error.message : String(error));
849
914
  }
850
915
  }
851
916
 
852
- throw new Error(`Could not start recorder. Tried: ${errors.join("; ")}`);
917
+ throw new Error(`Could not start recorder. Tried: ${errors.join("; ")}\nRecorder log: ${logFile}`);
853
918
  }
854
919
 
855
920
  async stop() {
@@ -857,30 +922,36 @@ export class VoiceRuntime {
857
922
  if (!active) return null;
858
923
 
859
924
  try {
860
- active.proc.kill("SIGINT");
925
+ if (active.recorder.gracefulStop && active.proc.stdin?.writable) active.proc.stdin.end("q\n");
926
+ else active.proc.kill("SIGINT");
861
927
  } catch {}
862
928
 
863
929
  await waitForExit(active.proc);
864
930
  this.recording = null;
865
931
 
866
932
  if (!fs.existsSync(active.file)) {
867
- const lastError = lastLine(active.stderr?.() || this.recordingError);
868
- throw new Error(lastError || `${active.recorder?.label || "Recorder"} did not create an audio file`);
933
+ const lastError = lastLine(active.stderr?.() || "");
934
+ throw new Error(`${lastError || `${active.recorder?.label || "Recorder"} did not create an audio file`}\nRecorder log: ${this.recorderLog}`);
869
935
  }
870
936
 
871
- if (fs.statSync(active.file).size <= RECORDING_MIN_BYTES) {
872
- throw new Error("Recording is empty. Check your microphone input.");
937
+ const size = fs.statSync(active.file).size;
938
+ active.log(`Recording stopped (${size} bytes)`);
939
+ if (size <= RECORDING_MIN_BYTES) {
940
+ throw new Error(`Recording is empty. Check your microphone input.\nRecorder log: ${this.recorderLog}`);
873
941
  }
874
942
 
875
943
  return active.file;
876
944
  }
877
945
 
878
946
  async cancel() {
947
+ this.starting?.controller.abort();
879
948
  if (this.recording) {
949
+ const active = this.recording;
880
950
  try {
881
- this.recording.proc.kill("SIGKILL");
951
+ active.proc.kill("SIGKILL");
882
952
  } catch {}
883
953
  this.recording = null;
954
+ await waitForExit(active.proc);
884
955
  }
885
956
 
886
957
  if (this.transcription) {
package/lib/engines.js CHANGED
@@ -10,6 +10,7 @@ import { getCacheDir } from "./models.js";
10
10
  import { getBundledEngineDir, resolveCommand } from "./engine.js";
11
11
 
12
12
  export const DEFAULT_ENGINE_REGISTRY_URL = "https://github.com/ihxnnxs/opencode-voice/releases/download/v0.2.0/registry.json";
13
+ const TRANSCRIBE_ENGINE_REGISTRY_URL = "https://github.com/ihxnnxs/opencode-voice/releases/download/engines-2026-12/registry.json";
13
14
 
14
15
  export const ENGINES = {
15
16
  "whisper.cpp": {
@@ -171,9 +172,13 @@ export async function probeEngine(engineId = "whisper.cpp", binaryPath, options
171
172
  finish({ ok: false, message: engineProbeMessage(error.message) });
172
173
  });
173
174
  proc.on("exit", (code, signal) => {
174
- const ok = engine.probeContains.every((item) => output.includes(item));
175
+ const requiresUpdate = engineId === "transcribe-cpp" && options.requireUpdatedEngine !== false;
176
+ const ok = engine.probeContains.every((item) => output.includes(item)) &&
177
+ (!requiresUpdate || output.includes("Supports GigaAM-v4"));
175
178
  const detail = summarizeProbeOutput(output) || `exit ${code ?? signal ?? "unknown"}`;
176
- finish({ ok, message: ok ? "ok" : engineProbeMessage(`unexpected ${engine.command} help output: ${detail}`) });
179
+ finish({ ok, message: ok ? "ok" : engineProbeMessage(requiresUpdate && !output.includes("Supports GigaAM-v4")
180
+ ? `${engine.command} needs the updated GigaAM-v4-capable runtime`
181
+ : `unexpected ${engine.command} help output: ${detail}`) });
177
182
  });
178
183
  });
179
184
  }
@@ -208,12 +213,13 @@ async function readJsonUrl(url, options = {}) {
208
213
  return response.json();
209
214
  }
210
215
 
211
- export function getEngineRegistryUrl(options = {}) {
212
- return options.engineRegistry || process.env.OPENCODE_VOICE_ENGINE_REGISTRY || DEFAULT_ENGINE_REGISTRY_URL;
216
+ export function getEngineRegistryUrl(options = {}, engineId) {
217
+ return options.engineRegistry || process.env.OPENCODE_VOICE_ENGINE_REGISTRY ||
218
+ (engineId === "transcribe-cpp" ? TRANSCRIBE_ENGINE_REGISTRY_URL : DEFAULT_ENGINE_REGISTRY_URL);
213
219
  }
214
220
 
215
- export async function loadEngineRegistry(options = {}) {
216
- const url = getEngineRegistryUrl(options);
221
+ export async function loadEngineRegistry(options = {}, engineId) {
222
+ const url = getEngineRegistryUrl(options, engineId);
217
223
  const registry = await readJsonUrl(url, options);
218
224
  if (registry?.schema !== "opencode-voice.engines.v1") throw new Error("Unsupported engine registry schema");
219
225
  return { url, registry };
@@ -320,7 +326,7 @@ export async function installManagedEngine(engineId = "whisper.cpp", options = {
320
326
  }
321
327
 
322
328
  hooks.onProgress?.({ state: "registry", downloaded: 0, total: 0, percent: 0, attempt: 1, attempts: 1 });
323
- const { url: registryUrl, registry } = await loadEngineRegistry(commandOptions);
329
+ const { url: registryUrl, registry } = await loadEngineRegistry(commandOptions, engineId);
324
330
  const platform = getEnginePlatformKey(commandOptions);
325
331
  const { engine, asset } = selectEngineAsset(registry, engineId, platform);
326
332
 
@@ -394,7 +400,7 @@ export async function importManagedEngine(engineId = "whisper.cpp", sourcePath,
394
400
  await fs.promises.copyFile(source, tmp);
395
401
  await fs.promises.chmod(tmp, 0o755);
396
402
 
397
- const probe = await probeEngine(engineId, tmp);
403
+ const probe = await probeEngine(engineId, tmp, { requireUpdatedEngine: false });
398
404
  if (!probe.ok) {
399
405
  await fs.promises.unlink(tmp).catch(() => {});
400
406
  throw new Error(`Imported binary failed probe: ${probe.message}`);
@@ -1,6 +1,19 @@
1
1
  // Generated by scripts/update-handy-model-catalog.mjs. Do not edit manually.
2
- export const HANDY_MODEL_CATALOG_SHA256 = "82b5f7bf28f3c4a4e607ac1730a7cf70869f5dafcde47aa9cc2e3e013ade63d4";
2
+ export const HANDY_MODEL_CATALOG_SHA256 = "8c886882ed49ff5f39cc0ff42176a41119ea49242068518e3eb671b09be88ddc";
3
3
  export const HANDY_MODELS = [
4
+ {
5
+ "id": "gigaam-v4-e2e-rnnt-gguf",
6
+ "name": "gigaam-v4-e2e-rnnt-gguf",
7
+ "engine": "transcribe-cpp",
8
+ "implemented": true,
9
+ "filename": "gigaam-v4-e2e-rnnt-Q8_0.gguf",
10
+ "url": "https://huggingface.co/70sh1/gigaam-v4-e2e-rnnt-gguf/resolve/2a312d783963ca3433768281faea00cdcf2569c5/gigaam-v4-e2e-rnnt-Q8_0.gguf",
11
+ "sha256": "debd6179b9948beba5c60c0944285e577f732610dd50dee1233884e4b46e3e29",
12
+ "sizeMB": 244,
13
+ "languages": "ru, en",
14
+ "requiresUpdatedEngine": true,
15
+ "description": "gigaam model from the GigaAM-v4 Zapformer port. Pinned to 2a312d783963."
16
+ },
4
17
  {
5
18
  "id": "handy-breeze-asr-25-gguf",
6
19
  "name": "Breeze-ASR-25-gguf",
@@ -217,6 +230,32 @@ export const HANDY_MODELS = [
217
230
  "languages": "en, fr, de, es, pt",
218
231
  "description": "granite_speech model from Handy's transcribe.cpp catalog. Pinned to f73a59df77fe."
219
232
  },
233
+ {
234
+ "id": "handy-granite-speech-5-0-470m-turboctc-gguf",
235
+ "name": "granite-speech-5.0-470m-turboctc-gguf",
236
+ "engine": "transcribe-cpp",
237
+ "implemented": true,
238
+ "filename": "granite-speech-5.0-470m-turboctc-Q4_K_M.gguf",
239
+ "url": "https://huggingface.co/handy-computer/granite-speech-5.0-470m-turboctc-gguf/resolve/0cf5be9f4bcd479989e6a24d142094d34d552daa/granite-speech-5.0-470m-turboctc-Q4_K_M.gguf",
240
+ "sha256": "3f30525381d72246b7f99e49b6cb66b249cf1b990c6c3d0e031a7765735f513e",
241
+ "sizeMB": 267,
242
+ "languages": "en",
243
+ "requiresUpdatedEngine": true,
244
+ "description": "granite_speech5_ctc model from Handy's transcribe.cpp catalog. Pinned to 0cf5be9f4bcd."
245
+ },
246
+ {
247
+ "id": "handy-granite-speech-5-0-470m-turboctc-nc-gguf",
248
+ "name": "granite-speech-5.0-470m-turboctc-nc-gguf",
249
+ "engine": "transcribe-cpp",
250
+ "implemented": true,
251
+ "filename": "granite-speech-5.0-470m-turboctc-nc-Q4_K_M.gguf",
252
+ "url": "https://huggingface.co/handy-computer/granite-speech-5.0-470m-turboctc-nc-gguf/resolve/73e511af2e488994672379a3e5f9307b51d173c9/granite-speech-5.0-470m-turboctc-nc-Q4_K_M.gguf",
253
+ "sha256": "b79b5b39c36f3d0596774ff352d132483b659a43927015864ad5e149ac85470a",
254
+ "sizeMB": 267,
255
+ "languages": "en",
256
+ "requiresUpdatedEngine": true,
257
+ "description": "granite_speech5_ctc model from Handy's transcribe.cpp catalog. Pinned to 73e511af2e48."
258
+ },
220
259
  {
221
260
  "id": "handy-medasr-gguf",
222
261
  "name": "medasr-gguf",
@@ -481,6 +520,19 @@ export const HANDY_MODELS = [
481
520
  "languages": "en",
482
521
  "description": "parakeet model from Handy's transcribe.cpp catalog. Pinned to 7d9b71920678."
483
522
  },
523
+ {
524
+ "id": "handy-orukeet-gguf",
525
+ "name": "orukeet-gguf",
526
+ "engine": "transcribe-cpp",
527
+ "implemented": true,
528
+ "filename": "orukeet-Q4_K_M.gguf",
529
+ "url": "https://huggingface.co/handy-computer/orukeet-gguf/resolve/c5511a3850fce1cbbfa5d94ef815966e1d99275f/orukeet-Q4_K_M.gguf",
530
+ "sha256": "ead20f27cef24a39c2c8ad262bff88c3b5e0d4b514ff761cf7a08c5e172ccd9e",
531
+ "sizeMB": 463,
532
+ "languages": "bg, hr, cs, da, nl, en, et, fi, fr, de, el, hu, it, lv, lt, mt, pl, pt, ro, ru, sk, sl, es, sv, uk",
533
+ "requiresUpdatedEngine": true,
534
+ "description": "parakeet model from Handy's transcribe.cpp catalog. Pinned to c5511a3850fc."
535
+ },
484
536
  {
485
537
  "id": "handy-parakeet-ctc-0-6b-gguf",
486
538
  "name": "parakeet-ctc-0.6b-gguf",
@@ -505,6 +557,19 @@ export const HANDY_MODELS = [
505
557
  "languages": "en",
506
558
  "description": "parakeet model from Handy's transcribe.cpp catalog. Pinned to a9607fbeb480."
507
559
  },
560
+ {
561
+ "id": "handy-parakeet-primeline-gguf",
562
+ "name": "parakeet-primeline-gguf",
563
+ "engine": "transcribe-cpp",
564
+ "implemented": true,
565
+ "filename": "parakeet-primeline-Q4_K_M.gguf",
566
+ "url": "https://huggingface.co/handy-computer/parakeet-primeline-gguf/resolve/cf04224dee82c8ad7184e99562680f2926c82bf7/parakeet-primeline-Q4_K_M.gguf",
567
+ "sha256": "8b01f1893fa1db166d8b08375f8300c140fc7f110af7e9b68480a27b145dad7d",
568
+ "sizeMB": 463,
569
+ "languages": "bg, hr, cs, da, nl, en, et, fi, fr, de, el, hu, it, lv, lt, mt, pl, pt, ro, ru, sk, sl, es, sv, uk",
570
+ "requiresUpdatedEngine": true,
571
+ "description": "parakeet model from Handy's transcribe.cpp catalog. Pinned to cf04224dee82."
572
+ },
508
573
  {
509
574
  "id": "handy-parakeet-rnnt-0-6b-gguf",
510
575
  "name": "parakeet-rnnt-0.6b-gguf",
@@ -589,6 +654,19 @@ export const HANDY_MODELS = [
589
654
  "languages": "en",
590
655
  "description": "parakeet model from Handy's transcribe.cpp catalog. Pinned to 8c2181061569."
591
656
  },
657
+ {
658
+ "id": "handy-parakeet-ultra-gguf",
659
+ "name": "parakeet-ultra-gguf",
660
+ "engine": "transcribe-cpp",
661
+ "implemented": true,
662
+ "filename": "parakeet-ultra-Q4_K_M.gguf",
663
+ "url": "https://huggingface.co/handy-computer/parakeet-ultra-gguf/resolve/a1539be1b849ea7463b88343e5277b373d0c4ea9/parakeet-ultra-Q4_K_M.gguf",
664
+ "sha256": "c69b7a5f9071a7afd8a1818ef7ae542c386c4b01ed0cac380c19a99947646bf9",
665
+ "sizeMB": 464,
666
+ "languages": "en, de, fr, es, it, pt, ru, uk, hr, sl, lv, lt, et, fi, sv, da, nl, pl, cs, sk, hu, ro, bg, el, mt",
667
+ "requiresUpdatedEngine": true,
668
+ "description": "parakeet model from Handy's transcribe.cpp catalog. Pinned to a1539be1b849."
669
+ },
592
670
  {
593
671
  "id": "handy-parakeet-unified-en-0-6b-gguf",
594
672
  "name": "parakeet-unified-en-0.6b-gguf",
package/lib/wav.js CHANGED
@@ -8,6 +8,17 @@ function readExactly(fd, buffer, position) {
8
8
  return fs.readSync(fd, buffer, 0, buffer.length, position) === buffer.length;
9
9
  }
10
10
 
11
+ function validChunkTail(fd, offset, end) {
12
+ const header = Buffer.alloc(CHUNK_HEADER_BYTES);
13
+ while (offset + CHUNK_HEADER_BYTES <= end) {
14
+ if (!readExactly(fd, header, offset)) return false;
15
+ if (!/^[\x20-\x7e]{4}$/.test(header.toString("latin1", 0, 4))) return false;
16
+ const size = header.readUInt32LE(4);
17
+ offset += CHUNK_HEADER_BYTES + size + (size % 2);
18
+ }
19
+ return offset === end;
20
+ }
21
+
11
22
  export function repairUnfinalizedWavHeader(file) {
12
23
  let fd;
13
24
  try {
@@ -37,8 +48,18 @@ export function repairUnfinalizedWavHeader(file) {
37
48
 
38
49
  if (chunkId === "data") {
39
50
  const availableDataSize = fileSize - chunkDataOffset;
40
- const repairRiffSize = declaredRiffSize > fileSize - 8;
41
- const repairDataSize = declaredChunkSize > availableDataSize;
51
+ const declaredEnd = declaredRiffSize + 8;
52
+ const dataEnd = chunkDataOffset + declaredChunkSize + (declaredChunkSize % 2);
53
+ // A complete RIFF may contain other chunks after data, or bytes outside
54
+ // the RIFF form. Do not mistake either for recorded PCM.
55
+ const validForm = dataEnd <= declaredEnd && declaredEnd <= fileSize &&
56
+ validChunkTail(fd, dataEnd, declaredEnd);
57
+ if (validForm && (declaredChunkSize !== 0 || dataEnd === fileSize ||
58
+ validChunkTail(fd, dataEnd, fileSize))) return false;
59
+
60
+ const repairRiffSize = declaredRiffSize !== fileSize - 8;
61
+ const repairDataSize = declaredChunkSize > availableDataSize ||
62
+ (dataEnd < fileSize && !validChunkTail(fd, dataEnd, fileSize));
42
63
  if (!repairRiffSize && !repairDataSize) return false;
43
64
 
44
65
  const size = Buffer.alloc(4);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hxnnxs/opencode-voice",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Local voice input plugin for OpenCode",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -19,7 +19,7 @@
19
19
  "import": "./index.js"
20
20
  },
21
21
  "./tui": {
22
- "import": "./index.js"
22
+ "import": "./tui.js"
23
23
  },
24
24
  "./runtime": {
25
25
  "import": "./lib/engine.js"
@@ -33,6 +33,7 @@
33
33
  "bin/",
34
34
  "lib/",
35
35
  "index.js",
36
+ "tui.js",
36
37
  "CHANGELOG.md",
37
38
  "CONTRIBUTING.md",
38
39
  "PUBLISHING.md",
@@ -42,7 +43,7 @@
42
43
  "LICENSE"
43
44
  ],
44
45
  "scripts": {
45
- "check": "node --check index.js && node --check lib/models.js && node --check lib/handy-model-catalog.js && node --check lib/download.js && node --check lib/engine.js && node --check lib/engines.js && node --check lib/wav.js && node --check bin/opencode-voice.js && node --check scripts/package-engine-asset.mjs && node --check scripts/build-engine-registry.mjs && node --check scripts/update-handy-model-catalog.mjs && npm test",
46
+ "check": "node --check index.js && node --check tui.js && node --check lib/models.js && node --check lib/handy-model-catalog.js && node --check lib/download.js && node --check lib/engine.js && node --check lib/engines.js && node --check lib/wav.js && node --check bin/opencode-voice.js && node --check scripts/package-engine-asset.mjs && node --check scripts/build-engine-registry.mjs && node --check scripts/update-handy-model-catalog.mjs && npm test",
46
47
  "test": "node --test",
47
48
  "update-handy-model-catalog": "node scripts/update-handy-model-catalog.mjs",
48
49
  "prepack": "npm run check"
@@ -55,11 +56,15 @@
55
56
  "provenance": true
56
57
  },
57
58
  "peerDependencies": {
58
- "@opencode-ai/plugin": ">=1.17.4 <2"
59
+ "@opencode-ai/plugin": ">=1.17.4 <2",
60
+ "@opencode/plugin": ">=2.0.26 <3"
59
61
  },
60
62
  "peerDependenciesMeta": {
61
63
  "@opencode-ai/plugin": {
62
64
  "optional": true
65
+ },
66
+ "@opencode/plugin": {
67
+ "optional": true
63
68
  }
64
69
  },
65
70
  "keywords": [