klaudio 0.12.4 → 0.12.6
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/package.json +1 -1
- package/src/player.js +11 -2
- package/src/tts.js +6 -8
package/package.json
CHANGED
package/src/player.js
CHANGED
|
@@ -467,10 +467,19 @@ export async function handlePlayCommand(args) {
|
|
|
467
467
|
const project = hookData.cwd ? hookData.cwd.replace(/\\/g, "/").split("/").pop() : null;
|
|
468
468
|
const spoken = project ? `${project}: ${summary}` : summary;
|
|
469
469
|
await soundPromise;
|
|
470
|
-
const { speak } = await import("./tts.js");
|
|
471
470
|
const voice = args.find((a) => a.startsWith("--voice="))?.slice(8)
|
|
472
471
|
|| args[args.indexOf("--voice") + 1];
|
|
473
|
-
|
|
472
|
+
// Spawn a detached child process for TTS so the hook can exit immediately
|
|
473
|
+
const { spawn } = await import("node:child_process");
|
|
474
|
+
const child = spawn(process.execPath, [
|
|
475
|
+
"--input-type=module",
|
|
476
|
+
"-e",
|
|
477
|
+
`import{speak}from"${import.meta.resolve("./tts.js")}";await speak(${JSON.stringify(spoken)},{voice:${JSON.stringify(voice || undefined)}});`,
|
|
478
|
+
], {
|
|
479
|
+
detached: true,
|
|
480
|
+
stdio: "ignore",
|
|
481
|
+
});
|
|
482
|
+
child.unref();
|
|
474
483
|
} else {
|
|
475
484
|
await soundPromise;
|
|
476
485
|
}
|
package/src/tts.js
CHANGED
|
@@ -373,12 +373,7 @@ export async function speak(text, options = {}) {
|
|
|
373
373
|
? { voice: null, onProgress: options } // backwards compat: speak(text, onProgress)
|
|
374
374
|
: options;
|
|
375
375
|
|
|
376
|
-
//
|
|
377
|
-
if (platform() === "darwin") {
|
|
378
|
-
return speakMacOS(text);
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
// Try Kokoro (best quality, Linux/Windows)
|
|
376
|
+
// Try Kokoro (best quality)
|
|
382
377
|
if (await isKokoroAvailable()) {
|
|
383
378
|
try {
|
|
384
379
|
await speakKokoro(text, voice);
|
|
@@ -388,8 +383,11 @@ export async function speak(text, options = {}) {
|
|
|
388
383
|
}
|
|
389
384
|
}
|
|
390
385
|
|
|
391
|
-
// Fallback: Piper
|
|
392
|
-
|
|
386
|
+
// Fallback: Piper (Linux/Windows), then macOS say
|
|
387
|
+
if (platform() !== "darwin") {
|
|
388
|
+
return speakPiper(text, onProgress);
|
|
389
|
+
}
|
|
390
|
+
return speakMacOS(text);
|
|
393
391
|
} finally {
|
|
394
392
|
speaking = false;
|
|
395
393
|
await releaseTTSLock();
|