@double_geste/agent-standup 1.30.0 → 1.32.0
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/bin/agent-standup.js +4 -1
- package/codex.js +6 -4
- package/kokoro-worker.js +35 -4
- package/kokoro.js +26 -10
- package/package.json +1 -1
- package/public/index.html +582 -166
- package/public/locales/README.md +5 -2
- package/public/locales/da.json +44 -10
- package/public/locales/de.json +44 -10
- package/public/locales/en.json +42 -8
- package/public/locales/es.json +44 -10
- package/public/locales/ja.json +44 -10
- package/public/locales/ko.json +44 -10
- package/public/locales/pt-BR.json +44 -10
- package/public/locales/zh-CN.json +44 -10
- package/public/locales/zh-TW.json +44 -10
- package/server.js +342 -82
- package/vibe.js +12 -7
package/bin/agent-standup.js
CHANGED
|
@@ -9,7 +9,7 @@ const pkg = require('../package.json');
|
|
|
9
9
|
const argv = process.argv.slice(2), flags = {}, rest = [];
|
|
10
10
|
for (let i = 0; i < argv.length; i++) {
|
|
11
11
|
const a = argv[i], val = () => argv[++i];
|
|
12
|
-
if (a === '--port') flags.port = val(); else if (a === '--projects') flags.projects = val(); else if (a === '--codex') flags.codex = val(); else if (a === '--vibe') flags.vibe = val(); else if (a === '--characters') flags.characters = val(); else if (a === '--config-dir') flags.config = val();
|
|
12
|
+
if (a === '--port') flags.port = val(); else if (a === '--projects') flags.projects = val(); else if (a === '--codex') flags.codex = val(); else if (a === '--vibe') flags.vibe = val(); else if (a === '--cowork') flags.cowork = val(); else if (a === '--characters') flags.characters = val(); else if (a === '--config-dir') flags.config = val();
|
|
13
13
|
else if (a === '--open') flags.open = true; else if (a === '--here') flags.here = true; else if (a === '--json') flags.json = true; else if (a === '--titles') flags.titles = true;
|
|
14
14
|
else if (a === '-h' || a === '--help') flags.help = true; else if (a === '-v' || a === '--version') flags.version = true; else rest.push(a);
|
|
15
15
|
}
|
|
@@ -27,6 +27,7 @@ Options
|
|
|
27
27
|
--projects DIR where the session files are (default ~/.claude/projects, or $CLAUDE_CONFIG_DIR/projects)
|
|
28
28
|
--codex DIR where Codex keeps its files (default ~/.codex, or $CODEX_HOME); "off" to leave Codex sessions out
|
|
29
29
|
--vibe DIR where Mistral Vibe keeps its files (default ~/.vibe, or $VIBE_HOME); "off" to leave Vibe sessions out
|
|
30
|
+
--cowork DIR where the Claude desktop app keeps its Cowork sessions (default: its local-agent-mode-sessions folder); "off" to leave them out
|
|
30
31
|
--characters DIR folder with your own pixel-art characters (default ~/.agent-standup/characters)
|
|
31
32
|
--here status: only sessions of the current folder (matched on its real path, as Claude Code names it)
|
|
32
33
|
--json status: machine-readable output (add --titles to include session titles)
|
|
@@ -36,12 +37,14 @@ if (flags.version || cmd === 'version') { console.log(pkg.version); process.exit
|
|
|
36
37
|
if (flags.projects) process.env.AGENT_STANDUP_PROJECTS = path.resolve(flags.projects);
|
|
37
38
|
if (flags.codex !== undefined) process.env.AGENT_STANDUP_CODEX = /^(0|off|no|false)?$/i.test(String(flags.codex)) ? 'off' : path.resolve(String(flags.codex));
|
|
38
39
|
if (flags.vibe !== undefined) process.env.AGENT_STANDUP_VIBE = /^(0|off|no|false)?$/i.test(String(flags.vibe)) ? 'off' : path.resolve(String(flags.vibe));
|
|
40
|
+
if (flags.cowork !== undefined) process.env.AGENT_STANDUP_COWORK = /^(0|off|no|false)?$/i.test(String(flags.cowork)) ? 'off' : path.resolve(String(flags.cowork));
|
|
39
41
|
if (flags.config) process.env.CLAUDE_CONFIG_DIR = path.resolve(flags.config);
|
|
40
42
|
if (flags.characters) process.env.AGENT_STANDUP_CHARACTERS = path.resolve(flags.characters);
|
|
41
43
|
if (flags.port !== undefined) { // a real port number or nothing: no silent fallback to another port
|
|
42
44
|
if (!/^\d+$/.test(String(flags.port)) || +flags.port < 1 || +flags.port > 65535) { console.error(`Invalid --port "${flags.port}": use a number between 1 and 65535.`); process.exit(2); }
|
|
43
45
|
process.env.PORT = String(+flags.port);
|
|
44
46
|
}
|
|
47
|
+
process.env.AGENT_STANDUP_HOST = 'command line'; // named in a problem report (⚙ › Report a problem)
|
|
45
48
|
const server = require('../server.js');
|
|
46
49
|
const projKey = (dir) => String(dir || '').replace(/[^a-zA-Z0-9]/g, '-'); // Claude Code's project folder naming
|
|
47
50
|
|
package/codex.js
CHANGED
|
@@ -67,6 +67,7 @@ function sessions(limit = 80) {
|
|
|
67
67
|
return out;
|
|
68
68
|
}
|
|
69
69
|
const inProject = (id, key) => { const r = row(id); if (!r || !key) return false; if (key === PROJ) return true; const d = head(r.file).dir; return d === key || d.startsWith(key + '-'); };
|
|
70
|
+
const cwd = (id) => { const r = row(id); return r ? head(r.file).cwd : ''; }; // the folder the session was started in: where a file it names by a relative path is
|
|
70
71
|
const projectLabel = (cwd) => { const h = os.homedir(), rel = cwd && cwd.startsWith(h + path.sep) ? cwd.slice(h.length + 1) : cwd; return 'Codex' + (rel ? ' · ' + rel.split(path.sep).join('/') : ''); };
|
|
71
72
|
|
|
72
73
|
// ---- names: the one Codex gave the thread (session_index.jsonl, the last line for an id wins), else the first thing the person typed
|
|
@@ -104,15 +105,16 @@ const tailCache = new Map();
|
|
|
104
105
|
function boardRow(r, now) {
|
|
105
106
|
const sig = r.mtime + ':' + r.size; let t = tailCache.get(r.file);
|
|
106
107
|
if (!t || t.sig !== sig) {
|
|
107
|
-
t = { sig, turn: '' };
|
|
108
|
+
t = { sig, turn: '', asked: (t && t.asked) || 0 }; // asked: when the person last typed something there, which is what moves the live call (see currentSession in server.js)
|
|
108
109
|
try {
|
|
109
110
|
const fd = fs.openSync(r.file, 'r'); let text = ''; try { const n = Math.min(128 * 1024, r.size), buf = Buffer.alloc(n); fs.readSync(fd, buf, 0, n, r.size - n); text = buf.toString('utf8'); } finally { fs.closeSync(fd); }
|
|
110
|
-
for (const l of text.split('\n')) { const m = /"type":"(task_started|task_complete|turn_started|turn_complete|turn_aborted)"/.exec(l.slice(0, 400)); if (m && l.includes('"event_msg"')) t.turn = /started/.test(m[1]) ? 'open' : 'closed';
|
|
111
|
+
for (const l of text.split('\n')) { const m = /"type":"(task_started|task_complete|turn_started|turn_complete|turn_aborted)"/.exec(l.slice(0, 400)); if (m && l.includes('"event_msg"')) t.turn = /started/.test(m[1]) ? 'open' : 'closed';
|
|
112
|
+
if (l.includes('"UserMessage"') || l.includes('"user_message"')) { try { const j = JSON.parse(l), p = (j && j.payload) || {}; if (p.type === 'user_message' ? typed(p.message) : p.type === 'item_completed' && p.item && p.item.type === 'UserMessage' && typed(partsText(p.item.content))) t.asked = Math.max(t.asked, Date.parse(j.timestamp) || 0); } catch {} } } // a first line cut in two does not parse
|
|
111
113
|
} catch {}
|
|
112
114
|
if (tailCache.size > 200) tailCache.delete(tailCache.keys().next().value); tailCache.set(r.file, t);
|
|
113
115
|
}
|
|
114
116
|
const age = now - r.mtime, state = age >= 30 * 60e3 ? 'idle' : t.turn === 'closed' ? 'turn' : age < 10 * 60e3 ? 'working' : 'idle';
|
|
115
|
-
return { proj: PROJ, id: r.id, title: title(r), mtime: r.mtime, state, tool: '', ageMs: age, subActive: 0, subTotal: 0, dir: r.dir, source: 'codex' };
|
|
117
|
+
return { proj: PROJ, id: r.id, title: title(r), mtime: r.mtime, state, tool: '', ageMs: age, subActive: 0, subTotal: 0, asked: t.asked, dir: r.dir, source: 'codex' };
|
|
116
118
|
}
|
|
117
119
|
|
|
118
120
|
// ---- one record of a rollout file → the events of the call
|
|
@@ -206,4 +208,4 @@ function parser({ toolLabel, clip, resultMax = {} }) {
|
|
|
206
208
|
if (p.type === 'web_search_call' && !cx.items && id) call(id, 'WebSearch', { query: (p.action && p.action.query) || '' });
|
|
207
209
|
};
|
|
208
210
|
}
|
|
209
|
-
module.exports = { PROJ, SOURCE, home, dirKey, sessions, row, fileOf, inProject, projectLabel, title, boardRow, parser };
|
|
211
|
+
module.exports = { PROJ, SOURCE, home, dirKey, sessions, row, fileOf, cwd, inProject, projectLabel, title, boardRow, parser };
|
package/kokoro-worker.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Kokoro worker: loads the Kokoro-82M model once, then reads one JSON request per stdin line ({ id, text, voice, speed, out }),
|
|
2
|
+
// Kokoro worker: loads the Kokoro-82M model once, then reads one JSON request per stdin line ({ id, text, voice, speed, out } and, for a voice that is not English, { lang, mix }),
|
|
3
3
|
// writes a 16-bit WAV to `out` and answers { id, ok, seconds } or { id, ok: false, error }. Started by kokoro.js.
|
|
4
|
-
const fs = require('fs'), path = require('path'), readline = require('readline'), { createRequire } = require('module');
|
|
4
|
+
const fs = require('fs'), path = require('path'), readline = require('readline'), { createRequire } = require('module'), { pathToFileURL } = require('url');
|
|
5
5
|
const MODEL = 'onnx-community/Kokoro-82M-v1.0-ONNX';
|
|
6
6
|
const send = (o) => fs.writeSync(1, JSON.stringify(o) + '\n');
|
|
7
7
|
const finite = (samples) => { for (let i = 0; i < samples.length; i++) if (samples[i] !== samples[i]) return false; return true; }; // a quantised model can return NaN for a whole line, which would be written as silence
|
|
@@ -24,6 +24,29 @@ function join(parts, rate) { // [audio, pause, audio, …] → one Float32Arra
|
|
|
24
24
|
const cut = parts.map((p, i) => { if (typeof p === 'number') return new Float32Array(Math.round(p * rate)); const s = p.audio; let a = 0, z = s.length; if (i) while (a < z && Math.abs(s[a]) < QUIET) a++; if (i < parts.length - 1) while (z > a && Math.abs(s[z - 1]) < QUIET) z--; return s.subarray(a, z); });
|
|
25
25
|
const out = new Float32Array(cut.reduce((n, c) => n + c.length, 0)); let at = 0; for (const c of cut) { out.set(c, at); at += c.length; } return out;
|
|
26
26
|
}
|
|
27
|
+
// ---- Languages other than English. kokoro-js only knows how to turn English into phonemes, and refuses the voices of the other languages; the model itself is not English only.
|
|
28
|
+
// The phonemes come from the full eSpeak NG the install adds next to kokoro-js (WebAssembly), written the way Kokoro's own Python front end (misaki) writes them, and go straight to the model.
|
|
29
|
+
const E2M = Object.entries({ 'a^ɪ': 'I', 'a^ʊ': 'W', 'd^z': 'ʣ', 'd^ʒ': 'ʤ', 'e^ɪ': 'A', 'o^ʊ': 'O', 'ə^ʊ': 'Q', 's^s': 'S', 't^s': 'ʦ', 't^ʃ': 'ʧ', 'ɔ^ɪ': 'Y' }).sort(); // eSpeak's tied pairs → the single letters the model was trained on
|
|
30
|
+
const MARKS = /(\s*(?:[;:,!?¡¿—…"«»“”(){}[\]]|\.(?![\p{L}\p{N}]))+\s*)+/gu; // the punctuation the model reads as pauses and intonation. eSpeak drops it, so the text is phonemized between the marks and they are put back. A dot inside a word (server.js) is not one
|
|
31
|
+
let espeakNg = null;
|
|
32
|
+
async function espeak(dir, stretches, lang) { // [text between two marks, …] → the phonemes of each, in one run of eSpeak when it answers one line per stretch
|
|
33
|
+
espeakNg ||= (await import(pathToFileURL(path.join(dir, 'node_modules', 'espeak-ng', 'dist', 'espeak-ng.js')).href)).default;
|
|
34
|
+
const run = async (text) => { // the text goes in as a UTF-8 file: as an argument, accented letters arrive mangled. '-b', '1' and not '-b=1', for the same reason
|
|
35
|
+
const m = await espeakNg({ arguments: ['--phonout', 'generated', '-q', '-b', '1', '--ipa', '--tie=^', '-v', lang, '-f', 'in.txt'], preRun: [(M) => M.FS.writeFile('in.txt', text)], print() {}, printErr() {} });
|
|
36
|
+
return m.FS.readFile('generated', { encoding: 'utf8' }).split('\n').map((l) => l.replace(/\((\^?[a-z-])+\)/g, '').trim()).filter(Boolean); // "(en)…(fr)": eSpeak's notes that it changed language for a word
|
|
37
|
+
};
|
|
38
|
+
const got = stretches.length ? await run(stretches.join('\n\n')) : []; if (got.length === stretches.length) return got;
|
|
39
|
+
const each = []; for (const s of stretches) each.push((await run(s)).join(' ')); return each; // a stretch with nothing to say (an arrow, a symbol) gave no line: one run each, so that none is given the phonemes of another
|
|
40
|
+
}
|
|
41
|
+
async function phonemes(dir, text, lang) {
|
|
42
|
+
text = text.replace(/[‘’]/g, "'").replace(/«\s*/g, '“').replace(/\s*»/g, '”').replace(/\s+([:;!?])/g, '$1'); // French typography: no space before the mark for the model
|
|
43
|
+
const parts = []; let last = 0;
|
|
44
|
+
for (const m of text.matchAll(MARKS)) { if (m.index > last) parts.push([false, text.slice(last, m.index)]); parts.push([true, m[0]]); last = m.index + m[0].length; }
|
|
45
|
+
if (last < text.length) parts.push([false, text.slice(last)]);
|
|
46
|
+
const got = await espeak(dir, parts.filter((p) => !p[0]).map((p) => p[1]), lang); let i = 0, ps = parts.map(([mark, t]) => (mark ? t : got[i++])).join('');
|
|
47
|
+
for (const [a, b] of E2M) ps = ps.split(a).join(b);
|
|
48
|
+
return ps.replace(/[\^-]/g, '').trim();
|
|
49
|
+
}
|
|
27
50
|
async function main() {
|
|
28
51
|
const dir = process.env.AGENT_STANDUP_KOKORO_DIR, dtype = process.env.AGENT_STANDUP_KOKORO_DTYPE || 'q4';
|
|
29
52
|
const req = createRequire(path.join(dir, 'node_modules', 'x.js')); // resolve from the install folder, not from the extension
|
|
@@ -38,7 +61,15 @@ async function main() {
|
|
|
38
61
|
}
|
|
39
62
|
const tok = tts.tokenizer; // kokoro-js calls it with truncation on, which drops every phoneme past the model's limit and says nothing: count them all here and refuse instead
|
|
40
63
|
if (tok) tts.tokenizer = (t, o) => { const r = tok(t, { ...o, truncation: false }); if (r.input_ids.dims.at(-1) > (tok.model_max_length || 512)) throw LONG; return r; };
|
|
41
|
-
const
|
|
64
|
+
const packs = new Map(), pack = (n) => { if (!packs.has(n)) { const b = fs.readFileSync(path.join(dir, 'node_modules', 'kokoro-js', 'voices', n + '.bin')); packs.set(n, new Float32Array(b.buffer.slice(b.byteOffset, b.byteOffset + b.length))); } return packs.get(n); }; // a voice: 510 styles of 256 numbers, one per length of line. All 54 come with kokoro-js
|
|
65
|
+
const foreign = async (text, o) => { // what kokoro-js' generate_from_ids does, with a style that can be a mix of several voices (o.mix: [[voice, share], …])
|
|
66
|
+
const { input_ids } = tts.tokenizer(await phonemes(dir, text, o.lang), { truncation: true }), at = 256 * Math.min(Math.max(input_ids.dims.at(-1) - 2, 0), 509), style = new Float32Array(256);
|
|
67
|
+
for (const [name, share] of o.mix) { const v = pack(name); for (let i = 0; i < 256; i++) style[i] += share * v[at + i]; }
|
|
68
|
+
const { waveform } = await tts.model({ input_ids, style: new tf.Tensor('float32', style, [1, 256]), speed: new tf.Tensor('float32', [o.speed], [1]) });
|
|
69
|
+
return { audio: waveform.data, sampling_rate: 24000 };
|
|
70
|
+
};
|
|
71
|
+
const say = (text, o) => (o.lang ? foreign(text, o) : tts.generate(text, { voice: o.voice, speed: o.speed }));
|
|
72
|
+
const make = async (text, o) => { let a = await say(text, o); if (!finite(a.audio)) { a = await say(text, o); if (!finite(a.audio)) throw new Error('the model returned NaN'); } return a; }; // made once more; if it fails again the server hands the line to a system voice
|
|
42
73
|
const parts = async (text, o) => { // → [audio] when the line fits (the usual case, made exactly as before), else [audio, pause, audio, …] in the order of the text
|
|
43
74
|
try { return [await make(text, o)]; } catch (e) { if (e !== LONG) throw e; }
|
|
44
75
|
const [a, b, gap] = halve(text); return [...await parts(a, o), gap / o.speed, ...await parts(b, o)];
|
|
@@ -47,7 +78,7 @@ async function main() {
|
|
|
47
78
|
for await (const line of readline.createInterface({ input: process.stdin })) {
|
|
48
79
|
let m; try { m = JSON.parse(line); } catch { continue; }
|
|
49
80
|
try {
|
|
50
|
-
const ps = await parts(String(m.text).trim(), { voice: m.voice, speed: +m.speed || 1 }), rate = ps[0].sampling_rate, audio = ps.length > 1 ? join(ps, rate) : ps[0].audio;
|
|
81
|
+
const ps = await parts(String(m.text).trim(), { voice: m.voice, speed: +m.speed || 1, lang: m.lang, mix: m.mix }), rate = ps[0].sampling_rate, audio = ps.length > 1 ? join(ps, rate) : ps[0].audio;
|
|
51
82
|
fs.writeFileSync(m.out, wav(audio, rate)); send({ id: m.id, ok: true, seconds: audio.length / rate });
|
|
52
83
|
}
|
|
53
84
|
catch (e) { send({ id: m.id, ok: false, error: String((e && e.message) || e).slice(0, 200) }); }
|
package/kokoro.js
CHANGED
|
@@ -1,18 +1,33 @@
|
|
|
1
1
|
// Natural voices with Kokoro-82M (kokoro-js on ONNX Runtime), installed on demand outside the extension.
|
|
2
2
|
// Nothing here runs until the person clicks Install in ⚙ → Sound: the packages (about 430 MB) go to one user folder, the model (about 155 MB) is fetched on first use.
|
|
3
|
+
// French, Spanish and Brazilian Portuguese are the same model: kokoro-js only reads English, so the install adds a full eSpeak NG (WebAssembly, 18 MB, GPL: fetched by npm like the rest, never shipped with the app) for the phonemes. See kokoro-worker.js.
|
|
3
4
|
const fs = require('fs'), os = require('os'), path = require('path'), { spawn } = require('child_process');
|
|
4
5
|
|
|
5
6
|
const WIN = process.platform === 'win32';
|
|
6
7
|
const DIR = process.env.AGENT_STANDUP_KOKORO_DIR || (WIN ? path.join(process.env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local'), 'agent-standup', 'kokoro') : path.join(os.homedir(), '.cache', 'agent-standup', 'kokoro'));
|
|
7
|
-
const PKG = 'kokoro-js@1.2.1', DTYPE = 'q4', SIZE_MB =
|
|
8
|
+
const PKG = 'kokoro-js@1.2.1', G2P = 'espeak-ng@1.0.2', G2P_MB = 18, DTYPE = 'q4', SIZE_MB = 750, MAX_RESTARTS = 3;
|
|
8
9
|
const WORKER = process.env.AGENT_STANDUP_KOKORO_WORKER || path.join(__dirname, 'kokoro-worker.js'), LOG = path.join(DIR, 'install.log');
|
|
9
10
|
|
|
10
|
-
// In the order agents get them (the lead takes the first), so successive agents sound distinct.
|
|
11
|
-
const
|
|
12
|
-
|
|
11
|
+
// In the order agents get them (the lead takes the first), so successive agents sound distinct.
|
|
12
|
+
const EN = [['af_heart', 'Heart', 'en_US'], ['am_fenrir', 'Fenrir', 'en_US'], ['bf_emma', 'Emma', 'en_GB'], ['am_michael', 'Michael', 'en_US'], ['af_bella', 'Bella', 'en_US'], ['bm_george', 'George', 'en_GB'], ['af_sarah', 'Sarah', 'en_US'], ['am_puck', 'Puck', 'en_US']].map(([name, label, locale]) => ({ name, label, locale }));
|
|
13
|
+
// The other languages. A voice here is a mix of the model's voices ([[voice, share], …]) said from the phonemes of `lang` (an eSpeak NG language).
|
|
14
|
+
// French: the model has one French voice, ff_siwis (a woman), which the lead takes as it is. The others are that voice mixed with the character's English one, in the same order as above:
|
|
15
|
+
// each keeps something of its own voice in both languages. Measured by transcribing the clips back (Whisper), a mix with 40 to 50 % of the French voice is understood as well as the French voice alone,
|
|
16
|
+
// and an English voice alone is not (two to four times the errors). The men get 40 % where that stays clear, which sets them apart: their pitch is 150 to 170 Hz against 205 for ff_siwis. Michael slurred words at 40 %.
|
|
17
|
+
const FR = [['ff_siwis', 'Siwis', null, 1], ['fr_fenrir', 'Fenrir', 'am_fenrir', 0.4], ['fr_emma', 'Emma', 'bf_emma', 0.5], ['fr_michael', 'Michael', 'am_michael', 0.5], ['fr_bella', 'Bella', 'af_bella', 0.5], ['fr_george', 'George', 'bm_george', 0.4], ['fr_sarah', 'Sarah', 'af_sarah', 0.5], ['fr_puck', 'Puck', 'am_puck', 0.4]]
|
|
18
|
+
.map(([name, label, other, share]) => ({ name, label, locale: 'fr_FR', lang: 'fr-fr', mix: other ? [['ff_siwis', share], [other, 1 - share]] : [['ff_siwis', 1]] }));
|
|
19
|
+
// Spanish and Brazilian Portuguese: one woman (f) and two men (m, m2) each in the model. The lead and the first agent take the woman and the first man as they are; the others are one of the three,
|
|
20
|
+
// of the same sex, mixed half and half with the character's English voice. By the same measure every one of these was understood as well as the three voices alone.
|
|
21
|
+
const cast = (pre, locale, lang, f, m, m2) => [[f, 'Dora', [[f, 1]]], [m, 'Alex', [[m, 1]]], [pre + '_emma', 'Emma', [[f, 0.5], ['bf_emma', 0.5]]], [pre + '_michael', 'Michael', [[m2, 0.5], ['am_michael', 0.5]]], [pre + '_bella', 'Bella', [[f, 0.5], ['af_bella', 0.5]]], [pre + '_george', 'George', [[m2, 0.5], ['bm_george', 0.5]]], [pre + '_sarah', 'Sarah', [[f, 0.5], ['af_sarah', 0.5]]], [pre + '_puck', 'Puck', [[m, 0.5], ['am_puck', 0.5]]]]
|
|
22
|
+
.map(([name, label, mix]) => ({ name, label, locale, lang, mix }));
|
|
23
|
+
const ES = cast('es', 'es_ES', 'es', 'ef_dora', 'em_alex', 'em_santa'), PT = cast('pt', 'pt_BR', 'pt-br', 'pf_dora', 'pm_alex', 'pm_santa');
|
|
24
|
+
const VOICES = [...EN, ...FR, ...ES, ...PT], find = (n) => VOICES.find((v) => v.name === n);
|
|
25
|
+
const voices = () => VOICES.filter((v) => !v.lang || g2p()).map(({ name, label, locale }) => ({ name, label, locale })), hasVoice = (n) => !!find(n); // the ones that are not English are listed once the phonemizer is there; until then the page keeps the system voices for these languages
|
|
26
|
+
const localeOf = (n) => (find(n) || EN[0]).locale;
|
|
13
27
|
const speedFor = (wpm) => Math.max(0.5, Math.min(2, Math.round((wpm / 178) * 20) / 20)); // 178 words a minute is about Kokoro's natural pace
|
|
14
28
|
const exists = (f) => { try { fs.statSync(f); return true; } catch { return false; } };
|
|
15
29
|
const installed = () => exists(path.join(DIR, 'node_modules', 'kokoro-js', 'package.json'));
|
|
30
|
+
const g2p = () => installed() && exists(path.join(DIR, 'node_modules', 'espeak-ng', 'package.json')); // an install made before the other languages were added has kokoro-js alone: the same button adds the phonemizer
|
|
16
31
|
|
|
17
32
|
function findNpm() {
|
|
18
33
|
const home = os.homedir(), names = WIN ? ['npm.cmd', 'npm.bat', 'npm'] : ['npm'], cands = [];
|
|
@@ -23,13 +38,13 @@ function findNpm() {
|
|
|
23
38
|
return cands.find((c) => c && exists(c)) || null;
|
|
24
39
|
}
|
|
25
40
|
|
|
26
|
-
// ---- install: `npm install --prefix DIR kokoro-js@x`, output in DIR/install.log, one job at a time
|
|
41
|
+
// ---- install: `npm install --prefix DIR kokoro-js@x espeak-ng@y`, output in DIR/install.log, one job at a time
|
|
27
42
|
let job = null, lastError = '';
|
|
28
43
|
function install() {
|
|
29
|
-
if (job ||
|
|
44
|
+
if (job || g2p()) return status();
|
|
30
45
|
const npm = findNpm(); if (!npm) { lastError = 'npm not found'; return status(); }
|
|
31
46
|
fs.mkdirSync(DIR, { recursive: true }); lastError = '';
|
|
32
|
-
const out = fs.openSync(LOG, 'w'), args = ['install', '--prefix', DIR, '--no-audit', '--no-fund', PKG];
|
|
47
|
+
const out = fs.openSync(LOG, 'w'), args = ['install', '--prefix', DIR, '--no-audit', '--no-fund', PKG, G2P];
|
|
33
48
|
job = WIN && /\.(cmd|bat)$/i.test(npm) ? spawn('"' + npm + '"', args.map((a) => (a === DIR ? '"' + a + '"' : a)), { shell: true, stdio: ['ignore', out, out], windowsHide: true }) : spawn(npm, args, { stdio: ['ignore', out, out], windowsHide: true });
|
|
34
49
|
const done = (why) => { job = null; try { fs.closeSync(out); } catch {} if (why) lastError = why; else warm(); };
|
|
35
50
|
job.on('error', (e) => done('npm: ' + e.message));
|
|
@@ -63,7 +78,8 @@ function pump() {
|
|
|
63
78
|
const j = queue.shift(); let w; try { w = startWorker(); } catch (e) { j.reject(e); return pump(); }
|
|
64
79
|
const id = ++seq, next = (fn) => (v) => { busy = false; fn(v); pump(); }; busy = true;
|
|
65
80
|
w.pending.set(id, { resolve: next(j.resolve), reject: next(j.reject) });
|
|
66
|
-
|
|
81
|
+
const v = find(j.voice);
|
|
82
|
+
w.p.stdin.write(JSON.stringify({ id, text: j.text, voice: j.voice, speed: j.speed, out: j.out, lang: v.lang, mix: v.mix }) + '\n');
|
|
67
83
|
}
|
|
68
84
|
function synth(text, voice, speed, out) {
|
|
69
85
|
if (!installed()) return Promise.reject(new Error('kokoro not installed'));
|
|
@@ -72,11 +88,11 @@ function synth(text, voice, speed, out) {
|
|
|
72
88
|
}
|
|
73
89
|
function status() {
|
|
74
90
|
let log = ''; try { log = fs.readFileSync(LOG, 'utf8').slice(-400); } catch {}
|
|
75
|
-
return { dir: DIR, sizeMb: SIZE_MB, installed: installed(), installing: !!job, ready: !!(worker && worker.ready), gaveUp: restarts >= MAX_RESTARTS, error: lastError || null, npm: !!findNpm(), log };
|
|
91
|
+
return { dir: DIR, sizeMb: SIZE_MB, installed: installed(), g2p: g2p(), g2pMb: G2P_MB, installing: !!job, ready: !!(worker && worker.ready), gaveUp: restarts >= MAX_RESTARTS, error: lastError || null, npm: !!findNpm(), log };
|
|
76
92
|
}
|
|
77
93
|
function shutdown() {
|
|
78
94
|
for (const j of queue.splice(0)) j.reject(new Error('kokoro shut down'));
|
|
79
95
|
if (worker) { const w = worker; worker = null; try { w.p.kill(); } catch {} for (const r of w.pending.values()) r.reject(new Error('kokoro shut down')); w.pending.clear(); }
|
|
80
96
|
busy = false; if (job) { try { job.kill(); } catch {} job = null; }
|
|
81
97
|
}
|
|
82
|
-
module.exports = { DIR, voices, hasVoice, speedFor, status, install, warm, synth, shutdown };
|
|
98
|
+
module.exports = { DIR, voices, hasVoice, localeOf, speedFor, status, install, warm, synth, shutdown };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@double_geste/agent-standup",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.32.0",
|
|
4
4
|
"description": "Your Claude Code, Codex and Mistral Vibe agents as a live video call, from the terminal: a local page in your browser, plus one-line status for status bars. Free, open source, zero token cost.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"agent-standup": "bin/agent-standup.js"
|