clavarium 0.2.215-next.1 → 0.2.217-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 +3 -1
- package/server/pocket.mjs +9 -1
- package/server/speech.mjs +3 -1
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.217-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.217-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
|
@@ -654,7 +654,9 @@ export class Boxes {
|
|
|
654
654
|
} 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
655
|
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
656
|
const box = link.box();
|
|
657
|
-
|
|
657
|
+
/* Only a short order starts a recording ("lance l'enregistrement de la réunion"): a sentence that merely
|
|
658
|
+
mentions recording does not (01-11). */
|
|
659
|
+
if (RECORD_ASKED.test(text) && text.split(/\s+/).length <= 10 && this.#recordDir && this.#parts) {
|
|
658
660
|
this.#log(`voice box ${box.name}: a recording asked`);
|
|
659
661
|
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
662
|
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;
|