@framers/agentos 0.1.184 → 0.1.185
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-pipeline/providers/ElevenLabsBatchTTS.d.ts +46 -0
- package/dist/voice-pipeline/providers/ElevenLabsBatchTTS.d.ts.map +1 -0
- package/dist/voice-pipeline/providers/ElevenLabsBatchTTS.js +61 -0
- package/dist/voice-pipeline/providers/ElevenLabsBatchTTS.js.map +1 -0
- package/dist/voice-pipeline/providers/index.d.ts +2 -0
- package/dist/voice-pipeline/providers/index.d.ts.map +1 -1
- package/dist/voice-pipeline/providers/index.js +2 -0
- package/dist/voice-pipeline/providers/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module voice-pipeline/providers/ElevenLabsBatchTTS
|
|
3
|
+
*
|
|
4
|
+
* Batch text-to-speech via ElevenLabs' REST API. Implements {@link IBatchTTS}
|
|
5
|
+
* for one-shot narration synthesis with voice settings control.
|
|
6
|
+
*/
|
|
7
|
+
import type { IBatchTTS, BatchTTSConfig, BatchTTSResult } from '../types.js';
|
|
8
|
+
/** Configuration for the ElevenLabs batch TTS provider. */
|
|
9
|
+
export interface ElevenLabsBatchTTSConfig {
|
|
10
|
+
/** ElevenLabs API key. */
|
|
11
|
+
apiKey: string;
|
|
12
|
+
/** Default voice ID. Falls back to 'EXAVITQu4vr4xnSDxMaL' (Rachel). */
|
|
13
|
+
voiceId?: string;
|
|
14
|
+
/** Model identifier. Defaults to 'eleven_multilingual_v2'. */
|
|
15
|
+
model?: string;
|
|
16
|
+
/** Base URL for the ElevenLabs API. Defaults to 'https://api.elevenlabs.io/v1'. */
|
|
17
|
+
baseUrl?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Batch (one-shot) TTS provider using ElevenLabs' REST text-to-speech endpoint.
|
|
21
|
+
*
|
|
22
|
+
* Accepts complete text and returns finished MP3 audio with voice settings
|
|
23
|
+
* control via `providerOptions` (stability, similarityBoost, style, useSpeakerBoost).
|
|
24
|
+
*/
|
|
25
|
+
export declare class ElevenLabsBatchTTS implements IBatchTTS {
|
|
26
|
+
readonly providerId = "elevenlabs-batch";
|
|
27
|
+
/** ElevenLabs API key used for authentication. */
|
|
28
|
+
private readonly apiKey;
|
|
29
|
+
/** Default voice ID when none is provided in the synthesis config. */
|
|
30
|
+
private readonly defaultVoiceId;
|
|
31
|
+
/** Model identifier sent with each request. */
|
|
32
|
+
private readonly model;
|
|
33
|
+
/** Base URL for all API requests. */
|
|
34
|
+
private readonly baseUrl;
|
|
35
|
+
constructor(config: ElevenLabsBatchTTSConfig);
|
|
36
|
+
/**
|
|
37
|
+
* Synthesize complete text into MP3 audio via ElevenLabs REST API.
|
|
38
|
+
*
|
|
39
|
+
* @param text - The text to synthesize.
|
|
40
|
+
* @param config - Optional synthesis configuration (voice, model, providerOptions).
|
|
41
|
+
* @returns Resolved {@link BatchTTSResult} containing the MP3 audio buffer.
|
|
42
|
+
* @throws Error if the API returns a non-OK status.
|
|
43
|
+
*/
|
|
44
|
+
synthesize(text: string, config?: BatchTTSConfig): Promise<BatchTTSResult>;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=ElevenLabsBatchTTS.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ElevenLabsBatchTTS.d.ts","sourceRoot":"","sources":["../../../src/voice-pipeline/providers/ElevenLabsBatchTTS.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7E,2DAA2D;AAC3D,MAAM,WAAW,wBAAwB;IACvC,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mFAAmF;IACnF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAKD;;;;;GAKG;AACH,qBAAa,kBAAmB,YAAW,SAAS;IAClD,QAAQ,CAAC,UAAU,sBAAsB;IAEzC,kDAAkD;IAClD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC,sEAAsE;IACtE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IAExC,+CAA+C;IAC/C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAE/B,qCAAqC;IACrC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,MAAM,EAAE,wBAAwB;IAO5C;;;;;;;OAOG;IACG,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;CAiCjF"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module voice-pipeline/providers/ElevenLabsBatchTTS
|
|
3
|
+
*
|
|
4
|
+
* Batch text-to-speech via ElevenLabs' REST API. Implements {@link IBatchTTS}
|
|
5
|
+
* for one-shot narration synthesis with voice settings control.
|
|
6
|
+
*/
|
|
7
|
+
/** Approximate bytes per second for 128kbps MP3 audio. */
|
|
8
|
+
const BYTES_PER_SEC_MP3 = 16000;
|
|
9
|
+
/**
|
|
10
|
+
* Batch (one-shot) TTS provider using ElevenLabs' REST text-to-speech endpoint.
|
|
11
|
+
*
|
|
12
|
+
* Accepts complete text and returns finished MP3 audio with voice settings
|
|
13
|
+
* control via `providerOptions` (stability, similarityBoost, style, useSpeakerBoost).
|
|
14
|
+
*/
|
|
15
|
+
export class ElevenLabsBatchTTS {
|
|
16
|
+
constructor(config) {
|
|
17
|
+
this.providerId = 'elevenlabs-batch';
|
|
18
|
+
this.apiKey = config.apiKey;
|
|
19
|
+
this.defaultVoiceId = config.voiceId ?? 'EXAVITQu4vr4xnSDxMaL';
|
|
20
|
+
this.model = config.model ?? 'eleven_multilingual_v2';
|
|
21
|
+
this.baseUrl = config.baseUrl ?? 'https://api.elevenlabs.io/v1';
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Synthesize complete text into MP3 audio via ElevenLabs REST API.
|
|
25
|
+
*
|
|
26
|
+
* @param text - The text to synthesize.
|
|
27
|
+
* @param config - Optional synthesis configuration (voice, model, providerOptions).
|
|
28
|
+
* @returns Resolved {@link BatchTTSResult} containing the MP3 audio buffer.
|
|
29
|
+
* @throws Error if the API returns a non-OK status.
|
|
30
|
+
*/
|
|
31
|
+
async synthesize(text, config) {
|
|
32
|
+
const voiceId = config?.voice ?? this.defaultVoiceId;
|
|
33
|
+
const opts = config?.providerOptions ?? {};
|
|
34
|
+
const res = await fetch(`${this.baseUrl}/text-to-speech/${voiceId}`, {
|
|
35
|
+
method: 'POST',
|
|
36
|
+
headers: {
|
|
37
|
+
'xi-api-key': this.apiKey,
|
|
38
|
+
'Content-Type': 'application/json',
|
|
39
|
+
Accept: 'audio/mpeg',
|
|
40
|
+
},
|
|
41
|
+
body: JSON.stringify({
|
|
42
|
+
text,
|
|
43
|
+
model_id: config?.model ?? this.model,
|
|
44
|
+
voice_settings: {
|
|
45
|
+
stability: opts.stability ?? 0.5,
|
|
46
|
+
similarity_boost: opts.similarityBoost ?? 0.75,
|
|
47
|
+
style: opts.style ?? 0.0,
|
|
48
|
+
use_speaker_boost: opts.useSpeakerBoost ?? true,
|
|
49
|
+
},
|
|
50
|
+
}),
|
|
51
|
+
});
|
|
52
|
+
if (!res.ok) {
|
|
53
|
+
const detail = await res.text().catch(() => '');
|
|
54
|
+
throw new Error(`ElevenLabs TTS failed: ${res.status} ${detail.slice(0, 200)}`);
|
|
55
|
+
}
|
|
56
|
+
const audio = Buffer.from(await res.arrayBuffer());
|
|
57
|
+
const durationMs = Math.round((audio.byteLength / BYTES_PER_SEC_MP3) * 1000);
|
|
58
|
+
return { audio, format: 'mp3', durationMs, provider: this.providerId };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=ElevenLabsBatchTTS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ElevenLabsBatchTTS.js","sourceRoot":"","sources":["../../../src/voice-pipeline/providers/ElevenLabsBatchTTS.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgBH,0DAA0D;AAC1D,MAAM,iBAAiB,GAAG,KAAM,CAAC;AAEjC;;;;;GAKG;AACH,MAAM,OAAO,kBAAkB;IAe7B,YAAY,MAAgC;QAdnC,eAAU,GAAG,kBAAkB,CAAC;QAevC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,OAAO,IAAI,sBAAsB,CAAC;QAC/D,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,wBAAwB,CAAC;QACtD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,8BAA8B,CAAC;IAClE,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,UAAU,CAAC,IAAY,EAAE,MAAuB;QACpD,MAAM,OAAO,GAAG,MAAM,EAAE,KAAK,IAAI,IAAI,CAAC,cAAc,CAAC;QACrD,MAAM,IAAI,GAAG,MAAM,EAAE,eAAe,IAAI,EAAE,CAAC;QAE3C,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,OAAO,mBAAmB,OAAO,EAAE,EAAE;YACnE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,YAAY,EAAE,IAAI,CAAC,MAAM;gBACzB,cAAc,EAAE,kBAAkB;gBAClC,MAAM,EAAE,YAAY;aACrB;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,IAAI;gBACJ,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,IAAI,CAAC,KAAK;gBACrC,cAAc,EAAE;oBACd,SAAS,EAAG,IAAI,CAAC,SAAoB,IAAI,GAAG;oBAC5C,gBAAgB,EAAG,IAAI,CAAC,eAA0B,IAAI,IAAI;oBAC1D,KAAK,EAAG,IAAI,CAAC,KAAgB,IAAI,GAAG;oBACpC,iBAAiB,EAAG,IAAI,CAAC,eAA2B,IAAI,IAAI;iBAC7D;aACF,CAAC;SACH,CAAC,CAAC;QAEH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;YAChD,MAAM,IAAI,KAAK,CAAC,0BAA0B,GAAG,CAAC,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;QAClF,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;QACnD,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,UAAU,GAAG,iBAAiB,CAAC,GAAG,IAAI,CAAC,CAAC;QAE7E,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC;IACzE,CAAC;CACF"}
|
|
@@ -6,10 +6,12 @@
|
|
|
6
6
|
* - {@link ElevenLabsStreamingTTS} — ElevenLabs WebSocket streaming TTS
|
|
7
7
|
* - {@link AgentSessionVoiceAdapter} — AgentOS session → voice pipeline adapter
|
|
8
8
|
* - {@link OpenAIBatchTTS} — OpenAI batch (one-shot) TTS
|
|
9
|
+
* - {@link ElevenLabsBatchTTS} — ElevenLabs batch (one-shot) TTS
|
|
9
10
|
*/
|
|
10
11
|
export { DeepgramStreamingSTT, type DeepgramStreamingSTTConfig } from './DeepgramStreamingSTT.js';
|
|
11
12
|
export { ElevenLabsStreamingSTT, type ElevenLabsStreamingSTTConfig, } from './ElevenLabsStreamingSTT.js';
|
|
12
13
|
export { ElevenLabsStreamingTTS, type ElevenLabsStreamingTTSConfig, } from './ElevenLabsStreamingTTS.js';
|
|
13
14
|
export { AgentSessionVoiceAdapter } from './AgentSessionVoiceAdapter.js';
|
|
14
15
|
export { OpenAIBatchTTS, type OpenAIBatchTTSConfig } from './OpenAIBatchTTS.js';
|
|
16
|
+
export { ElevenLabsBatchTTS, type ElevenLabsBatchTTSConfig } from './ElevenLabsBatchTTS.js';
|
|
15
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/voice-pipeline/providers/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/voice-pipeline/providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,oBAAoB,EAAE,KAAK,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAClG,OAAO,EACL,sBAAsB,EACtB,KAAK,4BAA4B,GAClC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,sBAAsB,EACtB,KAAK,4BAA4B,GAClC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,KAAK,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,KAAK,wBAAwB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -6,10 +6,12 @@
|
|
|
6
6
|
* - {@link ElevenLabsStreamingTTS} — ElevenLabs WebSocket streaming TTS
|
|
7
7
|
* - {@link AgentSessionVoiceAdapter} — AgentOS session → voice pipeline adapter
|
|
8
8
|
* - {@link OpenAIBatchTTS} — OpenAI batch (one-shot) TTS
|
|
9
|
+
* - {@link ElevenLabsBatchTTS} — ElevenLabs batch (one-shot) TTS
|
|
9
10
|
*/
|
|
10
11
|
export { DeepgramStreamingSTT } from './DeepgramStreamingSTT.js';
|
|
11
12
|
export { ElevenLabsStreamingSTT, } from './ElevenLabsStreamingSTT.js';
|
|
12
13
|
export { ElevenLabsStreamingTTS, } from './ElevenLabsStreamingTTS.js';
|
|
13
14
|
export { AgentSessionVoiceAdapter } from './AgentSessionVoiceAdapter.js';
|
|
14
15
|
export { OpenAIBatchTTS } from './OpenAIBatchTTS.js';
|
|
16
|
+
export { ElevenLabsBatchTTS } from './ElevenLabsBatchTTS.js';
|
|
15
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/voice-pipeline/providers/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/voice-pipeline/providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,oBAAoB,EAAmC,MAAM,2BAA2B,CAAC;AAClG,OAAO,EACL,sBAAsB,GAEvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,sBAAsB,GAEvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,cAAc,EAA6B,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAiC,MAAM,yBAAyB,CAAC"}
|