fix: set tts conversion output formats

This commit is contained in:
Shakker
2026-05-08 11:12:25 +01:00
parent e1e9cd82c1
commit 150b869cf8
2 changed files with 15 additions and 4 deletions

View File

@@ -80,7 +80,18 @@ describe("buildCliSpeechProvider", () => {
if (typeof outputPath !== "string") {
throw new Error("missing ffmpeg output path");
}
writeFileSync(outputPath, Buffer.from(`converted:${path.extname(outputPath)}`));
const forcedFormatIndex = args.lastIndexOf("-f");
const forcedFormat =
forcedFormatIndex >= 0 && typeof args[forcedFormatIndex + 1] === "string"
? args[forcedFormatIndex + 1]
: undefined;
const extension =
forcedFormat === "s16le"
? ".pcm"
: forcedFormat
? `.${forcedFormat}`
: path.extname(outputPath);
writeFileSync(outputPath, Buffer.from(`converted:${extension}`));
});
});

View File

@@ -275,11 +275,11 @@ async function convertAudio(
const outputPath = path.join(outputDir, outputFileName);
const args = ["-y", "-i", inputPath];
if (target === "opus") {
args.push("-c:a", "libopus", "-b:a", "64k");
args.push("-c:a", "libopus", "-b:a", "64k", "-f", "opus");
} else if (target === "wav") {
args.push("-c:a", "pcm_s16le");
args.push("-c:a", "pcm_s16le", "-f", "wav");
} else {
args.push("-c:a", "libmp3lame", "-b:a", "128k");
args.push("-c:a", "libmp3lame", "-b:a", "128k", "-f", "mp3");
}
await writeExternalFileWithinRoot({
rootDir: outputDir,