@pompeii-labs/audio 0.0.1 → 0.0.3
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/dist/voice.d.mts +6 -0
- package/dist/voice.d.ts +6 -0
- package/dist/voice.js +13 -2
- package/dist/voice.mjs +13 -2
- package/package.json +6 -6
package/dist/voice.d.mts
CHANGED
|
@@ -21,6 +21,10 @@ declare abstract class MagmaFlowTextToSpeech {
|
|
|
21
21
|
constructor();
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
type MagmaFlowConfig = {
|
|
25
|
+
pauseDurationMs?: number;
|
|
26
|
+
setenceChunkLength?: number;
|
|
27
|
+
};
|
|
24
28
|
type MagmaFlowArgs = {
|
|
25
29
|
stt: MagmaFlowSpeechToText;
|
|
26
30
|
tts: MagmaFlowTextToSpeech;
|
|
@@ -29,6 +33,7 @@ type MagmaFlowArgs = {
|
|
|
29
33
|
onSpeechDetected: () => void;
|
|
30
34
|
onTextOutput: (text: string) => void;
|
|
31
35
|
onAudioOutput: (audio: Buffer) => void;
|
|
36
|
+
config?: MagmaFlowConfig;
|
|
32
37
|
};
|
|
33
38
|
declare class MagmaFlow {
|
|
34
39
|
private stt;
|
|
@@ -40,6 +45,7 @@ declare class MagmaFlow {
|
|
|
40
45
|
private textQueue;
|
|
41
46
|
private generatingAudio;
|
|
42
47
|
private audioBuffer;
|
|
48
|
+
private config;
|
|
43
49
|
constructor(args: MagmaFlowArgs);
|
|
44
50
|
inputAudio(audio: Buffer): void;
|
|
45
51
|
inputText(text: string): void;
|
package/dist/voice.d.ts
CHANGED
|
@@ -21,6 +21,10 @@ declare abstract class MagmaFlowTextToSpeech {
|
|
|
21
21
|
constructor();
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
type MagmaFlowConfig = {
|
|
25
|
+
pauseDurationMs?: number;
|
|
26
|
+
setenceChunkLength?: number;
|
|
27
|
+
};
|
|
24
28
|
type MagmaFlowArgs = {
|
|
25
29
|
stt: MagmaFlowSpeechToText;
|
|
26
30
|
tts: MagmaFlowTextToSpeech;
|
|
@@ -29,6 +33,7 @@ type MagmaFlowArgs = {
|
|
|
29
33
|
onSpeechDetected: () => void;
|
|
30
34
|
onTextOutput: (text: string) => void;
|
|
31
35
|
onAudioOutput: (audio: Buffer) => void;
|
|
36
|
+
config?: MagmaFlowConfig;
|
|
32
37
|
};
|
|
33
38
|
declare class MagmaFlow {
|
|
34
39
|
private stt;
|
|
@@ -40,6 +45,7 @@ declare class MagmaFlow {
|
|
|
40
45
|
private textQueue;
|
|
41
46
|
private generatingAudio;
|
|
42
47
|
private audioBuffer;
|
|
48
|
+
private config;
|
|
43
49
|
constructor(args: MagmaFlowArgs);
|
|
44
50
|
inputAudio(audio: Buffer): void;
|
|
45
51
|
inputText(text: string): void;
|
package/dist/voice.js
CHANGED
|
@@ -392,11 +392,16 @@ var MagmaFlow = class {
|
|
|
392
392
|
this.textQueue = [];
|
|
393
393
|
this.generatingAudio = false;
|
|
394
394
|
this.audioBuffer = [];
|
|
395
|
+
this.config = {
|
|
396
|
+
pauseDurationMs: 500,
|
|
397
|
+
setenceChunkLength: 50
|
|
398
|
+
};
|
|
395
399
|
this.stt = args.stt;
|
|
396
400
|
this.tts = args.tts;
|
|
397
401
|
this.inputFormat = args.inputFormat;
|
|
398
402
|
this.outputFormat = args.outputFormat;
|
|
399
403
|
this.onAudioOutput = args.onAudioOutput;
|
|
404
|
+
this.config = { ...this.config, ...args.config };
|
|
400
405
|
this.tts.onOutput = (audio) => {
|
|
401
406
|
if (!audio) {
|
|
402
407
|
const lastChunk = this.audioBuffer[this.audioBuffer.length - 1];
|
|
@@ -404,7 +409,13 @@ var MagmaFlow = class {
|
|
|
404
409
|
const lastChunkSamples = bufferToInt16Array(lastChunk);
|
|
405
410
|
const lastSampleValue = lastChunkSamples[lastChunkSamples.length - 1];
|
|
406
411
|
this.audioBuffer.push(
|
|
407
|
-
Buffer.from(
|
|
412
|
+
Buffer.from(
|
|
413
|
+
generateFadeOutSamples(
|
|
414
|
+
lastSampleValue,
|
|
415
|
+
this.config.pauseDurationMs ?? 500,
|
|
416
|
+
48e3
|
|
417
|
+
)
|
|
418
|
+
)
|
|
408
419
|
);
|
|
409
420
|
}
|
|
410
421
|
this.sendAudio();
|
|
@@ -430,7 +441,7 @@ var MagmaFlow = class {
|
|
|
430
441
|
return;
|
|
431
442
|
}
|
|
432
443
|
this.textBuffer += text;
|
|
433
|
-
const chunks = splitTextIntoChunks(this.textBuffer, 50);
|
|
444
|
+
const chunks = splitTextIntoChunks(this.textBuffer, this.config.setenceChunkLength ?? 50);
|
|
434
445
|
for (const chunk of chunks) {
|
|
435
446
|
this.textQueue.push(chunk);
|
|
436
447
|
this.textBuffer = this.textBuffer.slice(chunk.length);
|
package/dist/voice.mjs
CHANGED
|
@@ -386,11 +386,16 @@ var MagmaFlow = class {
|
|
|
386
386
|
this.textQueue = [];
|
|
387
387
|
this.generatingAudio = false;
|
|
388
388
|
this.audioBuffer = [];
|
|
389
|
+
this.config = {
|
|
390
|
+
pauseDurationMs: 500,
|
|
391
|
+
setenceChunkLength: 50
|
|
392
|
+
};
|
|
389
393
|
this.stt = args.stt;
|
|
390
394
|
this.tts = args.tts;
|
|
391
395
|
this.inputFormat = args.inputFormat;
|
|
392
396
|
this.outputFormat = args.outputFormat;
|
|
393
397
|
this.onAudioOutput = args.onAudioOutput;
|
|
398
|
+
this.config = { ...this.config, ...args.config };
|
|
394
399
|
this.tts.onOutput = (audio) => {
|
|
395
400
|
if (!audio) {
|
|
396
401
|
const lastChunk = this.audioBuffer[this.audioBuffer.length - 1];
|
|
@@ -398,7 +403,13 @@ var MagmaFlow = class {
|
|
|
398
403
|
const lastChunkSamples = bufferToInt16Array(lastChunk);
|
|
399
404
|
const lastSampleValue = lastChunkSamples[lastChunkSamples.length - 1];
|
|
400
405
|
this.audioBuffer.push(
|
|
401
|
-
Buffer.from(
|
|
406
|
+
Buffer.from(
|
|
407
|
+
generateFadeOutSamples(
|
|
408
|
+
lastSampleValue,
|
|
409
|
+
this.config.pauseDurationMs ?? 500,
|
|
410
|
+
48e3
|
|
411
|
+
)
|
|
412
|
+
)
|
|
402
413
|
);
|
|
403
414
|
}
|
|
404
415
|
this.sendAudio();
|
|
@@ -424,7 +435,7 @@ var MagmaFlow = class {
|
|
|
424
435
|
return;
|
|
425
436
|
}
|
|
426
437
|
this.textBuffer += text;
|
|
427
|
-
const chunks = splitTextIntoChunks(this.textBuffer, 50);
|
|
438
|
+
const chunks = splitTextIntoChunks(this.textBuffer, this.config.setenceChunkLength ?? 50);
|
|
428
439
|
for (const chunk of chunks) {
|
|
429
440
|
this.textQueue.push(chunk);
|
|
430
441
|
this.textBuffer = this.textBuffer.slice(chunk.length);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pompeii-labs/audio",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "The
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "The Audio SDK from Pompeii Labs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Pompeii",
|
|
7
7
|
"Typescript",
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
"typescript": "^5.6.2"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@deepgram/sdk": "
|
|
53
|
-
"@elevenlabs/elevenlabs-js": "
|
|
54
|
-
"hume": "
|
|
55
|
-
"openai": "
|
|
52
|
+
"@deepgram/sdk": ">=4.2.0",
|
|
53
|
+
"@elevenlabs/elevenlabs-js": ">=2.2.0",
|
|
54
|
+
"hume": ">=0.11.1",
|
|
55
|
+
"openai": ">=4.86.2"
|
|
56
56
|
}
|
|
57
57
|
}
|