clavarium 0.2.215-next.1 → 0.2.218-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 +7 -6
- package/server/pocket.mjs +9 -1
- package/server/speech.mjs +3 -1
- package/server/voice.mjs +3 -0
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.218-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.218-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
|
@@ -476,7 +476,7 @@ export class Boxes {
|
|
|
476
476
|
}
|
|
477
477
|
if (boxes.length === 0) return;
|
|
478
478
|
/* A question: the box listens again right after, no wake word needed. So does a box in CONVERSATION:
|
|
479
|
-
asked for ("mode conversation")
|
|
479
|
+
asked for ("mode conversation") -- never by itself any more (01-11);
|
|
480
480
|
it ends when nobody answers, or on "fin de la conversation". */
|
|
481
481
|
const question = !doing && (asked || /\?\s*$/.test(words));
|
|
482
482
|
for (const l of boxes) { l.answeredAt = this.#now(); clearTimeout(l.thinkingA); clearTimeout(l.thinkingB); }
|
|
@@ -499,11 +499,10 @@ export class Boxes {
|
|
|
499
499
|
}
|
|
500
500
|
}
|
|
501
501
|
}
|
|
502
|
+
/* Only when asked ("mode conversation"): opened by itself after two sentences, it stayed listening and
|
|
503
|
+
took in the room's talk -- the circle kept lit, stray words sent (01-11). */
|
|
502
504
|
#chatting(link) {
|
|
503
|
-
|
|
504
|
-
const now = this.#now();
|
|
505
|
-
link.recent = (link.recent ?? []).filter((t) => now - t < CHAT_WITHIN_MS);
|
|
506
|
-
return link.recent.length >= 2;
|
|
505
|
+
return Boolean(link.chat);
|
|
507
506
|
}
|
|
508
507
|
|
|
509
508
|
/* A box connected with its key: speaks protocol v1 on `socket` (a ws WebSocket). */
|
|
@@ -654,7 +653,9 @@ export class Boxes {
|
|
|
654
653
|
} catch (error) { this.#log(`voice box ${box0.name}: ${seconds} s heard, dictation failed (${error.message})`); await lost('Pardon, la dictée ne répond pas. Tu peux répéter ?'); return; }
|
|
655
654
|
if (!text) { this.#log(`voice box ${box0.name}: ${seconds} s heard, nothing recognised (silence?)`); await lost("Pardon, je n'ai rien compris. Tu peux répéter ?"); return; }
|
|
656
655
|
const box = link.box();
|
|
657
|
-
|
|
656
|
+
/* Only a short order starts a recording ("lance l'enregistrement de la réunion"): a sentence that merely
|
|
657
|
+
mentions recording does not (01-11). */
|
|
658
|
+
if (RECORD_ASKED.test(text) && text.split(/\s+/).length <= 10 && this.#recordDir && this.#parts) {
|
|
658
659
|
this.#log(`voice box ${box.name}: a recording asked`);
|
|
659
660
|
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 */ }
|
|
660
661
|
link.send({ t: 'record', on: true });
|
package/server/pocket.mjs
CHANGED
|
@@ -94,8 +94,16 @@ export class Pocket {
|
|
|
94
94
|
return this.#starting;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
/* Never waited for: while it is fetched or starts (minutes, the first time), the next voice speaks and this
|
|
98
|
+
one gets ready behind (01-11: answers held minutes while it downloaded). */
|
|
99
|
+
#warm() {
|
|
100
|
+
if (this.#child && this.#port) return this.#port;
|
|
101
|
+
if (!this.#starting) this.#ready().catch((error) => this.#log(`speech: Pocket TTS could not start (${error.message})`));
|
|
102
|
+
throw new Error('Pocket TTS is getting ready');
|
|
103
|
+
}
|
|
104
|
+
|
|
97
105
|
async #clause(text) {
|
|
98
|
-
const port =
|
|
106
|
+
const port = this.#warm();
|
|
99
107
|
const form = new FormData(); form.append('text', text);
|
|
100
108
|
const r = await this.#fetch(`http://127.0.0.1:${port}/tts`, { method: 'POST', body: form, signal: AbortSignal.timeout(30_000) });
|
|
101
109
|
if (!r.ok) throw new Error(`Pocket TTS answered ${r.status}`);
|
package/server/speech.mjs
CHANGED
|
@@ -105,7 +105,9 @@ export class Speech {
|
|
|
105
105
|
async speak(text) {
|
|
106
106
|
/* Pocket first; failed, it rests five minutes and the next voice answers meanwhile. */
|
|
107
107
|
if (this.#pocket && Date.now() - this.#pocketDown > 5 * 60_000) {
|
|
108
|
-
try { const pcm = await this.#pocket.speak(text); if (pcm.length) return pcm; } catch (error) {
|
|
108
|
+
try { const pcm = await this.#pocket.speak(text); if (pcm.length) return pcm; } catch (error) {
|
|
109
|
+
if (!/getting ready/.test(error.message)) { this.#pocketDown = Date.now(); this.#log(`speech: Pocket TTS failed (${error.message}), another voice meanwhile`); }
|
|
110
|
+
}
|
|
109
111
|
}
|
|
110
112
|
const online = await this.#eleven(text);
|
|
111
113
|
if (online && online.length) return online;
|
package/server/voice.mjs
CHANGED
|
@@ -80,6 +80,9 @@ const PHANTOMS = [
|
|
|
80
80
|
/sous[- ]titr(?:age|es?)\s+(?:par\s+)?(?:la\s+)?société\s+radio[- ]canada[.!]?/giu,
|
|
81
81
|
/* A credit to a person, when it is all that was "heard" ("Sous-titres par Jérémy Diaz", 31-10). */
|
|
82
82
|
/^\s*[Ss]ous[- ]titr(?:age|es?)(?:\s+réalisés?)?\s+par\s+(?:\p{Lu}[\p{L}'-]*\s*){1,3}[.!]?\s*$/gu,
|
|
83
|
+
/* YouTube endings, heard on a button press with nothing said (01-11: "Thank you for watching and see
|
|
84
|
+
you in the next video!"): only when they are all of it. */
|
|
85
|
+
/^\s*(?:thank(?:s| you) (?:so much )?for watching[.!,]?\s*(?:(?:and )?see you (?:in the |on the )?next (?:video|time)[.!]?)?|see you (?:in the )?next (?:video|time)[.!]?|merci d'avoir regardé(?: cette vidéo)?\s*[.!]?(?:\s*[àa] bient[ôo]t[.!]?)?)\s*$/giu,
|
|
83
86
|
/untertitel(?:ung)?\s+(?:im\s+auftrag\s+)?des\s+zdf(?:\s+für\s+funk)?,?\s*\d{0,4}[.!]?/giu,
|
|
84
87
|
];
|
|
85
88
|
export function withoutPhantoms(text) {
|