Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions skills/media-use/audio/scripts/lib/tts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,22 @@ save(audio, sys.argv[3])
// [{text,start,end}] array for HeyGen (native), or null for ElevenLabs/Kokoro
// (caller must transcribeWav). Never throws; failures return { ok:false, error }
// where `error` states WHY (so the caller can surface it, not a bare "TTS failed").
export function buildKokoroTtsArgs({ textPath, voiceId, wavRel, lang = "en", speed = 1.0 }) {
const args = [
"hyperframes",
"tts",
textPath,
"--voice",
voiceId,
"--output",
wavRel,
"--speed",
String(speed),
];
if (lang !== "en") args.push("--lang", lang);
return args;
}

export async function synthesizeOne({
provider,
text,
Expand Down Expand Up @@ -276,8 +292,13 @@ export async function synthesizeOne({
}
// kokoro — via the published CLI; --output is relative to the project dir.
const wavRel = relTo(hyperframesDir, wavAbs);
const args = ["hyperframes", "tts", writeTmpText(text), "--voice", voiceId, "--output", wavRel];
if (lang !== "en") args.push("--lang", lang);
const args = buildKokoroTtsArgs({
textPath: writeTmpText(text),
voiceId,
wavRel,
lang,
speed,
});
const r = await spawnP("npx", args, { cwd: hyperframesDir });
return synthResult(r, wavAbs, "kokoro (npx hyperframes tts)");
}
Expand Down
23 changes: 23 additions & 0 deletions skills/media-use/audio/scripts/lib/tts.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,31 @@ import {
synthesizeOne,
synthesizeHeygen,
synthResult,
buildKokoroTtsArgs,
} from "./tts.mjs";

test("forwards a non-default speed to the Kokoro CLI", () => {
const args = buildKokoroTtsArgs({
textPath: "/tmp/narration.txt",
voiceId: "am_michael",
wavRel: "audio/narration.wav",
lang: "en",
speed: 1.15,
});

assert.deepEqual(args, [
"hyperframes",
"tts",
"/tmp/narration.txt",
"--voice",
"am_michael",
"--output",
"audio/narration.wav",
"--speed",
"1.15",
]);
});

test("parseFfmpegDurationBanner reads ffmpeg's stderr Duration line", () => {
const stderr = [
"ffmpeg version 6.0",
Expand Down
Loading