clavarium 0.2.160-beta.1 → 0.2.161-beta.1
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/npm-shrinkwrap.json +6 -6
- package/package.json +2 -2
- package/server/boxes.mjs +23 -5
- package/server/main.mjs +2 -0
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.161-beta.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "clavarium",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.161-beta.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
|
13
13
|
"@xterm/xterm": "^6.0.0",
|
|
14
14
|
"clavarium-binder": "0.1.60-next.1",
|
|
15
15
|
"clavarium-docket": "0.1.2-next.2",
|
|
16
|
-
"clavarium-parley": "0.17.
|
|
16
|
+
"clavarium-parley": "0.17.69-next.1",
|
|
17
17
|
"clavarium-tether": "0.1.0-next.49",
|
|
18
18
|
"mammoth": "1.13.0",
|
|
19
19
|
"mermaid": "11.17.2",
|
|
@@ -787,9 +787,9 @@
|
|
|
787
787
|
}
|
|
788
788
|
},
|
|
789
789
|
"node_modules/clavarium-parley": {
|
|
790
|
-
"version": "0.17.
|
|
791
|
-
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.
|
|
792
|
-
"integrity": "sha512-
|
|
790
|
+
"version": "0.17.69-next.1",
|
|
791
|
+
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.69-next.1.tgz",
|
|
792
|
+
"integrity": "sha512-NDT/l1J97PKnaNSu1srD+cldqMRRISfzBckwH2odMFaGLTtXnxHSVLifpZxEojwoRU2OPKXuNTQj1ZLLR3oPkg==",
|
|
793
793
|
"license": "MIT",
|
|
794
794
|
"bin": {
|
|
795
795
|
"parley": "bin/parley.mjs",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.161-beta.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "A conversation is a VM with a terminal in it. Everything else is a folder.",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@xterm/xterm": "^6.0.0",
|
|
47
47
|
"clavarium-binder": "0.1.60-next.1",
|
|
48
48
|
"clavarium-docket": "0.1.2-next.2",
|
|
49
|
-
"clavarium-parley": "0.17.
|
|
49
|
+
"clavarium-parley": "0.17.69-next.1",
|
|
50
50
|
"clavarium-tether": "0.1.0-next.49",
|
|
51
51
|
"mammoth": "1.13.0",
|
|
52
52
|
"mermaid": "11.17.2",
|
package/server/boxes.mjs
CHANGED
|
@@ -33,6 +33,18 @@ export const FIRMWARE_MINUTES = 10;
|
|
|
33
33
|
export const CLIP_MAX_BYTES = 16_000 * 2 * 3;
|
|
34
34
|
export const WAKE_HEARD = /\bm[ae]i?s+\s?an?ge?s?\b|\b[ml][ae]s anges?\b|\bmesange|\bmaisange|\bmessage?s?\b|\bmessenge?s?\b/; /* « Messenges »: Whisper's reading of the server's own voice saying it */
|
|
35
35
|
export const WAKE_DROP = process.env.CLAVARIUM_WAKE_DROP === '1';
|
|
36
|
+
/* THE WORD BY ITS SOUND (05-11): on a lone word, Whisper writes « Mise en jeu », « Les ongles », « Mes doigts »
|
|
37
|
+
for « Mésange » -- 14 of 21 real calls of 05-11 were marked ✗ by the spelling alone. Read by its sound: a first
|
|
38
|
+
word in m/l ending on an s/z sound, then a word in an/en/on (« mise en… », « les ongles », « mes anges »), or
|
|
39
|
+
« mes doigts ». Measured on the 22 real cases of 05-11: 19 of 21 calls heard (11 before), the one talk of
|
|
40
|
+
the room (« Oui, à l'ombre ») not. */
|
|
41
|
+
const WAKE_SOUND = /^(?:\S+ )?[ml](?:a|e|i|ai|ei)(?:s|z|ss|se|ze|sse) (?:a|e|o)n|^m[ae]s doi/;
|
|
42
|
+
export const wakeHeard = (text) => { const t = plainWords(text); return WAKE_HEARD.test(t) || WAKE_SOUND.test(t.replace(/^l /, '')); };
|
|
43
|
+
/* DROPPED IN SILENCE (05-11, the owner's go): a wake whose word is not heard again AND whose voice was faint --
|
|
44
|
+
the room's talk from afar, not someone speaking to the box. Every real call of 05-11 that the word missed
|
|
45
|
+
had a firm voice or none measured; the false wake of 05-11, 429. Said by one discreet line in the thread. */
|
|
46
|
+
export const WAKE_FAINT = 600;
|
|
47
|
+
export const dropsWake = (ok, voice) => !ok && (WAKE_DROP || (Number.isFinite(voice) && voice > 0 && voice < WAKE_FAINT));
|
|
36
48
|
const plainWords = (t) => String(t).toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '').replace(/[^a-z\s]/g, ' ').replace(/\s+/g, ' ').trim();
|
|
37
49
|
export const SENTENCE_MAX = 300 * 32_000 + 32_000; /* 5 min of 16 kHz 16-bit mono, and some slack */
|
|
38
50
|
export const TRIES_PER_MINUTE = 10;
|
|
@@ -262,14 +274,14 @@ export function piecesOf(pcm, { least = 8, most = 14 } = {}) {
|
|
|
262
274
|
|
|
263
275
|
export class Boxes {
|
|
264
276
|
#file; #codes = new Map(); #links = new Map(); #tries = []; #now;
|
|
265
|
-
#exists; #hear; #say; #speak; #log; #changed; #images = new Map(); #origin; #spawn; #fetch; #streams = new Map(); #recordDir; #parts; #keep; #react; #learn;
|
|
277
|
+
#exists; #hear; #say; #note; #speak; #log; #changed; #images = new Map(); #origin; #spawn; #fetch; #streams = new Map(); #recordDir; #parts; #keep; #react; #learn;
|
|
266
278
|
|
|
267
279
|
/* file: a JsonFile holding [{ id, name, conversation, keyHash, firmware, createdAt, seenAt }].
|
|
268
280
|
exists(conversation), hear(wav) -> text, say(conversation, text, room), speak(text) -> PCM 16 kHz. */
|
|
269
|
-
constructor({ file, exists = () => true, hear, say, speak, changed = () => {}, origin = () => null, now = () => Date.now(), log = () => {}, spawn = spawnProcess, fetcher = fetch, recordDir = null, parts = null, keep = null, react = async () => null, learn = null }) {
|
|
281
|
+
constructor({ file, exists = () => true, hear, say, note = null, speak, changed = () => {}, origin = () => null, now = () => Date.now(), log = () => {}, spawn = spawnProcess, fetcher = fetch, recordDir = null, parts = null, keep = null, react = async () => null, learn = null }) {
|
|
270
282
|
this.#react = react; this.#learn = learn;
|
|
271
283
|
this.#spawn = spawn; this.#fetch = fetcher; this.#recordDir = recordDir; this.#parts = parts; this.#keep = keep;
|
|
272
|
-
this.#file = file; this.#changed = changed; this.#origin = origin; this.#exists = exists; this.#hear = hear; this.#say = say; this.#speak = speak; this.#now = now; this.#log = log;
|
|
284
|
+
this.#file = file; this.#changed = changed; this.#origin = origin; this.#exists = exists; this.#hear = hear; this.#say = say; this.#note = note; this.#speak = speak; this.#now = now; this.#log = log;
|
|
273
285
|
}
|
|
274
286
|
|
|
275
287
|
#all() { const v = this.#file.get(); return Array.isArray(v) ? v : []; }
|
|
@@ -783,6 +795,7 @@ export class Boxes {
|
|
|
783
795
|
if (m.t === 'listen.end' && m.ep) {
|
|
784
796
|
const end = endOf(m.ep, m.reason ?? '');
|
|
785
797
|
link.why = `${link.why ? `${link.why} · ` : ''}${end}`;
|
|
798
|
+
link.voice = Number(m.ep.voice);
|
|
786
799
|
this.#log(`voice box ${box.name}: ${end}`);
|
|
787
800
|
}
|
|
788
801
|
if (m.t === 'listen.end' && sentence) {
|
|
@@ -846,7 +859,7 @@ export class Boxes {
|
|
|
846
859
|
async #checkWake(link, pcm, { score = null, near = false } = {}) {
|
|
847
860
|
if (pcm.length < 8_000) return null;
|
|
848
861
|
const heard = String(await this.#hear(wavOf(pcm), link.box().lang) ?? '').trim();
|
|
849
|
-
const ok =
|
|
862
|
+
const ok = wakeHeard(heard);
|
|
850
863
|
/* Counted, and kept when the box learns (the clip only: never the sentence), with the box's score. */
|
|
851
864
|
const box = link.box();
|
|
852
865
|
try { this.#learn?.checked(box.id, pcm, ok, { keep: box.wake === 'learn', heard, score, near }); } catch (error) { this.#log(`voice box ${box.name}: wake clip not kept (${error.message})`); }
|
|
@@ -906,7 +919,12 @@ export class Boxes {
|
|
|
906
919
|
/* First in the line: Parley keeps 120 characters of `why`, and the end stats after it can pass that. */
|
|
907
920
|
link.why = `mot ${check.ok ? '\u2713' : '\u2717'} « ${check.heard.slice(0, 30)} »${link.why ? ` · ${link.why}` : ''}`;
|
|
908
921
|
this.#log(`voice box ${box.name}: wake word heard again: ${check.ok ? 'yes' : 'NO'} (« ${check.heard.slice(0, 40)} »)`);
|
|
909
|
-
if (
|
|
922
|
+
if (dropsWake(check.ok, link.voice)) {
|
|
923
|
+
link.send({ t: 'cue', name: 'done' });
|
|
924
|
+
this.#log(`voice box ${box.name}: wake ignored (word not heard again, faint voice ${Math.round(link.voice || 0)})`);
|
|
925
|
+
try { this.#note?.(box.conversation, { kind: 'box-wake-ignored', text: `Wake ignored on ${box.name}: « ${check.heard.slice(0, 40)} », faint voice`, topic: 'Voice box', tone: 'info' }); } catch { /* the log has it */ }
|
|
926
|
+
return;
|
|
927
|
+
}
|
|
910
928
|
}
|
|
911
929
|
/* Only a short order starts a recording ("lance l'enregistrement de la réunion"): a sentence that merely
|
|
912
930
|
mentions recording does not (01-11). */
|
package/server/main.mjs
CHANGED
|
@@ -658,6 +658,8 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
658
658
|
hear: (wav, lang) => hearBox(voice, wav, lang), /* any language heard; one neither the box's (its page's) nor English heard again in the box's (voice.mjs) */
|
|
659
659
|
/* Said as the person's own message, the room named (one speaker for now). */
|
|
660
660
|
say: (name, text, by) => (/^room:/.test(name) ? rooms.say(name.slice(5), text, { box: by?.id }) : talk.say(name, text, undefined, undefined, 'voice', { by })),
|
|
661
|
+
/* A discreet line in the thread, never a message to the agent: a wake ignored (05-11). A room: the log only. */
|
|
662
|
+
note: (name, event) => (/^room:/.test(name) ? null : talk.event(name, event)),
|
|
661
663
|
/* Each conversation's thread knows its boxes: their names, and the ids its agent answers. */
|
|
662
664
|
origin: () => publicOrigin ?? null,
|
|
663
665
|
changed: () => { try { rooms?.boxesBound(boxes.all()); } catch (error) { console.error(`voice boxes in rooms: ${error.message}`); } for (const c of all.list()) talk.speakers(c.name, boxes.speakersOf(c.name)); try { syncTargets(tethers.store(), boxes.all()); } catch (error) { console.error(`voice boxes in Tether: ${error.message}`); } },
|