clavarium 0.2.220-next.1 → 0.2.223-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 +32 -4
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.223-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.223-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
|
@@ -132,6 +132,24 @@ export function sentencesOf(text) {
|
|
|
132
132
|
return out.filter(Boolean);
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
/* The words said while an answer is awaited (« Hmm… », « ça prend plus de temps ») -- off (01-11: heard all
|
|
136
|
+
the time while the box misheard, they made it worse; back once the sound path is sound). */
|
|
137
|
+
export const WAITING_WORDS = false;
|
|
138
|
+
/* WHAT THE BOX MEASURED, its sentence ended (firmware 0.1.38): how long, when a voice was heard, the bar it
|
|
139
|
+
used -- beside the message, with what reached this side. */
|
|
140
|
+
export function endOf(ep) {
|
|
141
|
+
if (!ep || typeof ep !== 'object') return '';
|
|
142
|
+
const n = (v) => (Number.isFinite(v) ? v : null);
|
|
143
|
+
const sec = (v) => `${v.toFixed(1).replace('.', ',')} s`;
|
|
144
|
+
const parts = [];
|
|
145
|
+
if (n(ep.s) !== null) parts.push(`écoute ${sec(ep.s)}`);
|
|
146
|
+
parts.push(n(ep.heard_at) !== null && ep.heard_at >= 0 ? `voix dès ${sec(ep.heard_at)}` : 'aucune voix détectée');
|
|
147
|
+
if (n(ep.bar) !== null) parts.push(`seuil ${Math.round(ep.bar)}`);
|
|
148
|
+
if (n(ep.voice) !== null && ep.voice > 0) parts.push(`voix ${Math.round(ep.voice)}`);
|
|
149
|
+
if (n(ep.mean) !== null) parts.push(`moyenne ${Math.round(ep.mean)}`);
|
|
150
|
+
if (n(ep.room) !== null) parts.push(`pièce ${Math.round(ep.room)}`);
|
|
151
|
+
return `boîtier : ${parts.join(', ')}`;
|
|
152
|
+
}
|
|
135
153
|
export const THINKING_AFTER_MS = 3_500;
|
|
136
154
|
export const LONGER_AFTER_MS = 12_000;
|
|
137
155
|
export const THINKING = ['Hmm…', 'Voyons…', 'Hmm, voyons voir…'];
|
|
@@ -164,6 +182,9 @@ export const TEST_MIC = 'Test du micro. Parle-moi, je t\'écoute.';
|
|
|
164
182
|
export const TEST_MIC_MS = 45_000;
|
|
165
183
|
/* A LONG RECORDING (a meeting, a class): asked in words, stopped by the button or the wake word. */
|
|
166
184
|
export const RECORD_ASKED = /\b(?:lance|d[ée]marre|commence|d[ée]bute)\w*\b.{0,25}\benregistrement\b|\benregistre\b.{0,20}\b(?:r[ée]union|conversation|cours|discussion|consultation)\b/i;
|
|
185
|
+
/* Off (01-11): a recording started without being asked, twice in a morning; back once it is asked for on
|
|
186
|
+
purpose (a button on the page). */
|
|
187
|
+
export const RECORD_BY_VOICE = false;
|
|
167
188
|
export const RECORD_MAX_BYTES = 4 * 3600 * 32_000; /* four hours */
|
|
168
189
|
export const mmss = (s) => `${String(Math.floor(s / 60)).padStart(2, '0')}:${String(Math.floor(s % 60)).padStart(2, '0')}`;
|
|
169
190
|
/* THE MIXER of a box that plays a stream: words said meanwhile go over it, the stream lowered to DUCK while
|
|
@@ -523,7 +544,9 @@ export class Boxes {
|
|
|
523
544
|
/* A question: the box listens again right after, no wake word needed. So does a box in CONVERSATION:
|
|
524
545
|
asked for ("mode conversation") -- never by itself any more (01-11);
|
|
525
546
|
it ends when nobody answers, or on "fin de la conversation". */
|
|
526
|
-
|
|
547
|
+
/* Only a question asked on purpose (parley ask) opens listening; one that merely ends in « ? » does not
|
|
548
|
+
any more (01-11: each follow-up listen took in the room and came back as invented words). */
|
|
549
|
+
const question = !doing && asked;
|
|
527
550
|
for (const l of boxes) { l.answeredAt = this.#now(); clearTimeout(l.thinkingA); clearTimeout(l.thinkingB); }
|
|
528
551
|
for (const l of boxes) {
|
|
529
552
|
/* An answer -- to a sentence heard within a minute -- may open the conversation; something said
|
|
@@ -630,6 +653,11 @@ export class Boxes {
|
|
|
630
653
|
link.send({ t: 'cue', name: 'done' });
|
|
631
654
|
return;
|
|
632
655
|
}
|
|
656
|
+
if (m.t === 'listen.end' && m.ep) {
|
|
657
|
+
const end = endOf(m.ep);
|
|
658
|
+
link.why = `${link.why ? `${link.why} ; ` : ''}fin : ${String(m.reason ?? '').slice(0, 20)} ; ${end}`;
|
|
659
|
+
this.#log(`voice box ${box.name}: listen ended (${String(m.reason ?? '').slice(0, 20)}), ${end}`);
|
|
660
|
+
}
|
|
633
661
|
if (m.t === 'listen.end' && sentence) {
|
|
634
662
|
const pcm = Buffer.concat(sentence);
|
|
635
663
|
sentence = null;
|
|
@@ -686,7 +714,7 @@ export class Boxes {
|
|
|
686
714
|
let text;
|
|
687
715
|
/* A sentence that goes nowhere is said so, in words, rather than with a beep nobody can read (31-10). */
|
|
688
716
|
const lost = async (words) => {
|
|
689
|
-
try { link.play(await this.#speak(words)
|
|
717
|
+
try { link.play(await this.#speak(words)); } catch { link.send({ t: 'cue', name: 'error' }); } /* not listened after: a loop of « pardon » on room noise (01-11) */
|
|
690
718
|
};
|
|
691
719
|
try {
|
|
692
720
|
const said = [];
|
|
@@ -714,7 +742,7 @@ export class Boxes {
|
|
|
714
742
|
const box = link.box();
|
|
715
743
|
/* Only a short order starts a recording ("lance l'enregistrement de la réunion"): a sentence that merely
|
|
716
744
|
mentions recording does not (01-11). */
|
|
717
|
-
if (RECORD_ASKED.test(text) && text.split(/\s+/).length <= 10 && this.#recordDir && this.#parts) {
|
|
745
|
+
if (RECORD_BY_VOICE && RECORD_ASKED.test(text) && text.split(/\s+/).length <= 10 && this.#recordDir && this.#parts) {
|
|
718
746
|
this.#log(`voice box ${box.name}: a recording asked`);
|
|
719
747
|
try { link.play(await this.#speak("J'enregistre. Pour arrêter, appuie sur le bouton ou dis le mot d'éveil.")); } catch { /* no voice: the light says it */ }
|
|
720
748
|
link.send({ t: 'record', on: true });
|
|
@@ -727,7 +755,7 @@ export class Boxes {
|
|
|
727
755
|
try { await this.#say(box.conversation, text, { id: box.id, name: box.name, ...(box.place ? { place: box.place } : {}), why: `${link.why ? `${link.why} ; ` : ''}${soundOf(pcm)}` }); } catch (error) { this.#log(`voice box ${box.name}: ${seconds} s heard and dictated, but not said in ${box.conversation} (${error.message})`); await lost("Pardon, je n'ai pas pu transmettre ta phrase. Tu peux répéter ?"); return; }
|
|
728
756
|
this.#log(`voice box ${box.name}: ${seconds} s heard, said in ${box.conversation}`);
|
|
729
757
|
link.heardAt = this.#now();
|
|
730
|
-
this.#waitFor(link, text);
|
|
758
|
+
if (WAITING_WORDS) this.#waitFor(link, text);
|
|
731
759
|
link.recent = [...(link.recent ?? []), link.heardAt];
|
|
732
760
|
if (/\bmode conversation\b/i.test(text)) link.chat = true;
|
|
733
761
|
if (/\b(?:fin|arr[eê]te|stop)\w*\b.{0,20}\b(?:conversation|[ée]couter)\b/i.test(text)) { link.chat = false; link.recent = []; }
|