Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

perf(dictation): faster mic start on Windows, concurrent Parakeet segments, no everyday words in AutoLearn (#2178)

Gabriel Stein1b41ce5f48b0
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9bb13a0c5..9500f2c20 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Dictation
+
+- **Dictation starts listening sooner on Windows.** Pressing the hotkey could take two seconds before the microphone opened. Since 1.9.0 the app pins the system-default microphone to a real device so its health checks can run, and on Windows finding that device means starting a PowerShell process that compiles C# on the fly — a lookup that ran on the first dictation after launch and again whenever an audio device came or went, and expired after 30 seconds either way. The answer is now resolved once at launch, kept until the OS reports a device change, and shared between windows, so the hotkey path only has to open the microphone. (#2178)
+- **Learned corrections skip everyday words.** When you fixed a transcript by swapping one common word for another, such as "why" for "what", the app treated the replacement as a mishearing and saved it to your dictionary. Those entries taught the cleanup model nothing and padded every request. Corrections that resolve to a common English word are no longer learned; names and jargon are unaffected. (#2178)
+
### Notes
- **Generate AI Summary no longer saves your transcript back as the "Enhanced" note.** With an OpenAI reasoning model such as GPT-5.6 Terra, the summary could finish with no error and an Enhanced tab that was just the raw transcript run together. Whenever the model returned no text, the OpenAI provider fell back to handing its input straight back, and the app saved that as the enhanced note. The fallback now only applies to plain dictation cleanup, which its callers already guard; a summary or any other prompted task reports an error instead, including a refusal or a response that ran out of tokens before writing anything. Every other reasoning path, bring-your-own-key, local, enterprise, and OpenWhispr Cloud alike, also reports an error on a blank result rather than saving a blank page. OpenAI's reasoning models additionally get at least 25k output tokens so hidden reasoning cannot crowd out the answer.
@@ -14,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Transcription
+- **Long local dictations transcribe faster.** Parakeet and Orukeet decode audio in 15-second segments, and the app sent them to the local server one after another even though the server decodes on three threads. Segments now decode side by side, one per server thread and sized to the machine's cores, so a one-minute dictation no longer waits on four serial passes. Dictations under 15 seconds are unchanged. (#2178)
- **Your own Deepgram key works again.** Every Deepgram connection failed with `Unexpected server response: 401`, even though the same key tested fine in Settings and worked against Deepgram directly. Deepgram accepts a raw API key only under its `Token` authorization scheme and reserves `Bearer` for the short-lived tokens OpenWhispr Cloud mints on your behalf — and the app was presenting your key as a `Bearer`. This broke bring-your-own-key dictation as well as Note Recording. (#2140, thanks @nikhilmaddirala)
- **Your own AssemblyAI key works in Note Recording again.** Recordings died seconds in with `Input Duration Violation: 40.0 ms`, followed by a cascade of reconnect errors. AssemblyAI accepts audio in 50-1000 ms frames, and the app measured those frames against dictation's 16 kHz — but Note Recording streams at 24 kHz, where the same frame lasts only 33-40 ms. The frame size now follows the rate each session actually opened at, and an oversized burst — which a busy moment can produce on the system-audio channel — is split instead of being sent as one frame that trips the same limit from the other end. Dictation was never affected. (#2140, thanks @nikhilmaddirala)
- **Local transcription no longer silently drops parts of a recording.** whisper.cpp decodes audio in 30-second windows, and the app was starting whisper-server with `--no-timestamps`. Without timestamp tokens the decoder cannot report where it stopped inside a window, so whisper.cpp skipped to the next 30-second mark regardless and the speech in between was discarded — with no gap or warning, and the surviving text still reading as a complete thought. Dictation was the most exposed, but notes and meeting recordings lost the same words whenever a passage ran up to a window boundary. The 60-character segment wrap that `--no-timestamps` was there to suppress is now switched off directly, so words still never split mid-word. (#2150)
diff --git a/src/helpers/audioManager.js b/src/helpers/audioManager.js
index 5f38dba19..e167bc55d 100644
--- a/src/helpers/audioManager.js
+++ b/src/helpers/audioManager.js
@@ -569,6 +569,9 @@ class AudioManager {
this.rejectedMicDeviceId = null;
this.cancelPreparedMicCapture();
this.micStreamHold.drop();
+ // The main process keeps the OS default mic until told it changed, so
+ // re-resolve now rather than on the next hotkey press (~2s on Windows).
+ window.electronAPI?.getSystemDefaultMicrophone?.({ refresh: true })?.catch(() => {});
};
navigator.mediaDevices?.addEventListener?.("devicechange", this._onDeviceChange);
this.recordingStartTime = null;
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.js
index 1cd585030..f5579838b 100644
--- a/src/helpers/ipcHandlers.js
+++ b/src/helpers/ipcHandlers.js
@@ -668,6 +668,8 @@ class IPCHandlers {
this._setupTextEditMonitor();
this._setupRetentionCleanup();
this._logDetectedGpus();
+ // Warm the OS default mic answer before the first hotkey press (~2s on Windows).
+ resolveSystemDefaultMicrophone();
this.setupHandlers();
// Lives for the app's lifetime; IPCHandlers has no teardown path.
tokenStore.subscribe(({ generation, token }) => {
diff --git a/src/helpers/parakeetServer.js b/src/helpers/parakeetServer.js
index cf7c372e0..657c6f01f 100644
--- a/src/helpers/parakeetServer.js
+++ b/src/helpers/parakeetServer.js
@@ -31,6 +31,25 @@ const COHERE_MAX_SEGMENT_SECONDS = 30;
const ONLINE_MAX_SEGMENT_SECONDS = 600;
const SILENCE_RMS_THRESHOLD = 0.001;
+// Runs fn over items with at most `limit` in flight; results keep item order.
+// Once one item rejects, no further items are started.
+async function mapWithConcurrency(items, limit, fn) {
+ const results = new Array(items.length);
+ let next = 0;
+ let failed = false;
+ const worker = async () => {
+ while (!failed && next < items.length) {
+ const index = next++;
+ results[index] = await fn(items[index], index).catch((error) => {
+ failed = true;
+ throw error;
+ });
+ }
+ };
+ await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
+ return results;
+}
+
class ParakeetServerManager {
constructor() {
this.wsServer = new ParakeetWsServer();
@@ -169,42 +188,51 @@ class ParakeetServerManager {
segmentCount: Math.ceil(samples.length / maxSegmentBytes),
});
- const texts = [];
- let totalElapsed = 0;
- let truncated = false;
-
+ const segments = [];
for (let offset = 0; offset < samples.length; offset += maxSegmentBytes) {
+ segments.push(samples.subarray(offset, offset + maxSegmentBytes));
+ }
+
+ const decodeSegment = async (segment, segmentIndex) => {
+ throwIfAborted();
+ const first = await this.wsServer.transcribe(segment, SAMPLE_RATE, { signal });
+ if (first.text || computeFloat32RMS(segment) < SILENCE_RMS_THRESHOLD) return first;
throwIfAborted();
- const end = Math.min(offset + maxSegmentBytes, samples.length);
- const segment = samples.subarray(offset, end);
- let result = await this.wsServer.transcribe(segment, SAMPLE_RATE, { signal });
- totalElapsed += result.elapsed || 0;
- if (!result.text && computeFloat32RMS(segment) >= SILENCE_RMS_THRESHOLD) {
- throwIfAborted();
- // An empty decode of audible audio silently amputates the transcript
- // (#1435: dictation openings dropped); retry once before conceding.
- debugLogger.warn("Parakeet segment returned empty text, retrying", {
- segmentIndex: offset / maxSegmentBytes,
- segmentDuration: segment.length / BYTES_PER_SAMPLE / SAMPLE_RATE,
+ // An empty decode of audible audio silently amputates the transcript
+ // (#1435: dictation openings dropped); retry once before conceding.
+ debugLogger.warn("Parakeet segment returned empty text, retrying", {
+ segmentIndex,
+ segmentDuration: segment.length / BYTES_PER_SAMPLE / SAMPLE_RATE,
+ });
+ const retry = await this.wsServer.transcribe(segment, SAMPLE_RATE, { signal });
+ if (!retry.text) {
+ debugLogger.warn("Parakeet segment still empty after retry; transcript truncated", {
+ segmentIndex,
});
- result = await this.wsServer.transcribe(segment, SAMPLE_RATE, { signal });
- totalElapsed += result.elapsed || 0;
- if (!result.text) {
- truncated = true;
- debugLogger.warn("Parakeet segment still empty after retry; transcript truncated", {
- segmentIndex: offset / maxSegmentBytes,
- });
- }
}
- // Latched after the retry so a discarded attempt's truncation dies with it.
- if (result.truncated) truncated = true;
- if (result.text) texts.push(result.text);
- }
-
- const text = texts.join(" ");
- return truncated
- ? { text, elapsed: totalElapsed, truncated }
- : { text, elapsed: totalElapsed };
+ // Only the retry's truncation counts; the discarded attempt's dies with it.
+ return {
+ ...retry,
+ elapsed: (first.elapsed || 0) + (retry.elapsed || 0),
+ truncated: !!retry.truncated || !retry.text,
+ };
+ };
+
+ // Segments are independent, so a minute of dictation decodes on the
+ // server's work threads side by side instead of in four serial passes.
+ const results = await mapWithConcurrency(
+ segments,
+ this.wsServer.maxConcurrentDecodes,
+ decodeSegment
+ );
+ const text = results
+ .map((result) => result.text)
+ .filter(Boolean)
+ .join(" ");
+ const elapsed = results.reduce((sum, result) => sum + (result.elapsed || 0), 0);
+ return results.some((result) => result.truncated)
+ ? { text, elapsed, truncated: true }
+ : { text, elapsed };
} finally {
this._cleanupFiles(filesToCleanup);
}
diff --git a/src/helpers/parakeetWsServer.js b/src/helpers/parakeetWsServer.js
index b5c664cd7..b059b40c4 100644
--- a/src/helpers/parakeetWsServer.js
+++ b/src/helpers/parakeetWsServer.js
@@ -3,11 +3,11 @@ const fs = require("fs");
const path = require("path");
const WebSocket = require("ws");
const debugLogger = require("./debugLogger");
-const os = require("os");
const {
findAvailablePort,
resolveBinaryPath,
gracefulStopProcess,
+ getAvailableParallelism,
} = require("../utils/serverUtils");
const { getSafeTempDir } = require("./safeTempDir");
const { createAbortError } = require("./abortError");
@@ -33,6 +33,17 @@ const ONLINE_TIMEOUT_PER_AUDIO_SECOND_MS = 2000;
const ONLINE_FINISH_IDLE_TIMEOUT_MS = 10000;
// Must cover the model's 560ms chunk so the flush decodes the final words.
const ONLINE_END_TAIL_PADDING_S = 0.6;
+const AVAILABLE_CPUS = getAvailableParallelism();
+// ONNX intra-op threads for one decode; the cap of four dates from #1131.
+const INTRA_OP_THREADS = Math.max(1, Math.min(4, Math.floor(AVAILABLE_CPUS * 0.75)));
+// sherpa-onnx's offline server decodes each connection on its own work thread.
+const OFFLINE_WORK_THREADS = 3;
+// How many segments the manager may hand the offline server at once: one per
+// work thread, but never so many that the intra-op pools oversubscribe the cores.
+const OFFLINE_DECODE_CONCURRENCY = Math.max(
+ 1,
+ Math.min(OFFLINE_WORK_THREADS, Math.floor(AVAILABLE_CPUS / INTRA_OP_THREADS))
+);
class ParakeetWsServer {
constructor() {
@@ -110,7 +121,6 @@ class ParakeetWsServer {
this.modelRuntime = runtime;
this.language = language;
- const threads = Math.max(1, Math.min(4, Math.floor(os.cpus().length * 0.75)));
const modelArgs =
getModelType(modelName) === "cohere-transcribe"
? [
@@ -133,7 +143,7 @@ class ParakeetWsServer {
? [
// --num-threads is ONNX intra-op parallelism for the single dictation
// stream; --num-work-threads only spreads across concurrent streams.
- `--num-threads=${threads}`,
+ `--num-threads=${INTRA_OP_THREADS}`,
"--num-work-threads=2",
// Default 10ms decode-loop tick adds idle time to faster-than-realtime decode.
"--loop-interval-ms=2",
@@ -142,7 +152,7 @@ class ParakeetWsServer {
// covers it app-side.
"--warm-up=0",
]
- : [`--num-threads=${threads}`]),
+ : [`--num-threads=${INTRA_OP_THREADS}`, `--num-work-threads=${OFFLINE_WORK_THREADS}`]),
];
debugLogger.debug("Starting parakeet WS server", { port: this.port, modelName, runtime, args });
@@ -276,6 +286,11 @@ class ParakeetWsServer {
}
}
+ // The online runtime is a single stream and takes segments in order.
+ get maxConcurrentDecodes() {
+ return this.modelRuntime === "online" ? 1 : OFFLINE_DECODE_CONCURRENCY;
+ }
+
// signal is optional; dictation and warm-up flows never pass one.
transcribe(samplesBuffer, sampleRate, { signal } = {}) {
if (!this.ready || !this.process) {
diff --git a/src/helpers/systemDefaultMicrophone.js b/src/helpers/systemDefaultMicrophone.js
index ca4c28fc5..73d3c8488 100644
--- a/src/helpers/systemDefaultMicrophone.js
+++ b/src/helpers/systemDefaultMicrophone.js
@@ -3,9 +3,9 @@ const { resolveBundledBinary } = require("./binaryResolver");
const debugLogger = require("./debugLogger");
const COMMAND_TIMEOUT_MS = 3000;
-// Windows resolves through a short-lived PowerShell process, so keep successful
-// lookups warm. Renderer devicechange recovery explicitly bypasses this cache.
-const CACHE_TTL_MS = 30000;
+// A failed lookup is retried after this long, so a transient error (a busy
+// PowerShell, a helper still extracting) does not stick for the session.
+const FAILURE_RETRY_MS = 30000;
const WINDOWS_DEFAULT_INPUT_SCRIPT = String.raw`
$ErrorActionPreference = 'Stop'
@@ -163,6 +163,7 @@ function createSystemDefaultMicrophoneResolver({
} = {}) {
let cache = null;
let cachedAt = 0;
+ let inflight = null;
const resolveDarwin = async () => {
const helper = resolveBinary("macos-mic-listener", "audio");
@@ -200,9 +201,7 @@ function createSystemDefaultMicrophoneResolver({
return parsePactlSources(sources, defaultSourceName);
};
- return async ({ refresh = false } = {}) => {
- if (!refresh && cache && now() - cachedAt < CACHE_TTL_MS) return cache;
-
+ const lookup = async () => {
try {
let result = null;
if (platform === "darwin") result = await resolveDarwin();
@@ -212,8 +211,6 @@ function createSystemDefaultMicrophoneResolver({
cache = result
? { ...result, platform, source: "system" }
: { name: "", platform, source: "unavailable" };
- cachedAt = now();
- return cache;
} catch (error) {
debugLogger.debug(
"Failed to resolve the system default microphone",
@@ -221,9 +218,24 @@ function createSystemDefaultMicrophoneResolver({
"audio"
);
cache = { name: "", platform, source: "unavailable" };
- cachedAt = now();
+ }
+ cachedAt = now();
+ return cache;
+ };
+
+ // A successful lookup stays valid until a renderer sees a devicechange and
+ // asks for a refresh: on Windows each lookup is a PowerShell process compiling
+ // C# (~2s), far too slow to sit on the hotkey path. Every caller joins an
+ // in-flight lookup so all windows share one process and see the same answer.
+ return async ({ refresh = false } = {}) => {
+ if (inflight) return inflight;
+ if (!refresh && cache && (cache.source === "system" || now() - cachedAt < FAILURE_RETRY_MS)) {
return cache;
}
+ inflight = lookup().finally(() => {
+ inflight = null;
+ });
+ return inflight;
};
}
diff --git a/src/helpers/whisperServer.js b/src/helpers/whisperServer.js
index d1f630324..939ae779c 100644
--- a/src/helpers/whisperServer.js
+++ b/src/helpers/whisperServer.js
@@ -3,11 +3,10 @@ const EventEmitter = require("events");
const fs = require("fs");
const path = require("path");
const http = require("http");
-const os = require("os");
const { app } = require("electron");
const debugLogger = require("./debugLogger");
const { killProcess } = require("../utils/process");
-const { isPortAvailable } = require("../utils/serverUtils");
+const { isPortAvailable, getAvailableParallelism } = require("../utils/serverUtils");
const { getSafeTempDir } = require("./safeTempDir");
const { convertToWav } = require("./ffmpegUtils");
const { createAbortError } = require("./abortError");
@@ -58,17 +57,6 @@ function parsePositiveInteger(value) {
return parsed > 0 ? parsed : null;
}
-function getAvailableParallelism() {
- try {
- if (typeof os.availableParallelism === "function") {
- return os.availableParallelism();
- }
- } catch {}
-
- const cpus = os.cpus();
- return Array.isArray(cpus) && cpus.length > 0 ? cpus.length : DEFAULT_WHISPER_THREADS;
-}
-
function createThreadResolution(threads, source, availableParallelism) {
return { threads, source, availableParallelism };
}
diff --git a/src/utils/correctionLearner.js b/src/utils/correctionLearner.js
index 74c5da416..6d93cb64c 100644
--- a/src/utils/correctionLearner.js
+++ b/src/utils/correctionLearner.js
@@ -3,6 +3,20 @@
* the edited field value. Returns corrected words to add to the custom dictionary.
*/
+// Swapping one everyday word for another ("why" -> "what") is a content edit,
+// not vocabulary; learning it would only pad the cleanup prompt. Words under
+// three letters are already dropped, so none are listed here.
+const COMMON_WORDS = new Set(
+ `the and for not with you this but his from they say her she will one all would
+ there their what out about who get which when make can like time just him know
+ take into year your good some could them see other than then now look only come
+ over think also back after use two how our work first well way even new want
+ because any these give day most are was were been has had did does said went
+ made got came took saw knew thought where why here very much many still too again
+ off down never every own same another both each few more less last next while
+ before through under between should might must being have that its yes okay`.split(/\s+/)
+);
+
/** Levenshtein edit distance between two strings */
function editDistance(a, b) {
const m = a.length;
@@ -162,6 +176,7 @@ function extractCorrections(originalText, fieldValue, existingDictionary) {
if (seenCorrections.has(normalizedCorrected)) continue;
if (origWord.toLowerCase() === normalizedCorrected) continue;
if (correctedWord.length < 3) continue;
+ if (COMMON_WORDS.has(normalizedCorrected)) continue;
// 0.65 threshold allows phonetic corrections like "Shunade" → "Sinead" (dist 4/7 = 0.57)
// while filtering out unrelated word replacements.
diff --git a/src/utils/serverUtils.js b/src/utils/serverUtils.js
index 0d0362b73..a51665169 100644
--- a/src/utils/serverUtils.js
+++ b/src/utils/serverUtils.js
@@ -1,5 +1,6 @@
const fs = require("fs");
const net = require("net");
+const os = require("os");
const path = require("path");
const { killProcessGroup } = require("./process");
@@ -75,9 +76,17 @@ async function gracefulStopProcess(proc) {
});
}
+// Logical CPUs this process may use: unlike os.cpus().length this honours
+// affinity masks and container limits, so inference thread counts fit the
+// cores the sidecar will actually get.
+function getAvailableParallelism() {
+ return os.availableParallelism();
+}
+
module.exports = {
findAvailablePort,
isPortAvailable,
resolveBinaryPath,
gracefulStopProcess,
+ getAvailableParallelism,
};
diff --git a/test/helpers/correctionLearner.test.js b/test/helpers/correctionLearner.test.js
index d8ef8ec7f..f3c2d1f96 100644
--- a/test/helpers/correctionLearner.test.js
+++ b/test/helpers/correctionLearner.test.js
@@ -43,6 +43,12 @@ test("unrelated word swaps are filtered by edit distance — cat to elephant is
assert.ok(!result.includes("elephant"));
});
+test("swapping one everyday word for another is a content edit, not vocabulary", () => {
+ const original = "This is why I'm speaking";
+ assert.deepEqual(extractCorrections(original, "This is what I'm speaking", []), []);
+ assert.deepEqual(extractCorrections(original, "This is where I'm speaking", []), []);
+});
+
test("a non-array dictionary is tolerated", () => {
const result = extractCorrections("Hey Shunade", "Hey Sinead", null);
assert.ok(result.includes("Sinead"));
diff --git a/test/helpers/parakeetServer.test.js b/test/helpers/parakeetServer.test.js
index ec1af0540..bbb9a5a4c 100644
--- a/test/helpers/parakeetServer.test.js
+++ b/test/helpers/parakeetServer.test.js
@@ -35,10 +35,11 @@ function wavFromSeconds(spans) {
return buf;
}
-function fakeWsServer(responses, { onCall } = {}) {
+function fakeWsServer(responses, { onCall, maxConcurrentDecodes = 1 } = {}) {
const calls = [];
return {
calls,
+ maxConcurrentDecodes,
async start() {},
async transcribe(samplesBuffer) {
calls.push(samplesBuffer.length);
@@ -182,6 +183,49 @@ test("transcribe without a signal is unchanged", async () => {
assert.equal(fake.calls.length, 3);
});
+test("segments decode side by side up to the server's limit and rejoin in order", async () => {
+ const pending = [];
+ const fake = {
+ maxConcurrentDecodes: 2,
+ async start() {},
+ transcribe: () => new Promise((resolve) => pending.push(resolve)),
+ };
+ const manager = managerWith(fake);
+ const flush = () => new Promise((resolve) => setImmediate(resolve));
+
+ const transcription = manager.transcribe(wavFromSeconds([{ seconds: 31 }]));
+ await flush();
+ assert.equal(pending.length, 2, "two segments in flight, the third waits for a slot");
+
+ pending[1]({ text: "two", elapsed: 1 });
+ pending[0]({ text: "one", elapsed: 1 });
+ await flush();
+ assert.equal(pending.length, 3);
+ pending[2]({ text: "three", elapsed: 1 });
+
+ const result = await transcription;
+ assert.equal(result.text, "one two three");
+ assert.equal(result.elapsed, 3);
+});
+
+test("a failing segment stops further segments from being scheduled", async () => {
+ const fake = fakeWsServer(
+ [{ text: "one" }, { text: "two" }, { text: "three" }, { text: "four" }, { text: "five" }],
+ { maxConcurrentDecodes: 2 }
+ );
+ const baseTranscribe = fake.transcribe;
+ fake.transcribe = async (samplesBuffer) => {
+ const isFirstCall = fake.calls.length === 0;
+ const result = await baseTranscribe(samplesBuffer);
+ if (isFirstCall) throw new Error("parakeet-ws transcription timed out");
+ return result;
+ };
+ const manager = managerWith(fake);
+
+ await assert.rejects(() => manager.transcribe(wavFromSeconds([{ seconds: 61 }])), /timed out/);
+ assert.equal(fake.calls.length, 2, "only the two already in flight ran");
+});
+
test("cohere models segment at 30s and start the server with the resolved language", async () => {
const fake = fakeWsServer([{ text: "one" }, { text: "two" }]);
const startArgs = [];
diff --git a/test/helpers/parakeetWsStartup.test.js b/test/helpers/parakeetWsStartup.test.js
index d02b51bd8..4bdff6edf 100644
--- a/test/helpers/parakeetWsStartup.test.js
+++ b/test/helpers/parakeetWsStartup.test.js
@@ -44,12 +44,14 @@ async function startupArgs(modelName, runtime = "offline", language = null, regi
return child;
},
},
- os: { cpus: () => Array(8).fill({}) },
"./parakeetModelInfo": modelInfo,
"./debugLogger": { debug() {}, info() {} },
"./sidecarPidFile": { write() {} },
"./safeTempDir": { getSafeTempDir: () => os.tmpdir() },
- "../utils/serverUtils": { findAvailablePort: async () => 6006 },
+ "../utils/serverUtils": {
+ findAvailablePort: async () => 6006,
+ getAvailableParallelism: () => 8,
+ },
});
const server = new Server();
server.getWsBinaryPath = (mode) => `sherpa-${mode}`;
@@ -73,6 +75,7 @@ for (const modelName of ["parakeet-tdt-0.6b-v3", "orukeet-v0.1.0"]) {
"--model-type=nemo_transducer",
"--port=6006",
"--num-threads=4",
+ "--num-work-threads=3",
]);
});
}
@@ -92,6 +95,7 @@ test("Cohere keeps its language-specific startup arguments", async () => {
"--cohere-transcribe-language=fr",
"--port=6006",
"--num-threads=4",
+ "--num-work-threads=3",
]);
});
diff --git a/test/helpers/systemDefaultMicrophone.test.js b/test/helpers/systemDefaultMicrophone.test.js
index 6d3590163..fbabdec47 100644
--- a/test/helpers/systemDefaultMicrophone.test.js
+++ b/test/helpers/systemDefaultMicrophone.test.js
@@ -27,19 +27,66 @@ test("parses a PulseAudio default source", () => {
});
});
-test("resolver caches a successful platform result briefly", async () => {
+function wpctlResolver({ now = () => 100, respond } = {}) {
let calls = 0;
const resolve = helper.createSystemDefaultMicrophoneResolver({
platform: "linux",
- now: () => 100,
- run: async (command) => {
+ now,
+ run: (command) => {
calls += 1;
- if (command === "wpctl") return 'node.description = "Desk Microphone"';
- throw new Error("unexpected command");
+ if (command !== "wpctl") throw new Error("unexpected command");
+ return respond ? respond() : 'node.description = "Desk Microphone"';
},
});
+ return { resolve, calls: () => calls };
+}
+
+test("resolver keeps a successful lookup until asked to refresh", async () => {
+ const { resolve, calls } = wpctlResolver();
assert.equal((await resolve()).name, "Desk Microphone");
assert.equal((await resolve()).name, "Desk Microphone");
- assert.equal(calls, 1);
+ assert.equal(calls(), 1);
+
+ await resolve({ refresh: true });
+ assert.equal(calls(), 2);
+});
+
+test("resolver retries a failed lookup only after the back-off", async () => {
+ let clock = 0;
+ let calls = 0;
+ const resolve = helper.createSystemDefaultMicrophoneResolver({
+ platform: "linux",
+ now: () => clock,
+ run: async () => {
+ calls += 1;
+ throw new Error("no audio server");
+ },
+ });
+
+ assert.equal((await resolve()).source, "unavailable");
+ clock = 1000;
+ await resolve();
+ assert.equal(calls, 2, "wpctl then pactl, no retry inside the back-off");
+ clock = 31000;
+ await resolve();
+ assert.equal(calls, 4);
+});
+
+test("concurrent lookups share one process", async () => {
+ let release;
+ const { resolve, calls } = wpctlResolver({
+ respond: () =>
+ new Promise((done) => {
+ release = () => done('node.description = "Desk Microphone"');
+ }),
+ });
+
+ const first = resolve();
+ const second = resolve({ refresh: true });
+ release();
+
+ assert.equal((await first).name, "Desk Microphone");
+ assert.equal((await second).name, "Desk Microphone");
+ assert.equal(calls(), 1);
});