use-voice-control 0.1.95 → 0.1.97
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/dist/cli-CXzTD4W4.js +338 -0
- package/dist/cli-CXzTD4W4.js.map +1 -0
- package/dist/cli.js +2 -374
- package/dist/client-CwHmea9T.js +229 -0
- package/dist/client-CwHmea9T.js.map +1 -0
- package/dist/client.js +3 -276
- package/dist/index.js +45 -55
- package/dist/index.js.map +1 -1
- package/dist/kokoro-node-CDhCeD6u.js +115 -0
- package/dist/kokoro-node-CDhCeD6u.js.map +1 -0
- package/dist/markdown.js +179 -206
- package/dist/markdown.js.map +1 -1
- package/dist/node.js +4 -27
- package/dist/react.js +188 -211
- package/dist/react.js.map +1 -1
- package/dist/semantic-split-DF26uo-Z.js +36 -0
- package/dist/semantic-split-DF26uo-Z.js.map +1 -0
- package/package.json +14 -14
- package/dist/cli.js.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/kokoro-node-DJ_Rxp_N.js +0 -144
- package/dist/kokoro-node-DJ_Rxp_N.js.map +0 -1
- package/dist/node.js.map +0 -1
- package/dist/semantic-split-CXhk-k1F.js +0 -44
- package/dist/semantic-split-CXhk-k1F.js.map +0 -1
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import { l as e, o as t, r as n, s as r, u as i } from "./kokoro-node-CDhCeD6u.js";
|
|
2
|
+
import { looksLikeMarkdown as a, markdownToSpeech as o } from "./markdown.js";
|
|
3
|
+
//#region speech/node/document.ts
|
|
4
|
+
var s = [
|
|
5
|
+
".md",
|
|
6
|
+
".markdown",
|
|
7
|
+
".mdown",
|
|
8
|
+
".mkd",
|
|
9
|
+
".mdx"
|
|
10
|
+
], c = [
|
|
11
|
+
".txt",
|
|
12
|
+
".text",
|
|
13
|
+
""
|
|
14
|
+
];
|
|
15
|
+
function l(e) {
|
|
16
|
+
let t = e.split(/[\\/]/).pop() ?? "", n = t.lastIndexOf(".");
|
|
17
|
+
return n > 0 ? t.slice(n).toLowerCase() : "";
|
|
18
|
+
}
|
|
19
|
+
function u(e, t, n = "auto") {
|
|
20
|
+
if (n !== "auto") return n;
|
|
21
|
+
if (t) {
|
|
22
|
+
let e = l(t);
|
|
23
|
+
if (s.includes(e)) return "markdown";
|
|
24
|
+
if (c.includes(e)) return "text";
|
|
25
|
+
}
|
|
26
|
+
return a(e) ? "markdown" : "text";
|
|
27
|
+
}
|
|
28
|
+
function d(e, t, n = {}) {
|
|
29
|
+
return t === "text" ? e.replace(/\r\n?/g, "\n").trim() : o(e, n);
|
|
30
|
+
}
|
|
31
|
+
async function f(e) {
|
|
32
|
+
let { file: t, text: n, format: r = "auto", markdown: i = {} } = e;
|
|
33
|
+
if (n !== void 0) {
|
|
34
|
+
let e = u(n, void 0, r);
|
|
35
|
+
return {
|
|
36
|
+
text: d(n, e, i),
|
|
37
|
+
format: e,
|
|
38
|
+
source: "--text"
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (!t) throw Error("No input: pass a file path, `-` for stdin, or --text");
|
|
42
|
+
if (t === "-") {
|
|
43
|
+
let t = e.readStdin ? await e.readStdin() : await p(), n = u(t, void 0, r);
|
|
44
|
+
return {
|
|
45
|
+
text: d(t, n, i),
|
|
46
|
+
format: n,
|
|
47
|
+
source: "stdin"
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
let { readFile: a } = await import("node:fs/promises"), o = await a(t, "utf8"), s = u(o, t, r);
|
|
51
|
+
return {
|
|
52
|
+
text: d(o, s, i),
|
|
53
|
+
format: s,
|
|
54
|
+
source: t
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
async function p() {
|
|
58
|
+
let e = [];
|
|
59
|
+
for await (let t of process.stdin) e.push(Buffer.isBuffer(t) ? t : Buffer.from(t));
|
|
60
|
+
return Buffer.concat(e).toString("utf8");
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region speech/node/render.ts
|
|
64
|
+
function m(e) {
|
|
65
|
+
let t = l(e);
|
|
66
|
+
return `${t ? e.slice(0, -t.length) : e}.wav`;
|
|
67
|
+
}
|
|
68
|
+
async function h(e) {
|
|
69
|
+
let i = await f(e);
|
|
70
|
+
if (!i.text.trim()) throw Error(`Nothing to speak: ${i.source} has no readable text`);
|
|
71
|
+
let { samples: a, sampleRate: o } = await (e.synthesize ?? n)(i.text, e), s = t(a, o), c = e.output ?? (e.file && e.file !== "-" ? m(e.file) : "out.wav");
|
|
72
|
+
if (c === "-") process.stdout.write(Buffer.from(s));
|
|
73
|
+
else {
|
|
74
|
+
let { writeFile: e } = await import("node:fs/promises");
|
|
75
|
+
await e(c, Buffer.from(s));
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
output: c,
|
|
79
|
+
text: i.text,
|
|
80
|
+
format: i.format,
|
|
81
|
+
source: i.source,
|
|
82
|
+
durationSeconds: r(a, o),
|
|
83
|
+
bytes: s.byteLength
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region speech/node/cli.ts
|
|
88
|
+
var g = {
|
|
89
|
+
auto: "auto",
|
|
90
|
+
markdown: "markdown",
|
|
91
|
+
md: "markdown",
|
|
92
|
+
text: "text",
|
|
93
|
+
txt: "text",
|
|
94
|
+
plain: "text"
|
|
95
|
+
}, _ = [
|
|
96
|
+
"fp32",
|
|
97
|
+
"fp16",
|
|
98
|
+
"q8",
|
|
99
|
+
"q4",
|
|
100
|
+
"q4f16"
|
|
101
|
+
], v = [
|
|
102
|
+
"wasm",
|
|
103
|
+
"webgpu",
|
|
104
|
+
"cpu"
|
|
105
|
+
], y = "use-voice-control — read a Markdown or text file aloud into an audio file\n\nUsage\n npx use-voice-control <file.md|file.txt|-> [options]\n npx use-voice-control --text \"Hello there\" -o hello.wav\n cat notes.md | npx use-voice-control - -o notes.wav\n\nMarkdown is converted before it is spoken: \"#\", \"**\" and the rest are not read\nout, headings become their own spoken lines, links keep their text, and fenced\ncode blocks are announced instead of being spelled out.\n\nInput\n <file> File to read. Use \"-\" to read stdin.\n --text <string> Speak this string instead of reading a file.\n -f, --format <fmt> auto (default), markdown, or text.\n\nOutput\n -o, --out <file> Audio file to write. Default: the input path with a\n .wav extension. Use \"-\" to write the WAV to stdout.\n -p, --print Print the speakable text and exit — no model, no audio.\n Useful for checking the Markdown conversion.\n -q, --quiet No progress output.\n\nVoice\n -v, --voice <id> Voice id. Default af_heart. See --list-voices.\n -s, --speed <n> Speaking rate, 0.5-2. Default 1.\n --list-voices Print the available voices and exit.\n\nMarkdown handling\n --headings <mode> text (default) | announce | skip\n --code <mode> announce (default) | read | skip\n --links <mode> text (default) | text-and-url\n --tables <mode> rows (default) | skip\n --front-matter Read the YAML front matter instead of skipping it.\n\nModel\n --model <id> Hugging Face model id.\n Default onnx-community/Kokoro-82M-v1.0-ONNX.\n --dtype <type> fp32 | fp16 | q8 (default) | q4 | q4f16\n --device <device> cpu (default) | wasm | webgpu\n --chunk <chars> Target characters per synthesis chunk. Default 400.\n --gap <ms> Silence between chunks. Default 120.\n\nOther\n -h, --help Show this help.\n -V, --version Print the package version.\n\nThe first run downloads the Kokoro weights (about 90 MB at the default q8) into\nthe Hugging Face cache; later runs are offline. Speech is synthesized locally —\nno text leaves the machine.";
|
|
106
|
+
function b(e, t, n, r) {
|
|
107
|
+
let i = e[t + 1];
|
|
108
|
+
return i === void 0 || i.startsWith("-") ? (r.push(`${n} needs a value`), { next: t + 1 }) : {
|
|
109
|
+
value: i,
|
|
110
|
+
next: t + 1
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function x(e, t, n) {
|
|
114
|
+
if (e === void 0) return;
|
|
115
|
+
let r = Number(e);
|
|
116
|
+
if (!Number.isFinite(r)) {
|
|
117
|
+
n.push(`${t} expects a number, got "${e}"`);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
return r;
|
|
121
|
+
}
|
|
122
|
+
function S(e, t, n, r) {
|
|
123
|
+
if (e !== void 0) {
|
|
124
|
+
if (!t.includes(e)) {
|
|
125
|
+
r.push(`${n} expects one of ${t.join(", ")} — got "${e}"`);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
return e;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function C(t) {
|
|
132
|
+
let n = [], r = {}, i = {
|
|
133
|
+
command: "speak",
|
|
134
|
+
format: "auto",
|
|
135
|
+
voice: "af_heart",
|
|
136
|
+
speed: 1,
|
|
137
|
+
markdown: r,
|
|
138
|
+
quiet: !1,
|
|
139
|
+
errors: n
|
|
140
|
+
}, a = !1;
|
|
141
|
+
for (let o = 0; o < t.length; o += 1) {
|
|
142
|
+
let s = t[o];
|
|
143
|
+
if (a || !s.startsWith("-") || s === "-") {
|
|
144
|
+
i.input === void 0 ? i.input = s : n.push(`unexpected extra input "${s}" — pass one file at a time`);
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (s === "--") {
|
|
148
|
+
a = !0;
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
let c = s.indexOf("=");
|
|
152
|
+
if (c > 1) {
|
|
153
|
+
t.splice(o, 1, s.slice(0, c), s.slice(c + 1)), --o;
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
switch (s) {
|
|
157
|
+
case "-h":
|
|
158
|
+
case "--help": return i.command = "help", i;
|
|
159
|
+
case "-V":
|
|
160
|
+
case "--version": return i.command = "version", i;
|
|
161
|
+
case "--list-voices": return i.command = "list-voices", i;
|
|
162
|
+
case "-p":
|
|
163
|
+
case "--print":
|
|
164
|
+
case "--dry-run":
|
|
165
|
+
i.command = "print";
|
|
166
|
+
break;
|
|
167
|
+
case "-q":
|
|
168
|
+
case "--quiet":
|
|
169
|
+
i.quiet = !0;
|
|
170
|
+
break;
|
|
171
|
+
case "--front-matter":
|
|
172
|
+
r.frontMatter = !0;
|
|
173
|
+
break;
|
|
174
|
+
case "-o":
|
|
175
|
+
case "--out":
|
|
176
|
+
case "--output": {
|
|
177
|
+
let { value: e, next: r } = b(t, o, s, n);
|
|
178
|
+
i.output = e, o = r;
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
case "--text": {
|
|
182
|
+
let e = t[o + 1];
|
|
183
|
+
e === void 0 ? n.push("--text needs a value") : i.text = e, o += 1;
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
case "-f":
|
|
187
|
+
case "--format": {
|
|
188
|
+
let { value: e, next: r } = b(t, o, s, n);
|
|
189
|
+
if (o = r, e !== void 0) {
|
|
190
|
+
let t = g[e.toLowerCase()];
|
|
191
|
+
t ? i.format = t : n.push(`--format expects auto, markdown or text — got "${e}"`);
|
|
192
|
+
}
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
case "-v":
|
|
196
|
+
case "--voice": {
|
|
197
|
+
let { value: r, next: a } = b(t, o, s, n);
|
|
198
|
+
o = a, r !== void 0 && (e.includes(r) ? i.voice = r : n.push(`unknown voice "${r}" — run --list-voices to see them all`));
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
case "-s":
|
|
202
|
+
case "--speed": {
|
|
203
|
+
let { value: e, next: r } = b(t, o, s, n);
|
|
204
|
+
o = r;
|
|
205
|
+
let a = x(e, s, n);
|
|
206
|
+
a !== void 0 && (a < .5 || a > 2 ? n.push("--speed must be between 0.5 and 2") : i.speed = a);
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
case "--model": {
|
|
210
|
+
let { value: e, next: r } = b(t, o, s, n);
|
|
211
|
+
i.model = e, o = r;
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
case "--dtype": {
|
|
215
|
+
let { value: e, next: r } = b(t, o, s, n);
|
|
216
|
+
o = r, i.dtype = S(e, _, s, n) ?? i.dtype;
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
case "--device": {
|
|
220
|
+
let { value: e, next: r } = b(t, o, s, n);
|
|
221
|
+
o = r, i.device = S(e, v, s, n) ?? i.device;
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
case "--chunk":
|
|
225
|
+
case "--chunk-length": {
|
|
226
|
+
let { value: e, next: r } = b(t, o, s, n);
|
|
227
|
+
o = r;
|
|
228
|
+
let a = x(e, s, n);
|
|
229
|
+
a !== void 0 && (a < 40 ? n.push("--chunk must be at least 40 characters") : i.maxChunkLength = a);
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
case "--gap": {
|
|
233
|
+
let { value: e, next: r } = b(t, o, s, n);
|
|
234
|
+
o = r;
|
|
235
|
+
let a = x(e, s, n);
|
|
236
|
+
a !== void 0 && (a < 0 ? n.push("--gap cannot be negative") : i.gapMs = a);
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
case "--headings": {
|
|
240
|
+
let { value: e, next: i } = b(t, o, s, n);
|
|
241
|
+
o = i, r.headings = S(e, [
|
|
242
|
+
"text",
|
|
243
|
+
"announce",
|
|
244
|
+
"skip"
|
|
245
|
+
], s, n) ?? r.headings;
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
case "--code":
|
|
249
|
+
case "--code-blocks": {
|
|
250
|
+
let { value: e, next: i } = b(t, o, s, n);
|
|
251
|
+
o = i, r.codeBlocks = S(e, [
|
|
252
|
+
"announce",
|
|
253
|
+
"read",
|
|
254
|
+
"skip"
|
|
255
|
+
], s, n) ?? r.codeBlocks;
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
case "--links": {
|
|
259
|
+
let { value: e, next: i } = b(t, o, s, n);
|
|
260
|
+
o = i, r.links = S(e, ["text", "text-and-url"], s, n) ?? r.links;
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
case "--tables": {
|
|
264
|
+
let { value: e, next: i } = b(t, o, s, n);
|
|
265
|
+
o = i, r.tables = S(e, ["rows", "skip"], s, n) ?? r.tables;
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
default: n.push(`unknown option "${s}" — run --help to see the options`);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return i.text !== void 0 && i.input !== void 0 && n.push("pass either a file or --text, not both"), i;
|
|
272
|
+
}
|
|
273
|
+
function w() {
|
|
274
|
+
let t = e.map((e) => {
|
|
275
|
+
let t = i(e);
|
|
276
|
+
return ` ${e.padEnd(14)}${t.name.padEnd(12)}${t.gender.padEnd(8)}${t.accent}`;
|
|
277
|
+
});
|
|
278
|
+
return [`${e.length} Kokoro voices:`, ...t].join("\n");
|
|
279
|
+
}
|
|
280
|
+
async function T() {
|
|
281
|
+
try {
|
|
282
|
+
let { readFile: e } = await import("node:fs/promises");
|
|
283
|
+
for (let t of ["../package.json", "../../package.json"]) try {
|
|
284
|
+
let n = new URL(t, import.meta.url), r = JSON.parse(await e(n, "utf8"));
|
|
285
|
+
if (r?.name === "use-voice-control" && r.version) return r.version;
|
|
286
|
+
} catch {}
|
|
287
|
+
} catch {}
|
|
288
|
+
return "unknown";
|
|
289
|
+
}
|
|
290
|
+
async function E(e, t = {}) {
|
|
291
|
+
let n = t.log ?? ((e) => process.stdout.write(`${e}\n`)), r = t.error ?? ((e) => process.stderr.write(`${e}\n`)), i = C([...e]);
|
|
292
|
+
if (i.command === "help") return n(y), 0;
|
|
293
|
+
if (i.command === "version") return n(await T()), 0;
|
|
294
|
+
if (i.command === "list-voices") return n(w()), 0;
|
|
295
|
+
if (i.errors.length > 0) return i.errors.forEach((e) => r(`use-voice-control: ${e}`)), r("Run `npx use-voice-control --help` for usage."), 1;
|
|
296
|
+
let a = t.stdinIsTTY ?? !!process.stdin.isTTY, o = i.input ?? (i.text === void 0 && !a ? "-" : void 0);
|
|
297
|
+
if (o === void 0 && i.text === void 0) return r("use-voice-control: no input — pass a file, pipe text in, or use --text"), r("Run `npx use-voice-control --help` for usage."), 1;
|
|
298
|
+
let s = {
|
|
299
|
+
file: o,
|
|
300
|
+
text: i.text,
|
|
301
|
+
format: i.format,
|
|
302
|
+
markdown: i.markdown,
|
|
303
|
+
readStdin: t.readStdin
|
|
304
|
+
};
|
|
305
|
+
try {
|
|
306
|
+
if (i.command === "print") return n((await f(s)).text), 0;
|
|
307
|
+
let e = Date.now(), a = await h({
|
|
308
|
+
...s,
|
|
309
|
+
output: i.output,
|
|
310
|
+
voice: i.voice,
|
|
311
|
+
speed: i.speed,
|
|
312
|
+
model: i.model,
|
|
313
|
+
dtype: i.dtype,
|
|
314
|
+
device: i.device,
|
|
315
|
+
maxChunkLength: i.maxChunkLength,
|
|
316
|
+
gapMs: i.gapMs,
|
|
317
|
+
synthesize: t.synthesize,
|
|
318
|
+
onModelProgress: i.quiet ? void 0 : (e) => {
|
|
319
|
+
if (e?.status === "progress" && e.file && e.total) {
|
|
320
|
+
let t = Math.round((e.loaded ?? 0) / e.total * 100);
|
|
321
|
+
r(`downloading ${e.file}: ${t}%`);
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
onChunk: i.quiet ? void 0 : ({ index: e, total: t }) => r(`speaking chunk ${e + 1}/${t}`)
|
|
325
|
+
});
|
|
326
|
+
if (!i.quiet) {
|
|
327
|
+
let t = a.durationSeconds.toFixed(1), n = ((Date.now() - e) / 1e3).toFixed(1);
|
|
328
|
+
r(`wrote ${a.output === "-" ? "stdout" : a.output} — ${t}s of audio from ${a.source} in ${n}s`);
|
|
329
|
+
}
|
|
330
|
+
return 0;
|
|
331
|
+
} catch (e) {
|
|
332
|
+
return r(`use-voice-control: ${e instanceof Error ? e.message : String(e)}`), 1;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
//#endregion
|
|
336
|
+
export { m as a, c, f as d, p as f, E as i, u as l, w as n, h as o, d as p, C as r, s, y as t, l as u };
|
|
337
|
+
|
|
338
|
+
//# sourceMappingURL=cli-CXzTD4W4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-CXzTD4W4.js","names":[],"sources":["../speech/node/document.ts","../speech/node/render.ts","../speech/node/cli.ts"],"sourcesContent":["/**\n * @fileoverview Turning a document on disk (or on stdin) into speakable text.\n *\n * A `.md` file is converted with `markdownToSpeech` so the marks become\n * structure rather than words; a `.txt` file is passed through as it is. When\n * the source has no filename — piped stdin, a `--text` string — the format is\n * guessed from the content.\n */\nimport {\n looksLikeMarkdown,\n markdownToSpeech,\n type MarkdownToSpeechOptions,\n} from \"../utils/markdown-to-speech\";\n\nexport type DocumentFormat = \"markdown\" | \"text\";\n/** What the caller asked for; `auto` defers to the extension, then the content. */\nexport type RequestedFormat = DocumentFormat | \"auto\";\n\n/** Extensions read as Markdown. Everything else is treated as plain text. */\nexport const MARKDOWN_EXTENSIONS = [\".md\", \".markdown\", \".mdown\", \".mkd\", \".mdx\"];\n\n/** Extensions the CLI accepts without complaint. Others still work, with a warning. */\nexport const TEXT_EXTENSIONS = [\".txt\", \".text\", \"\"];\n\n/** Lowercased extension of a path, including the dot (`\"\"` when there is none). */\nexport function extensionOf(filename: string): string {\n const base = filename.split(/[\\\\/]/).pop() ?? \"\";\n const dot = base.lastIndexOf(\".\");\n return dot > 0 ? base.slice(dot).toLowerCase() : \"\";\n}\n\n/**\n * Decides how to read a document.\n *\n * An explicit `requested` format always wins — a `.txt` file full of Markdown is\n * still the user's call. Otherwise the extension decides, and content sniffing\n * is the last resort for input that arrived without a name.\n */\nexport function detectFormat(\n content: string,\n filename?: string,\n requested: RequestedFormat = \"auto\"\n): DocumentFormat {\n if (requested !== \"auto\") return requested;\n\n if (filename) {\n const extension = extensionOf(filename);\n if (MARKDOWN_EXTENSIONS.includes(extension)) return \"markdown\";\n if (TEXT_EXTENSIONS.includes(extension)) return \"text\";\n }\n\n return looksLikeMarkdown(content) ? \"markdown\" : \"text\";\n}\n\n/** Converts document content to the text that should be spoken. */\nexport function toSpeechText(\n content: string,\n format: DocumentFormat,\n options: MarkdownToSpeechOptions = {}\n): string {\n if (format === \"text\") {\n // Plain text is already speakable; only normalise line endings and the\n // trailing whitespace that would otherwise become an empty final chunk.\n return content.replace(/\\r\\n?/g, \"\\n\").trim();\n }\n return markdownToSpeech(content, options);\n}\n\nexport interface LoadedDocument {\n /** The speakable text, Markdown already converted. */\n text: string;\n /** How the content was read. */\n format: DocumentFormat;\n /** Where it came from, for log lines: a path, `stdin`, or `--text`. */\n source: string;\n}\n\nexport interface LoadDocumentOptions {\n /** Path to read. Use `-` for stdin. Mutually exclusive with `text`. */\n file?: string;\n /** Literal content to speak, instead of reading a file. */\n text?: string;\n format?: RequestedFormat;\n markdown?: MarkdownToSpeechOptions;\n /** Reads stdin. Injected so the CLI tests do not need a real pipe. */\n readStdin?: () => Promise<string>;\n}\n\n/**\n * Reads a document from a path, stdin, or an inline string and returns the text\n * to synthesize.\n */\nexport async function loadDocument(\n options: LoadDocumentOptions\n): Promise<LoadedDocument> {\n const { file, text, format = \"auto\", markdown = {} } = options;\n\n if (text !== undefined) {\n const resolved = detectFormat(text, undefined, format);\n return { text: toSpeechText(text, resolved, markdown), format: resolved, source: \"--text\" };\n }\n\n if (!file) throw new Error(\"No input: pass a file path, `-` for stdin, or --text\");\n\n if (file === \"-\") {\n const stdin = options.readStdin\n ? await options.readStdin()\n : await readStdinToString();\n const resolved = detectFormat(stdin, undefined, format);\n return { text: toSpeechText(stdin, resolved, markdown), format: resolved, source: \"stdin\" };\n }\n\n const { readFile } = await import(\"node:fs/promises\");\n const content = await readFile(file, \"utf8\");\n const resolved = detectFormat(content, file, format);\n return { text: toSpeechText(content, resolved, markdown), format: resolved, source: file };\n}\n\n/** Collects all of stdin as UTF-8 text. */\nexport async function readStdinToString(): Promise<string> {\n const chunks: Buffer[] = [];\n for await (const chunk of process.stdin) {\n chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));\n }\n return Buffer.concat(chunks).toString(\"utf8\");\n}\n","/**\n * @fileoverview Rendering a loaded document to an audio file on disk.\n *\n * Sits between `document.ts` (what to say) and `core/kokoro-node.ts` (how to say\n * it): resolves the output path, runs the synthesizer, and writes the WAV.\n */\nimport {\n synthesizeSamples,\n type KokoroAudio,\n type KokoroNodeOptions,\n} from \"../core/kokoro-node\";\nimport { encodeWav, wavDurationSeconds } from \"../utils/wav\";\nimport { extensionOf, loadDocument, type LoadDocumentOptions } from \"./document\";\n\nexport interface RenderOptions extends LoadDocumentOptions, KokoroNodeOptions {\n /** Where to write the audio. `-` writes the WAV to stdout. */\n output?: string;\n /**\n * Replace the synthesizer. Used by the tests, and by hosts that already have a\n * model loaded and do not want a second copy.\n */\n synthesize?: (text: string, options: KokoroNodeOptions) => Promise<KokoroAudio>;\n}\n\nexport interface RenderResult {\n /** Path written, or `-` when the audio went to stdout. */\n output: string;\n /** The text that was spoken, after Markdown conversion. */\n text: string;\n format: \"markdown\" | \"text\";\n source: string;\n durationSeconds: number;\n bytes: number;\n}\n\n/** `notes.md` becomes `notes.wav`, next to the original. */\nexport function defaultOutputPath(input: string): string {\n const extension = extensionOf(input);\n const base = extension ? input.slice(0, -extension.length) : input;\n return `${base}.wav`;\n}\n\n/**\n * Reads a document, synthesizes it, and writes a WAV file.\n *\n * Returns the spoken text alongside the file details so a caller can show what\n * was read without converting the document a second time.\n */\nexport async function renderDocument(options: RenderOptions): Promise<RenderResult> {\n const document = await loadDocument(options);\n\n if (!document.text.trim()) {\n throw new Error(`Nothing to speak: ${document.source} has no readable text`);\n }\n\n const synthesize = options.synthesize ?? synthesizeSamples;\n const { samples, sampleRate } = await synthesize(document.text, options);\n const audio = encodeWav(samples, sampleRate);\n\n const output =\n options.output ??\n (options.file && options.file !== \"-\" ? defaultOutputPath(options.file) : \"out.wav\");\n\n if (output === \"-\") {\n process.stdout.write(Buffer.from(audio));\n } else {\n const { writeFile } = await import(\"node:fs/promises\");\n await writeFile(output, Buffer.from(audio));\n }\n\n return {\n output,\n text: document.text,\n format: document.format,\n source: document.source,\n durationSeconds: wavDurationSeconds(samples, sampleRate),\n bytes: audio.byteLength,\n };\n}\n","/**\n * @fileoverview The `use-voice-control` command line tool.\n *\n * Reads a Markdown or text file and speaks it to a WAV file:\n *\n * ```sh\n * npx use-voice-control README.md -o readme.wav\n * ```\n *\n * Argument parsing is a pure function (`parseArgs`) and every effect the command\n * has — writing lines, reading stdin, synthesizing — is injectable, so the whole\n * command is testable without loading a 90 MB model.\n */\nimport { describeKokoroVoice, KOKORO_VOICES } from \"../types/types\";\nimport type { KokoroDevice, KokoroDtype } from \"../core/kokoro-node\";\nimport type { MarkdownToSpeechOptions } from \"../utils/markdown-to-speech\";\nimport { loadDocument, type RequestedFormat } from \"./document\";\nimport { renderDocument, type RenderOptions } from \"./render\";\n\nexport type CliCommand = \"speak\" | \"print\" | \"help\" | \"version\" | \"list-voices\";\n\nexport interface CliOptions {\n command: CliCommand;\n /** Input path, or `-` for stdin. Undefined when `text` is set. */\n input?: string;\n /** Literal text passed with `--text`. */\n text?: string;\n output?: string;\n format: RequestedFormat;\n voice: string;\n speed: number;\n model?: string;\n dtype?: KokoroDtype;\n device?: KokoroDevice;\n maxChunkLength?: number;\n gapMs?: number;\n markdown: MarkdownToSpeechOptions;\n quiet: boolean;\n /** Everything wrong with the command line. Non-empty means do not run. */\n errors: string[];\n}\n\nexport interface CliIO {\n /** Writes a line to stdout. */\n log?: (line: string) => void;\n /** Writes a line to stderr — progress and errors go here so `-o -` stays clean. */\n error?: (line: string) => void;\n /** Overrides synthesis, for tests. */\n synthesize?: RenderOptions[\"synthesize\"];\n /** Overrides reading stdin, for tests. */\n readStdin?: () => Promise<string>;\n /** Whether stdin is a terminal. When false and no input is given, stdin is read. */\n stdinIsTTY?: boolean;\n}\n\nconst FORMATS: Record<string, RequestedFormat> = {\n auto: \"auto\",\n markdown: \"markdown\",\n md: \"markdown\",\n text: \"text\",\n txt: \"text\",\n plain: \"text\",\n};\n\nconst DTYPES: KokoroDtype[] = [\"fp32\", \"fp16\", \"q8\", \"q4\", \"q4f16\"];\nconst DEVICES: KokoroDevice[] = [\"wasm\", \"webgpu\", \"cpu\"];\n\nexport const USAGE = `use-voice-control — read a Markdown or text file aloud into an audio file\n\nUsage\n npx use-voice-control <file.md|file.txt|-> [options]\n npx use-voice-control --text \"Hello there\" -o hello.wav\n cat notes.md | npx use-voice-control - -o notes.wav\n\nMarkdown is converted before it is spoken: \"#\", \"**\" and the rest are not read\nout, headings become their own spoken lines, links keep their text, and fenced\ncode blocks are announced instead of being spelled out.\n\nInput\n <file> File to read. Use \"-\" to read stdin.\n --text <string> Speak this string instead of reading a file.\n -f, --format <fmt> auto (default), markdown, or text.\n\nOutput\n -o, --out <file> Audio file to write. Default: the input path with a\n .wav extension. Use \"-\" to write the WAV to stdout.\n -p, --print Print the speakable text and exit — no model, no audio.\n Useful for checking the Markdown conversion.\n -q, --quiet No progress output.\n\nVoice\n -v, --voice <id> Voice id. Default af_heart. See --list-voices.\n -s, --speed <n> Speaking rate, 0.5-2. Default 1.\n --list-voices Print the available voices and exit.\n\nMarkdown handling\n --headings <mode> text (default) | announce | skip\n --code <mode> announce (default) | read | skip\n --links <mode> text (default) | text-and-url\n --tables <mode> rows (default) | skip\n --front-matter Read the YAML front matter instead of skipping it.\n\nModel\n --model <id> Hugging Face model id.\n Default onnx-community/Kokoro-82M-v1.0-ONNX.\n --dtype <type> fp32 | fp16 | q8 (default) | q4 | q4f16\n --device <device> cpu (default) | wasm | webgpu\n --chunk <chars> Target characters per synthesis chunk. Default 400.\n --gap <ms> Silence between chunks. Default 120.\n\nOther\n -h, --help Show this help.\n -V, --version Print the package version.\n\nThe first run downloads the Kokoro weights (about 90 MB at the default q8) into\nthe Hugging Face cache; later runs are offline. Speech is synthesized locally —\nno text leaves the machine.`;\n\n/** Reads the next value for a flag, recording an error when it is missing. */\nfunction takeValue(\n argv: string[],\n index: number,\n flag: string,\n errors: string[]\n): { value?: string; next: number } {\n const value = argv[index + 1];\n if (value === undefined || value.startsWith(\"-\")) {\n errors.push(`${flag} needs a value`);\n return { next: index + 1 };\n }\n return { value, next: index + 1 };\n}\n\n/** Parses a numeric flag, recording an error when it is not a finite number. */\nfunction toNumber(value: string | undefined, flag: string, errors: string[]): number | undefined {\n if (value === undefined) return undefined;\n const parsed = Number(value);\n if (!Number.isFinite(parsed)) {\n errors.push(`${flag} expects a number, got \"${value}\"`);\n return undefined;\n }\n return parsed;\n}\n\n/** Parses an enum flag, recording an error when the value is not in `allowed`. */\nfunction toChoice<T extends string>(\n value: string | undefined,\n allowed: readonly T[],\n flag: string,\n errors: string[]\n): T | undefined {\n if (value === undefined) return undefined;\n if (!allowed.includes(value as T)) {\n errors.push(`${flag} expects one of ${allowed.join(\", \")} — got \"${value}\"`);\n return undefined;\n }\n return value as T;\n}\n\n/**\n * Parses the command line. Pure: it reads nothing and writes nothing, so the\n * tests can assert on the whole option set.\n */\nexport function parseArgs(argv: string[]): CliOptions {\n const errors: string[] = [];\n const markdown: MarkdownToSpeechOptions = {};\n const options: CliOptions = {\n command: \"speak\",\n format: \"auto\",\n voice: \"af_heart\",\n speed: 1,\n markdown,\n quiet: false,\n errors,\n };\n\n let positionalsOnly = false;\n\n for (let i = 0; i < argv.length; i += 1) {\n const arg = argv[i];\n\n if (positionalsOnly || !arg.startsWith(\"-\") || arg === \"-\") {\n if (options.input !== undefined) {\n errors.push(`unexpected extra input \"${arg}\" — pass one file at a time`);\n } else {\n options.input = arg;\n }\n continue;\n }\n\n if (arg === \"--\") {\n positionalsOnly = true;\n continue;\n }\n\n // `--voice=af_bella` is the same as `--voice af_bella`.\n const equals = arg.indexOf(\"=\");\n if (equals > 1) {\n argv.splice(i, 1, arg.slice(0, equals), arg.slice(equals + 1));\n i -= 1;\n continue;\n }\n\n switch (arg) {\n case \"-h\":\n case \"--help\":\n options.command = \"help\";\n return options;\n\n case \"-V\":\n case \"--version\":\n options.command = \"version\";\n return options;\n\n case \"--list-voices\":\n options.command = \"list-voices\";\n return options;\n\n case \"-p\":\n case \"--print\":\n case \"--dry-run\":\n options.command = \"print\";\n break;\n\n case \"-q\":\n case \"--quiet\":\n options.quiet = true;\n break;\n\n case \"--front-matter\":\n markdown.frontMatter = true;\n break;\n\n case \"-o\":\n case \"--out\":\n case \"--output\": {\n const { value, next } = takeValue(argv, i, arg, errors);\n options.output = value;\n i = next;\n break;\n }\n\n case \"--text\": {\n // Unlike every other value, this one may legitimately start with \"-\".\n const value = argv[i + 1];\n if (value === undefined) errors.push(\"--text needs a value\");\n else options.text = value;\n i += 1;\n break;\n }\n\n case \"-f\":\n case \"--format\": {\n const { value, next } = takeValue(argv, i, arg, errors);\n i = next;\n if (value !== undefined) {\n const format = FORMATS[value.toLowerCase()];\n if (!format) {\n errors.push(`--format expects auto, markdown or text — got \"${value}\"`);\n } else {\n options.format = format;\n }\n }\n break;\n }\n\n case \"-v\":\n case \"--voice\": {\n const { value, next } = takeValue(argv, i, arg, errors);\n i = next;\n if (value !== undefined) {\n if (!KOKORO_VOICES.includes(value as (typeof KOKORO_VOICES)[number])) {\n errors.push(`unknown voice \"${value}\" — run --list-voices to see them all`);\n } else {\n options.voice = value;\n }\n }\n break;\n }\n\n case \"-s\":\n case \"--speed\": {\n const { value, next } = takeValue(argv, i, arg, errors);\n i = next;\n const speed = toNumber(value, arg, errors);\n if (speed !== undefined) {\n if (speed < 0.5 || speed > 2) errors.push(\"--speed must be between 0.5 and 2\");\n else options.speed = speed;\n }\n break;\n }\n\n case \"--model\": {\n const { value, next } = takeValue(argv, i, arg, errors);\n options.model = value;\n i = next;\n break;\n }\n\n case \"--dtype\": {\n const { value, next } = takeValue(argv, i, arg, errors);\n i = next;\n options.dtype = toChoice(value, DTYPES, arg, errors) ?? options.dtype;\n break;\n }\n\n case \"--device\": {\n const { value, next } = takeValue(argv, i, arg, errors);\n i = next;\n options.device = toChoice(value, DEVICES, arg, errors) ?? options.device;\n break;\n }\n\n case \"--chunk\":\n case \"--chunk-length\": {\n const { value, next } = takeValue(argv, i, arg, errors);\n i = next;\n const chunk = toNumber(value, arg, errors);\n if (chunk !== undefined) {\n if (chunk < 40) errors.push(\"--chunk must be at least 40 characters\");\n else options.maxChunkLength = chunk;\n }\n break;\n }\n\n case \"--gap\": {\n const { value, next } = takeValue(argv, i, arg, errors);\n i = next;\n const gap = toNumber(value, arg, errors);\n if (gap !== undefined) {\n if (gap < 0) errors.push(\"--gap cannot be negative\");\n else options.gapMs = gap;\n }\n break;\n }\n\n case \"--headings\": {\n const { value, next } = takeValue(argv, i, arg, errors);\n i = next;\n markdown.headings =\n toChoice(value, [\"text\", \"announce\", \"skip\"] as const, arg, errors) ??\n markdown.headings;\n break;\n }\n\n case \"--code\":\n case \"--code-blocks\": {\n const { value, next } = takeValue(argv, i, arg, errors);\n i = next;\n markdown.codeBlocks =\n toChoice(value, [\"announce\", \"read\", \"skip\"] as const, arg, errors) ??\n markdown.codeBlocks;\n break;\n }\n\n case \"--links\": {\n const { value, next } = takeValue(argv, i, arg, errors);\n i = next;\n markdown.links =\n toChoice(value, [\"text\", \"text-and-url\"] as const, arg, errors) ?? markdown.links;\n break;\n }\n\n case \"--tables\": {\n const { value, next } = takeValue(argv, i, arg, errors);\n i = next;\n markdown.tables =\n toChoice(value, [\"rows\", \"skip\"] as const, arg, errors) ?? markdown.tables;\n break;\n }\n\n default:\n errors.push(`unknown option \"${arg}\" — run --help to see the options`);\n }\n }\n\n if (options.text !== undefined && options.input !== undefined) {\n errors.push(\"pass either a file or --text, not both\");\n }\n\n return options;\n}\n\n/** The `--list-voices` table, derived from the ids so it cannot drift. */\nexport function formatVoiceList(): string {\n const rows = KOKORO_VOICES.map((id) => {\n const voice = describeKokoroVoice(id);\n return ` ${id.padEnd(14)}${voice.name.padEnd(12)}${voice.gender.padEnd(8)}${voice.accent}`;\n });\n return [`${KOKORO_VOICES.length} Kokoro voices:`, ...rows].join(\"\\n\");\n}\n\n/** Reads the package version, so `--version` matches what npx installed. */\nasync function readVersion(): Promise<string> {\n try {\n const { readFile } = await import(\"node:fs/promises\");\n // From `dist/cli.js` the manifest is one level up; from a source checkout it\n // is two. Try both before giving up.\n for (const relative of [\"../package.json\", \"../../package.json\"]) {\n try {\n const url = new URL(relative, import.meta.url);\n const manifest = JSON.parse(await readFile(url, \"utf8\"));\n if (manifest?.name === \"use-voice-control\" && manifest.version) return manifest.version;\n } catch {\n // Try the next candidate.\n }\n }\n } catch {\n // No filesystem (bundled for a runtime without fs) — fall through.\n }\n return \"unknown\";\n}\n\n/**\n * Runs the command line and resolves to the process exit code.\n *\n * @param argv Arguments after the executable and script, i.e. `process.argv.slice(2)`.\n * @param io Injection points for output, stdin and synthesis.\n */\nexport async function runCli(argv: string[], io: CliIO = {}): Promise<number> {\n const log = io.log ?? ((line: string) => process.stdout.write(`${line}\\n`));\n const warn = io.error ?? ((line: string) => process.stderr.write(`${line}\\n`));\n\n const options = parseArgs([...argv]);\n\n if (options.command === \"help\") {\n log(USAGE);\n return 0;\n }\n\n if (options.command === \"version\") {\n log(await readVersion());\n return 0;\n }\n\n if (options.command === \"list-voices\") {\n log(formatVoiceList());\n return 0;\n }\n\n if (options.errors.length > 0) {\n options.errors.forEach((message) => warn(`use-voice-control: ${message}`));\n warn(\"Run `npx use-voice-control --help` for usage.\");\n return 1;\n }\n\n // With nothing named on the command line, a pipe is the intended input.\n const stdinIsTTY = io.stdinIsTTY ?? Boolean(process.stdin.isTTY);\n const input =\n options.input ?? (options.text === undefined && !stdinIsTTY ? \"-\" : undefined);\n\n if (input === undefined && options.text === undefined) {\n warn(\"use-voice-control: no input — pass a file, pipe text in, or use --text\");\n warn(\"Run `npx use-voice-control --help` for usage.\");\n return 1;\n }\n\n const shared = {\n file: input,\n text: options.text,\n format: options.format,\n markdown: options.markdown,\n readStdin: io.readStdin,\n };\n\n try {\n if (options.command === \"print\") {\n const document = await loadDocument(shared);\n log(document.text);\n return 0;\n }\n\n const started = Date.now();\n const result = await renderDocument({\n ...shared,\n output: options.output,\n voice: options.voice,\n speed: options.speed,\n model: options.model,\n dtype: options.dtype,\n device: options.device,\n maxChunkLength: options.maxChunkLength,\n gapMs: options.gapMs,\n synthesize: io.synthesize,\n onModelProgress: options.quiet\n ? undefined\n : (progress: any) => {\n if (progress?.status === \"progress\" && progress.file && progress.total) {\n const done = Math.round(((progress.loaded ?? 0) / progress.total) * 100);\n warn(`downloading ${progress.file}: ${done}%`);\n }\n },\n onChunk: options.quiet\n ? undefined\n : ({ index, total }) => warn(`speaking chunk ${index + 1}/${total}`),\n });\n\n if (!options.quiet) {\n const seconds = result.durationSeconds.toFixed(1);\n const elapsed = ((Date.now() - started) / 1000).toFixed(1);\n const target = result.output === \"-\" ? \"stdout\" : result.output;\n warn(`wrote ${target} — ${seconds}s of audio from ${result.source} in ${elapsed}s`);\n }\n return 0;\n } catch (error) {\n warn(`use-voice-control: ${error instanceof Error ? error.message : String(error)}`);\n return 1;\n }\n}\n"],"mappings":";;;AAmBA,IAAa,IAAsB;CAAC;CAAO;CAAa;CAAU;CAAQ;AAAM,GAGnE,IAAkB;CAAC;CAAQ;CAAS;AAAE;AAGnD,SAAgB,EAAY,GAA0B;CACpD,IAAM,IAAO,EAAS,MAAM,OAAO,CAAC,CAAC,IAAI,KAAK,IACxC,IAAM,EAAK,YAAY,GAAG;CAChC,OAAO,IAAM,IAAI,EAAK,MAAM,CAAG,CAAC,CAAC,YAAY,IAAI;AACnD;AASA,SAAgB,EACd,GACA,GACA,IAA6B,QACb;CAChB,IAAI,MAAc,QAAQ,OAAO;CAEjC,IAAI,GAAU;EACZ,IAAM,IAAY,EAAY,CAAQ;EACtC,IAAI,EAAoB,SAAS,CAAS,GAAG,OAAO;EACpD,IAAI,EAAgB,SAAS,CAAS,GAAG,OAAO;CAClD;CAEA,OAAO,EAAkB,CAAO,IAAI,aAAa;AACnD;AAGA,SAAgB,EACd,GACA,GACA,IAAmC,CAAC,GAC5B;CAMR,OALI,MAAW,SAGN,EAAQ,QAAQ,UAAU,IAAI,CAAC,CAAC,KAAK,IAEvC,EAAiB,GAAS,CAAO;AAC1C;AA0BA,eAAsB,EACpB,GACyB;CACzB,IAAM,EAAE,SAAM,SAAM,YAAS,QAAQ,cAAW,CAAC,MAAM;CAEvD,IAAI,MAAS,KAAA,GAAW;EACtB,IAAM,IAAW,EAAa,GAAM,KAAA,GAAW,C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