clavarium 0.2.331-next.1 → 0.2.332-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 +9 -5
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.332-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.332-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,9 @@ 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
|
+
export const dropsWake = (ok, voice, reason = '') => !ok && (WAKE_DROP || reason === 'timeout' || (Number.isFinite(voice) && voice > 0 && voice < WAKE_FAINT));
|
|
48
50
|
const plainWords = (t) => String(t).toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '').replace(/[^a-z\s]/g, ' ').replace(/\s+/g, ' ').trim();
|
|
49
51
|
export const SENTENCE_MAX = 300 * 32_000 + 32_000; /* 5 min of 16 kHz 16-bit mono, and some slack */
|
|
50
52
|
export const TRIES_PER_MINUTE = 10;
|
|
@@ -781,7 +783,7 @@ export class Boxes {
|
|
|
781
783
|
this.#log(`voice box ${box.name}: a sentence while recording here, the recording closed`);
|
|
782
784
|
r.out.end(() => { void this.#recorded(link, r); });
|
|
783
785
|
}
|
|
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 */
|
|
786
|
+
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
787
|
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
788
|
if (m.t === 'listen.end' && sentence && m.reason === 'nobody') {
|
|
787
789
|
/* Listened again, nobody spoke: a conversation ends there, in silence. */
|
|
@@ -792,6 +794,8 @@ export class Boxes {
|
|
|
792
794
|
link.send({ t: 'cue', name: 'done' });
|
|
793
795
|
return;
|
|
794
796
|
}
|
|
797
|
+
/* How this sentence ended, said with or without its measures (a radio cut at the length limit may have none). */
|
|
798
|
+
if (m.t === 'listen.end') link.endReason = String(m.reason ?? '');
|
|
795
799
|
if (m.t === 'listen.end' && m.ep) {
|
|
796
800
|
const end = endOf(m.ep, m.reason ?? '');
|
|
797
801
|
link.why = `${link.why ? `${link.why} · ` : ''}${end}`;
|
|
@@ -919,10 +923,10 @@ export class Boxes {
|
|
|
919
923
|
/* First in the line: Parley keeps 120 characters of `why`, and the end stats after it can pass that. */
|
|
920
924
|
link.why = `mot ${check.ok ? '\u2713' : '\u2717'} « ${check.heard.slice(0, 30)} »${link.why ? ` · ${link.why}` : ''}`;
|
|
921
925
|
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)) {
|
|
926
|
+
if (dropsWake(check.ok, link.voice, link.endReason)) {
|
|
923
927
|
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 */ }
|
|
928
|
+
this.#log(`voice box ${box.name}: wake ignored (word not heard again, ${link.endReason === 'timeout' ? 'a sentence that never ended' : `faint voice ${Math.round(link.voice || 0)}`})`);
|
|
929
|
+
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)' : 'faint voice'}`, topic: 'Voice box', tone: 'info' }); } catch { /* the log has it */ }
|
|
926
930
|
return;
|
|
927
931
|
}
|
|
928
932
|
}
|