Skip to content

Commit 132584e

Browse files
committed
perf(windows): use 75% of CPU cores for whisper inference
On macOS Metal GPU handles compute so thread count is less critical. On Windows (CPU-only), whisper defaults to 4 threads which wastes available cores. Using 75% of available cores nearly halves inference time on a 16-core system (7.6s -> 4.0s for 11s of audio).
1 parent 60dbdfd commit 132584e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/main/audio/whisper.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,16 @@ export async function transcribe(
4747
}
4848
}
4949

50+
// On macOS Metal handles compute, so threads are less critical.
51+
// On Windows/Linux (CPU-only), using ~75% of cores gives the best throughput
52+
// without starving the OS. Minimum 4 to avoid slowdowns on low-core machines.
53+
const WHISPER_THREADS = process.platform === "darwin"
54+
? 4
55+
: Math.max(4, Math.floor(os.cpus().length * 0.75));
56+
5057
function runWhisper(modelPath: string, filePath: string, prompt: string, language = "auto", temperature?: number): Promise<string> {
5158
const args = [
59+
"-t", String(WHISPER_THREADS),
5260
"-l", language,
5361
"-m", modelPath,
5462
"-f", filePath,

0 commit comments

Comments
 (0)