fix(cli): restore tts --text-file compatibility (#2117)

This commit is contained in:
Miguel Ángel
2026-07-09 21:45:35 -04:00
committed by GitHub
parent 7bd8c0942e
commit ef38321d5d
2 changed files with 53 additions and 3 deletions
+8 -3
View File
@@ -46,6 +46,10 @@ export default defineCommand({
description: "Text to speak, or path to a .txt file",
required: false,
},
"text-file": {
type: "string",
description: "Read text from a .txt file (compatibility alias)",
},
output: {
type: "string",
description: "Output file path (default: speech.wav in current directory)",
@@ -85,13 +89,14 @@ export default defineCommand({
}
// ── Resolve input text ────────────────────────────────────────────
if (!args.input) {
const input = args["text-file"] ?? args.input;
if (!input) {
console.error(c.error("Provide text to speak, or use --list to see available voices."));
process.exit(1);
}
let text: string;
const maybeFile = resolve(args.input);
const maybeFile = resolve(input);
if (existsSync(maybeFile) && extname(maybeFile).toLowerCase() === ".txt") {
text = readFileSync(maybeFile, "utf-8").trim();
@@ -100,7 +105,7 @@ export default defineCommand({
process.exit(1);
}
} else {
text = args.input;
text = input;
}
if (!text.trim()) {