clavarium 0.2.331-next.1 → 0.2.333-next.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 +2 -2
- package/package.json +1 -1
- package/server/boxes.mjs +13 -5
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.333-next.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.333-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/package.json
CHANGED
package/server/boxes.mjs
CHANGED
|
@@ -44,7 +44,13 @@ export const wakeHeard = (text) => { const t = plainWords(text); return WAKE_HEA
|
|
|
44
44
|
the room's talk from afar, not someone speaking to the box. Every real call of 05-11 that the word missed
|
|
45
45
|
had a firm voice or none measured; the false wake of 05-11, 429. Said by one discreet line in the thread. */
|
|
46
46
|
export const WAKE_FAINT = 600;
|
|
47
|
-
|
|
47
|
+
/* 06-11: a radio or a TV read a whole news flash after a false wake (120 s, cut by the length limit, no voice measured):
|
|
48
|
+
a sentence never ended is not someone speaking to the box -- not heard AND cut by the length limit is dropped too. */
|
|
49
|
+
/* 06-11 (again): the wake's own 1.6 s held no word at all (heard: nothing) -- the word was certainly not said: a radio's
|
|
50
|
+
music or jingle. A real call missed by the check always held words (its sentence begun). */
|
|
51
|
+
/* NOT "a second miss within 10 min": checked against the owner's calls of 05-11, it would have dropped a real one (05:18,
|
|
52
|
+
five minutes after a missed 05:13). A radio that says words after a false wake still comes through; nothing is answered. */
|
|
53
|
+
export const dropsWake = (ok, voice, reason = '', heard = 'x') => !ok && (WAKE_DROP || reason === 'timeout' || !String(heard ?? '').trim() || (Number.isFinite(voice) && voice > 0 && voice < WAKE_FAINT));
|
|
48
54
|
const plainWords = (t) => String(t).toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '').replace(/[^a-z\s]/g, ' ').replace(/\s+/g, ' ').trim();
|
|
49
55
|
export const SENTENCE_MAX = 300 * 32_000 + 32_000; /* 5 min of 16 kHz 16-bit mono, and some slack */
|
|
50
56
|
export const TRIES_PER_MINUTE = 10;
|
|
@@ -781,7 +787,7 @@ export class Boxes {
|
|
|
781
787
|
this.#log(`voice box ${box.name}: a sentence while recording here, the recording closed`);
|
|
782
788
|
r.out.end(() => { void this.#recorded(link, r); });
|
|
783
789
|
}
|
|
784
|
-
if (m.t === 'listen.start') { link.why = whyOf(m); link.wakeCheck = null; } /* its clip, if any, comes after listen.start: an older check never carries over */
|
|
790
|
+
if (m.t === 'listen.start') { link.why = whyOf(m); link.wakeCheck = null; link.voice = NaN; link.endReason = ''; } /* its clip, if any, comes after listen.start: an older check never carries over */
|
|
785
791
|
if (m.t === 'listen.start') { if (this.stop(box.id)) this.#log(`voice box ${box.name}: stopped playing, someone speaks`); sentence = []; size = 0; return; }
|
|
786
792
|
if (m.t === 'listen.end' && sentence && m.reason === 'nobody') {
|
|
787
793
|
/* Listened again, nobody spoke: a conversation ends there, in silence. */
|
|
@@ -792,6 +798,8 @@ export class Boxes {
|
|
|
792
798
|
link.send({ t: 'cue', name: 'done' });
|
|
793
799
|
return;
|
|
794
800
|
}
|
|
801
|
+
/* How this sentence ended, said with or without its measures (a radio cut at the length limit may have none). */
|
|
802
|
+
if (m.t === 'listen.end') link.endReason = String(m.reason ?? '');
|
|
795
803
|
if (m.t === 'listen.end' && m.ep) {
|
|
796
804
|
const end = endOf(m.ep, m.reason ?? '');
|
|
797
805
|
link.why = `${link.why ? `${link.why} · ` : ''}${end}`;
|
|
@@ -919,10 +927,10 @@ export class Boxes {
|
|
|
919
927
|
/* First in the line: Parley keeps 120 characters of `why`, and the end stats after it can pass that. */
|
|
920
928
|
link.why = `mot ${check.ok ? '\u2713' : '\u2717'} « ${check.heard.slice(0, 30)} »${link.why ? ` · ${link.why}` : ''}`;
|
|
921
929
|
this.#log(`voice box ${box.name}: wake word heard again: ${check.ok ? 'yes' : 'NO'} (« ${check.heard.slice(0, 40)} »)`);
|
|
922
|
-
if (dropsWake(check.ok, link.voice)) {
|
|
930
|
+
if (dropsWake(check.ok, link.voice, link.endReason, check.heard)) {
|
|
923
931
|
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 */ }
|
|
932
|
+
this.#log(`voice box ${box.name}: wake ignored (word not heard again, ${link.endReason === 'timeout' ? 'a sentence that never ended' : !check.heard.trim() ? 'no word in its clip' : `faint voice ${Math.round(link.voice || 0)}`})`);
|
|
933
|
+
try { this.#note?.(box.conversation, { kind: 'box-wake-ignored', text: `Wake ignored on ${box.name}: « ${check.heard.slice(0, 40)} », ${link.endReason === 'timeout' ? 'a sound that never stopped (radio, TV)' : !check.heard.trim() ? 'no word where the wake word should be' : 'faint voice'}`, topic: 'Voice box', tone: 'info' }); } catch { /* the log has it */ }
|
|
926
934
|
return;
|
|
927
935
|
}
|
|
928
936
|
}
|