Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
const test = require("node:test");
const assert = require("node:assert/strict");
const mic = (deviceId, label) => ({ kind: "audioinput", deviceId, label });
test("system mode maps the native default name to an exact Chromium input", async () => {
const { resolveMicrophoneSelection } = await import("../../src/helpers/microphoneSelection.js");
const expected = mic("macbook", "MacBook Pro Microphone (Built-in)");
const result = resolveMicrophoneSelection(
[mic("default", "Default - MacBook Pro Microphone (Built-in)"), expected],
{ microphoneSelectionMode: "system" },
{ name: "MacBook Pro Microphone" }
);
assert.equal(result.device, expected);
assert.equal(result.status, "native-exact");
});
test("system mode uses Chromium's explicit default device when native mapping is unavailable", async () => {
const { isCacheableMicrophoneResolution, resolveMicrophoneSelection } =
await import("../../src/helpers/microphoneSelection.js");
const expected = mic("default", "Default - Microphone Array");
const result = resolveMicrophoneSelection([expected, mic("continuity", "Joshua P Microphone")], {
microphoneSelectionMode: "system",
});
assert.equal(result.device, expected);
assert.equal(result.status, "chromium-default");
assert.equal(isCacheableMicrophoneResolution(result), false);
});
test("a resolved physical microphone can be cached", async () => {
const { isCacheableMicrophoneResolution, resolveMicrophoneSelection } =
await import("../../src/helpers/microphoneSelection.js");
const result = resolveMicrophoneSelection(
[mic("default", "Default - USB Microphone"), mic("usb", "USB Microphone")],
{ microphoneSelectionMode: "system" },
{ name: "USB Microphone" }
);
assert.equal(isCacheableMicrophoneResolution(result), true);
});
test("system mode never guesses the first physical microphone", async () => {
const { resolveMicrophoneSelection } = await import("../../src/helpers/microphoneSelection.js");
const result = resolveMicrophoneSelection(
[mic("continuity", "Joshua P Microphone"), mic("usb", "USB Microphone")],
{ microphoneSelectionMode: "system" },
{ name: "Missing System Microphone" }
);
assert.equal(result.device, null);
assert.equal(result.status, "native-unmatched");
});
test("legacy microphone preferences retain their behavior", async () => {
const { getMicrophoneSelectionMode } = await import("../../src/helpers/microphoneSelection.js");
assert.equal(getMicrophoneSelectionMode({ preferBuiltInMic: true }), "built-in");
assert.equal(
getMicrophoneSelectionMode({ preferBuiltInMic: false, selectedMicDeviceId: "usb" }),
"specific"
);
assert.equal(getMicrophoneSelectionMode({ preferBuiltInMic: false }), "system");
});
test("system mode ignores Chromium's Windows 'communications' alias when matching the native default", async () => {
const { isCacheableMicrophoneResolution, resolveMicrophoneSelection } =
await import("../../src/helpers/microphoneSelection.js");
const expected = mic("9f2c1e5a7b3d", "Microphone (Realtek(R) Audio)");
const result = resolveMicrophoneSelection(
[
mic("default", "Default - Microphone (Realtek(R) Audio)"),
mic("communications", "Communications - Microphone (Realtek(R) Audio)"),
expected,
],
{ microphoneSelectionMode: "system" },
{ name: "Microphone (Realtek(R) Audio)" }
);
assert.equal(result.device, expected);
assert.equal(result.status, "native-exact");
assert.equal(isCacheableMicrophoneResolution(result), true);
});
test("system mode ignores the alias when the native name is only contained in the Chromium label", async () => {
const { isCacheableMicrophoneResolution, resolveMicrophoneSelection } =
await import("../../src/helpers/microphoneSelection.js");
const expected = mic("9f2c1e5a7b3d", "Microphone (Realtek(R) Audio)");
const result = resolveMicrophoneSelection(
[
mic("default", "Default - Microphone (Realtek(R) Audio)"),
mic("communications", "Communications - Microphone (Realtek(R) Audio)"),
expected,
],
{ microphoneSelectionMode: "system" },
{ name: "Realtek(R) Audio" }
);
assert.equal(result.device, expected);
assert.equal(result.status, "native-compatible");
assert.equal(isCacheableMicrophoneResolution(result), true);
});
test("built-in mode pins the physical built-in device, not Chromium's Windows aliases", async () => {
const { resolveMicrophoneSelection } = await import("../../src/helpers/microphoneSelection.js");
const expected = mic("9f2c1e5a7b3d", "Microphone Array (Realtek(R) Audio)");
const result = resolveMicrophoneSelection(
[
mic("default", "Default - Microphone Array (Realtek(R) Audio)"),
mic("communications", "Communications - Microphone Array (Realtek(R) Audio)"),
expected,
mic("7a1b", "Jabra Evolve2 65"),
],
{ microphoneSelectionMode: "built-in" }
);
assert.equal(result.device, expected);
assert.equal(result.status, "built-in");
});