clavarium 0.2.271-next.1 → 0.2.273-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/speech.mjs +9 -2
- package/server/voice.mjs +2 -0
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.273-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.273-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/package.json
CHANGED
package/server/speech.mjs
CHANGED
|
@@ -43,6 +43,8 @@ export const ELEVEN_VOICE = 'onwK4e9ZLuTAKqWW03F9'; /* "Daniel" */
|
|
|
43
43
|
export const ELEVEN_MODEL = 'eleven_multilingual_v2';
|
|
44
44
|
export const SPEED = 1.1; /* a little quicker than the voices' own pace: found slow on the real box (31-10) */
|
|
45
45
|
|
|
46
|
+
/* A moment before the main voice is asked again (a sentence it missed). */
|
|
47
|
+
export const AGAIN_MS = 700;
|
|
46
48
|
export class Speech {
|
|
47
49
|
#dir; #lang; #engine = null; #loading = null; #fetch; #log; #secret; #pocket; #pocketDown = 0;
|
|
48
50
|
|
|
@@ -104,9 +106,14 @@ export class Speech {
|
|
|
104
106
|
/* Text -> PCM 16 kHz. */
|
|
105
107
|
async speak(text) {
|
|
106
108
|
/* Pocket first; failed, it rests five minutes and the next voice answers meanwhile. */
|
|
109
|
+
/* One voice from the start of an answer to its end (03-11: "tu as bougé de voix au milieu"): a sentence it
|
|
110
|
+
misses is asked of it once more, a moment later, before another voice says it. */
|
|
107
111
|
if (this.#pocket && Date.now() - this.#pocketDown > 5 * 60_000) {
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
113
|
+
try { const pcm = await this.#pocket.speak(text); if (pcm.length) return pcm; } catch (error) {
|
|
114
|
+
if (attempt === 1 && !/getting ready/.test(error.message)) { this.#pocketDown = Date.now(); this.#log(`speech: Pocket TTS failed (${error.message}), another voice meanwhile`); }
|
|
115
|
+
}
|
|
116
|
+
if (attempt === 0) await new Promise((r) => setTimeout(r, AGAIN_MS));
|
|
110
117
|
}
|
|
111
118
|
}
|
|
112
119
|
const online = await this.#eleven(text);
|
package/server/voice.mjs
CHANGED
|
@@ -82,6 +82,8 @@ const PHANTOMS = [
|
|
|
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
83
|
/* YouTube endings, heard on a button press with nothing said (01-11: "Thank you for watching and see
|
|
84
84
|
you in the next video!"): only when they are all of it. */
|
|
85
|
+
/* « There you go. » alone, on a near silence (03-11, 5 a.m., nobody spoke): only when it is all of it. */
|
|
86
|
+
/^\s*there you go[.!]?\s*$/giu,
|
|
85
87
|
/^\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,
|
|
86
88
|
/untertitel(?:ung)?\s+(?:im\s+auftrag\s+)?des\s+zdf(?:\s+für\s+funk)?,?\s*\d{0,4}[.!]?/giu,
|
|
87
89
|
];
|