clavarium 0.2.182-next.1 → 0.2.183-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 +3 -2
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.183-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.183-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
|
@@ -41,6 +41,7 @@ export function toPcm16k(samples, from) {
|
|
|
41
41
|
export const ELEVEN_SECRET = 'ELEVENLABS_API_KEY';
|
|
42
42
|
export const ELEVEN_VOICE = 'onwK4e9ZLuTAKqWW03F9'; /* "Daniel" */
|
|
43
43
|
export const ELEVEN_MODEL = 'eleven_multilingual_v2';
|
|
44
|
+
export const SPEED = 1.1; /* a little quicker than the voices' own pace: found slow on the real box (31-10) */
|
|
44
45
|
|
|
45
46
|
export class Speech {
|
|
46
47
|
#dir; #lang; #engine = null; #loading = null; #fetch; #log; #secret;
|
|
@@ -55,7 +56,7 @@ export class Speech {
|
|
|
55
56
|
try {
|
|
56
57
|
const r = await this.#fetch(`https://api.elevenlabs.io/v1/text-to-speech/${ELEVEN_VOICE}?output_format=pcm_16000`, {
|
|
57
58
|
method: 'POST', headers: { 'xi-api-key': key, 'content-type': 'application/json' },
|
|
58
|
-
body: JSON.stringify({ text, model_id: ELEVEN_MODEL }), signal: AbortSignal.timeout(20_000),
|
|
59
|
+
body: JSON.stringify({ text, model_id: ELEVEN_MODEL, voice_settings: { stability: 0.5, similarity_boost: 0.75, speed: SPEED } }), signal: AbortSignal.timeout(20_000),
|
|
59
60
|
});
|
|
60
61
|
if (!r.ok) { this.#log(`speech: ElevenLabs answered ${r.status}, this server's voice instead`); return null; }
|
|
61
62
|
return Buffer.from(await r.arrayBuffer());
|
|
@@ -104,7 +105,7 @@ export class Speech {
|
|
|
104
105
|
const online = await this.#eleven(text);
|
|
105
106
|
if (online && online.length) return online;
|
|
106
107
|
const engine = await this.#load();
|
|
107
|
-
const audio = engine.generate({ text, sid: 0, speed:
|
|
108
|
+
const audio = engine.generate({ text, sid: 0, speed: SPEED });
|
|
108
109
|
return toPcm16k(audio.samples, audio.sampleRate);
|
|
109
110
|
}
|
|
110
111
|
}
|