@shogo-ai/voice 1.10.0 → 2.4.2
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/README.md +89 -0
- package/dist/{chunk-S3S2RNO6.js → chunk-BI6SL35K.js} +1 -184
- package/dist/chunk-IOFWML5L.js +1078 -0
- package/dist/chunk-KMSL5PWK.js +540 -0
- package/dist/chunk-ME3SIZZU.js +581 -0
- package/dist/{chunk-T3T4EBWY.js → chunk-RALZRMFL.js} +6 -2
- package/dist/chunk-TQOBJMEK.js +17 -0
- package/dist/chunk-U5UC7ZVS.js +988 -0
- package/dist/chunk-UW7VQ3S6.js +148 -0
- package/dist/chunk-ZAW6F3YT.js +172 -0
- package/dist/index.cjs +748 -25
- package/dist/index.d.cts +396 -3
- package/dist/index.d.ts +396 -3
- package/dist/index.js +63 -3
- package/dist/live/client.cjs +173 -0
- package/dist/live/client.d.cts +132 -0
- package/dist/live/client.d.ts +132 -0
- package/dist/live/client.js +9 -0
- package/dist/native/index.d.cts +5 -2
- package/dist/native/index.d.ts +5 -2
- package/dist/native/index.js +15 -11
- package/dist/{organicParticlesShaders-DIva0vBO.d.ts → organicParticlesShaders-seZq7jYX.d.cts} +1 -421
- package/dist/{organicParticlesShaders-DIva0vBO.d.cts → organicParticlesShaders-seZq7jYX.d.ts} +1 -421
- package/dist/particlesConfig-0YbdPOdY.d.cts +223 -0
- package/dist/particlesConfig-0YbdPOdY.d.ts +223 -0
- package/dist/react/conversation.cjs +789 -0
- package/dist/react/conversation.d.cts +134 -0
- package/dist/react/conversation.d.ts +134 -0
- package/dist/react/conversation.js +13 -0
- package/dist/react/index.cjs +374 -36
- package/dist/react/index.d.cts +10 -141
- package/dist/react/index.d.ts +10 -141
- package/dist/react/index.js +23 -770
- package/dist/react/visuals.cjs +1048 -0
- package/dist/react/visuals.d.cts +70 -0
- package/dist/react/visuals.d.ts +70 -0
- package/dist/react/visuals.js +10 -0
- package/dist/route/agent.cjs +1047 -85
- package/dist/route/agent.js +3 -3
- package/dist/route/audio-tags.cjs +1047 -85
- package/dist/route/audio-tags.js +3 -3
- package/dist/route/index.cjs +1051 -85
- package/dist/route/index.d.cts +19 -3
- package/dist/route/index.d.ts +19 -3
- package/dist/route/index.js +3 -3
- package/dist/route/music.cjs +1047 -85
- package/dist/route/music.js +3 -3
- package/dist/route/op.cjs +2127 -0
- package/dist/route/op.d.cts +43 -0
- package/dist/route/op.d.ts +43 -0
- package/dist/route/op.js +27 -0
- package/dist/route/signed-url.cjs +1047 -85
- package/dist/route/signed-url.js +3 -3
- package/dist/route/tts-preview.cjs +1047 -85
- package/dist/route/tts-preview.d.cts +6 -4
- package/dist/route/tts-preview.d.ts +6 -4
- package/dist/route/tts-preview.js +3 -3
- package/dist/server.cjs +1047 -85
- package/dist/server.d.cts +40 -8
- package/dist/server.d.ts +40 -8
- package/dist/server.js +2 -2
- package/dist/types-Bfhu-aQH.d.cts +199 -0
- package/dist/types-Bfhu-aQH.d.ts +199 -0
- package/dist/{types-W9y6eMj3.d.ts → types-CadjTXNH.d.cts} +193 -12
- package/dist/{types-W9y6eMj3.d.cts → types-CadjTXNH.d.ts} +193 -12
- package/package.json +21 -1
- package/dist/chunk-B4JC3DK2.js +0 -529
- package/dist/chunk-O362EJQR.js +0 -524
|
@@ -96,11 +96,72 @@ declare function readVoiceSettings(raw: unknown): VoiceSettings;
|
|
|
96
96
|
*/
|
|
97
97
|
|
|
98
98
|
declare const DEFAULT_ELEVENLABS_BASE_URL = "https://api.elevenlabs.io";
|
|
99
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* The one ElevenLabs TTS model table. Everything that needs to know which
|
|
101
|
+
* models exist, which are realtime/convai-capable and how much text each
|
|
102
|
+
* accepts reads from here — `resolveConvaiTtsModel*()` below, the hosted
|
|
103
|
+
* `/api/voice/tts` route, and the docs.
|
|
104
|
+
*
|
|
105
|
+
* `maxChars` is ElevenLabs' per-request character cap for the model;
|
|
106
|
+
* `realtime` marks the subset that a convai agent can run on.
|
|
107
|
+
*/
|
|
108
|
+
interface VoiceTtsModel {
|
|
109
|
+
id: string;
|
|
110
|
+
label: string;
|
|
111
|
+
/** Usable as a convai agent's TTS model (low-latency websocket path). */
|
|
112
|
+
realtime: boolean;
|
|
113
|
+
/** Per-request character cap enforced by ElevenLabs. */
|
|
114
|
+
maxChars: number;
|
|
115
|
+
/** Listed for back-compat; still callable, but not what new agents get. */
|
|
116
|
+
deprecated?: boolean;
|
|
117
|
+
}
|
|
118
|
+
declare const VOICE_TTS_MODELS: readonly VoiceTtsModel[];
|
|
119
|
+
/** Every model id we know about, in table order. */
|
|
120
|
+
declare const VOICE_TTS_MODEL_IDS: readonly string[];
|
|
121
|
+
/** Default model for a plain one-shot `textToSpeech()` call. */
|
|
122
|
+
declare const DEFAULT_TTS_MODEL = "eleven_v4";
|
|
123
|
+
/** TTS models a convai agent can run on. */
|
|
100
124
|
declare const CONVAI_SUPPORTED_TTS_MODELS: Set<string>;
|
|
101
|
-
declare const CONVAI_TTS_MODEL_FALLBACK = "
|
|
125
|
+
declare const CONVAI_TTS_MODEL_FALLBACK = "eleven_v4_turbo";
|
|
126
|
+
/**
|
|
127
|
+
* Last-resort model for a one-shot {@link ElevenLabsClient.textToSpeech} retry.
|
|
128
|
+
*
|
|
129
|
+
* Deliberately *not* {@link CONVAI_TTS_MODEL_FALLBACK}: a BYO account on an
|
|
130
|
+
* older plan can have neither v4 model, and the whole point of the retry is to
|
|
131
|
+
* land on one that is available to everybody. Flash v2.5 is the
|
|
132
|
+
* widest-available and cheapest of the current models.
|
|
133
|
+
*/
|
|
134
|
+
declare const TTS_FALLBACK_MODEL = "eleven_flash_v2_5";
|
|
135
|
+
/** Look up a model's metadata, or `undefined` when the id is unknown. */
|
|
136
|
+
declare function getVoiceTtsModel(modelId: string | null | undefined): VoiceTtsModel | undefined;
|
|
137
|
+
interface ConvaiTtsModelResolution {
|
|
138
|
+
/** The model the agent will actually be configured with. */
|
|
139
|
+
modelId: string;
|
|
140
|
+
/** What the caller asked for (null/undefined when they asked for nothing). */
|
|
141
|
+
requested: string | null;
|
|
142
|
+
/** True when a requested model was replaced by {@link CONVAI_TTS_MODEL_FALLBACK}. */
|
|
143
|
+
downgraded: boolean;
|
|
144
|
+
/** Why the requested model was rejected (absent when nothing was requested). */
|
|
145
|
+
reason?: string;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Resolve a requested convai TTS model, reporting whether we had to
|
|
149
|
+
* substitute it. `eleven_v4`, `eleven_v3` and any unknown id are not
|
|
150
|
+
* convai-capable and resolve to {@link CONVAI_TTS_MODEL_FALLBACK}; every
|
|
151
|
+
* distinct downgrade is logged once so a caller can see it in pod logs
|
|
152
|
+
* instead of silently getting a different voice model.
|
|
153
|
+
*/
|
|
154
|
+
declare function resolveConvaiTtsModelDetailed(requested: string | null | undefined): ConvaiTtsModelResolution;
|
|
102
155
|
/** If `requested` isn't a convai-compatible TTS model, fall back to the default. */
|
|
103
156
|
declare function resolveConvaiTtsModel(requested: string | null | undefined): string;
|
|
157
|
+
/**
|
|
158
|
+
* Whether an ElevenLabs TTS failure is plausibly about the model rather than
|
|
159
|
+
* about the request as a whole: 402 (model not in the plan) always counts,
|
|
160
|
+
* and 400/403/404/422 count only when the body mentions model / plan /
|
|
161
|
+
* permission. 401, 429, 5xx and network errors never do — retrying those on
|
|
162
|
+
* another model only hides the real problem.
|
|
163
|
+
*/
|
|
164
|
+
declare function isModelRelatedTtsFailure(status: number, body: string): boolean;
|
|
104
165
|
interface ElevenLabsClientConfig {
|
|
105
166
|
apiKey: string;
|
|
106
167
|
/** Override for tests or self-hosted proxies. Defaults to the public API. */
|
|
@@ -156,11 +217,25 @@ interface PatchAgentParams {
|
|
|
156
217
|
interface TextToSpeechParams {
|
|
157
218
|
voiceId: string;
|
|
158
219
|
text: string;
|
|
220
|
+
/** Defaults to {@link DEFAULT_TTS_MODEL} (`eleven_v4`). */
|
|
159
221
|
modelId?: string;
|
|
160
222
|
voiceSettings?: VoiceSettings;
|
|
161
223
|
/** Accept header; defaults to `audio/mpeg`. */
|
|
162
224
|
accept?: string;
|
|
163
225
|
}
|
|
226
|
+
/** Result of {@link ElevenLabsClient.textToSpeech}. */
|
|
227
|
+
interface TextToSpeechResult {
|
|
228
|
+
audio: ArrayBuffer;
|
|
229
|
+
/** The model that actually produced the audio. */
|
|
230
|
+
modelId: string;
|
|
231
|
+
/** The model the caller asked for (defaulted when they passed none). */
|
|
232
|
+
requestedModel: string;
|
|
233
|
+
/** True when `modelId !== requestedModel` because of a model-related error. */
|
|
234
|
+
fellBack: boolean;
|
|
235
|
+
/** Why we fell back (upstream status + body snippet). */
|
|
236
|
+
fallbackReason?: string;
|
|
237
|
+
contentType: string;
|
|
238
|
+
}
|
|
164
239
|
/** Options for the low-level {@link ElevenLabsClient.request} escape hatch. */
|
|
165
240
|
interface ElevenLabsRequestOptions {
|
|
166
241
|
/** HTTP method, e.g. `'POST'`. */
|
|
@@ -204,6 +279,70 @@ interface ComposeMusicParams {
|
|
|
204
279
|
outputFormat?: string;
|
|
205
280
|
}
|
|
206
281
|
declare const DEFAULT_MUSIC_MODEL = "music_v1";
|
|
282
|
+
/**
|
|
283
|
+
* ElevenLabs speech-to-speech ("voice changer") models. The multilingual one
|
|
284
|
+
* is the cross-language default; the English one is cheaper and sharper on
|
|
285
|
+
* English input.
|
|
286
|
+
*/
|
|
287
|
+
declare const VOICE_STS_MODEL_IDS: readonly string[];
|
|
288
|
+
declare const DEFAULT_STS_MODEL = "eleven_multilingual_sts_v2";
|
|
289
|
+
/** ElevenLabs Scribe speech-to-text models. */
|
|
290
|
+
declare const VOICE_SPEECH_TO_TEXT_MODEL_IDS: readonly string[];
|
|
291
|
+
declare const DEFAULT_SPEECH_TO_TEXT_MODEL = "scribe_v1";
|
|
292
|
+
/** ElevenLabs text-to-sound-effects models. */
|
|
293
|
+
declare const VOICE_SOUND_GENERATION_MODEL_IDS: readonly string[];
|
|
294
|
+
declare const DEFAULT_SOUND_GENERATION_MODEL = "eleven_text_to_sound_v2";
|
|
295
|
+
/** Parameters for {@link ElevenLabsClient.speechToSpeech} (the voice changer). */
|
|
296
|
+
interface SpeechToSpeechParams {
|
|
297
|
+
/** Target voice. `POST /v1/speech-to-speech/{voiceId}`. */
|
|
298
|
+
voiceId: string;
|
|
299
|
+
/** Source audio to convert. */
|
|
300
|
+
audio: Blob;
|
|
301
|
+
/** Filename sent in the multipart part; defaults to `audio`. */
|
|
302
|
+
fileName?: string;
|
|
303
|
+
/** One of `VOICE_STS_MODEL_IDS`; defaults to `eleven_multilingual_sts_v2`. */
|
|
304
|
+
modelId?: string;
|
|
305
|
+
voiceSettings?: VoiceSettings;
|
|
306
|
+
/** Output container/quality, e.g. `mp3_44100_192`. */
|
|
307
|
+
outputFormat?: string;
|
|
308
|
+
/** `pcm_s16le_16` / `other` (mp3) / `ulaw_8000`. */
|
|
309
|
+
fileFormat?: string;
|
|
310
|
+
seed?: number;
|
|
311
|
+
removeBackgroundNoise?: boolean;
|
|
312
|
+
}
|
|
313
|
+
/** Parameters for {@link ElevenLabsClient.soundEffects}. */
|
|
314
|
+
interface SoundEffectsParams {
|
|
315
|
+
text: string;
|
|
316
|
+
/** 0.5–30 s. */
|
|
317
|
+
durationSeconds?: number;
|
|
318
|
+
/** 0–1; how literally the prompt is followed. */
|
|
319
|
+
promptInfluence?: number;
|
|
320
|
+
loop?: boolean;
|
|
321
|
+
/** Defaults to `eleven_text_to_sound_v2`. */
|
|
322
|
+
modelId?: string;
|
|
323
|
+
outputFormat?: string;
|
|
324
|
+
}
|
|
325
|
+
/** Parameters for {@link ElevenLabsClient.transcribe} (Scribe speech-to-text). */
|
|
326
|
+
interface TranscribeParams {
|
|
327
|
+
file: Blob;
|
|
328
|
+
/** Filename sent in the multipart part; defaults to `audio`. */
|
|
329
|
+
fileName?: string;
|
|
330
|
+
/** Defaults to `scribe_v1`. */
|
|
331
|
+
modelId?: string;
|
|
332
|
+
/** ISO-639-1/3 code; omit to auto-detect. */
|
|
333
|
+
languageCode?: string;
|
|
334
|
+
diarize?: boolean;
|
|
335
|
+
tagAudioEvents?: boolean;
|
|
336
|
+
numSpeakers?: number;
|
|
337
|
+
}
|
|
338
|
+
/** A Scribe transcription. Extra provider fields are passed through as-is. */
|
|
339
|
+
interface TranscriptionResult {
|
|
340
|
+
text: string;
|
|
341
|
+
language_code?: string;
|
|
342
|
+
language_probability?: number;
|
|
343
|
+
words?: unknown[];
|
|
344
|
+
[key: string]: unknown;
|
|
345
|
+
}
|
|
207
346
|
/**
|
|
208
347
|
* An error thrown when ElevenLabs returns a non-2xx response. Preserves the
|
|
209
348
|
* status and response body so callers can decide how to surface it.
|
|
@@ -231,15 +370,17 @@ declare class ElevenLabsClient {
|
|
|
231
370
|
/** Fetch a short-lived signed URL the browser can use to start a session. */
|
|
232
371
|
getSignedUrl(agentId: string): Promise<string>;
|
|
233
372
|
/**
|
|
234
|
-
* One-shot TTS. Returns the raw audio bytes plus the model
|
|
235
|
-
*
|
|
236
|
-
*
|
|
373
|
+
* One-shot TTS. Returns the raw audio bytes plus the model that actually
|
|
374
|
+
* produced them.
|
|
375
|
+
*
|
|
376
|
+
* The requested model is never swapped silently: we only retry on
|
|
377
|
+
* {@link TTS_FALLBACK_MODEL} when the failure is plausibly about
|
|
378
|
+
* the model (400/403/404/422 whose body mentions model/plan/permission,
|
|
379
|
+
* or 402 for an out-of-plan model). Auth (401), rate limit (429), 5xx and
|
|
380
|
+
* network errors are surfaced as-is. When a fallback does happen the
|
|
381
|
+
* result reports `requestedModel`, `fellBack` and `fallbackReason`.
|
|
237
382
|
*/
|
|
238
|
-
textToSpeech(params: TextToSpeechParams): Promise<
|
|
239
|
-
audio: ArrayBuffer;
|
|
240
|
-
modelId: string;
|
|
241
|
-
contentType: string;
|
|
242
|
-
}>;
|
|
383
|
+
textToSpeech(params: TextToSpeechParams): Promise<TextToSpeechResult>;
|
|
243
384
|
/**
|
|
244
385
|
* Low-level escape hatch for any ElevenLabs endpoint not covered by a
|
|
245
386
|
* dedicated method (music, sound-generation, speech-to-text, dubbing,
|
|
@@ -276,6 +417,45 @@ declare class ElevenLabsClient {
|
|
|
276
417
|
audio: ArrayBuffer;
|
|
277
418
|
contentType: string;
|
|
278
419
|
}>;
|
|
420
|
+
/**
|
|
421
|
+
* Convert speech to speech — the "voice changer": keep the performance,
|
|
422
|
+
* swap the voice. `POST /v1/speech-to-speech/{voiceId}` with a multipart
|
|
423
|
+
* audio part. Returns the converted audio bytes.
|
|
424
|
+
*
|
|
425
|
+
* @example
|
|
426
|
+
* ```ts
|
|
427
|
+
* const { audio } = await el.speechToSpeech({
|
|
428
|
+
* voiceId: '21m00Tcm4TlvDq8ikWAM',
|
|
429
|
+
* audio: await fetch(myRecording).then((r) => r.blob()),
|
|
430
|
+
* modelId: 'eleven_multilingual_sts_v2',
|
|
431
|
+
* })
|
|
432
|
+
* ```
|
|
433
|
+
*/
|
|
434
|
+
speechToSpeech(params: SpeechToSpeechParams): Promise<{
|
|
435
|
+
audio: ArrayBuffer;
|
|
436
|
+
contentType: string;
|
|
437
|
+
}>;
|
|
438
|
+
/**
|
|
439
|
+
* Generate a sound effect from a text prompt. `POST /v1/sound-generation`.
|
|
440
|
+
*
|
|
441
|
+
* @example
|
|
442
|
+
* ```ts
|
|
443
|
+
* const { audio } = await el.soundEffects({ text: 'heavy wooden door creaking' })
|
|
444
|
+
* ```
|
|
445
|
+
*/
|
|
446
|
+
soundEffects(params: SoundEffectsParams): Promise<{
|
|
447
|
+
audio: ArrayBuffer;
|
|
448
|
+
contentType: string;
|
|
449
|
+
}>;
|
|
450
|
+
/**
|
|
451
|
+
* Transcribe audio with Scribe. `POST /v1/speech-to-text` (multipart).
|
|
452
|
+
*
|
|
453
|
+
* @example
|
|
454
|
+
* ```ts
|
|
455
|
+
* const { text } = await el.transcribe({ file: recording })
|
|
456
|
+
* ```
|
|
457
|
+
*/
|
|
458
|
+
transcribe(params: TranscribeParams): Promise<TranscriptionResult>;
|
|
279
459
|
/** Probe whether a given voice id still exists on the caller's account. */
|
|
280
460
|
voiceExists(voiceId: string): Promise<boolean>;
|
|
281
461
|
/**
|
|
@@ -420,7 +600,8 @@ interface CreateCompanionBody {
|
|
|
420
600
|
type PatchCompanionBody = Partial<CreateCompanionBody>;
|
|
421
601
|
/** Shape of the JSON body for `POST /voice/tts-preview`. */
|
|
422
602
|
interface TtsPreviewBody {
|
|
423
|
-
|
|
603
|
+
/** ElevenLabs voice id. Optional in proxy mode (the project's voice wins). */
|
|
604
|
+
voiceId?: string;
|
|
424
605
|
text?: string;
|
|
425
606
|
audioTags?: string[];
|
|
426
607
|
modelId?: string;
|
|
@@ -428,4 +609,4 @@ interface TtsPreviewBody {
|
|
|
428
609
|
characterName?: string;
|
|
429
610
|
}
|
|
430
611
|
|
|
431
|
-
export { AUDIO_TAGS as A,
|
|
612
|
+
export { isModelRelatedTtsFailure as $, AUDIO_TAGS as A, type ElevenLabsResponse as B, type CompanionStore as C, DEFAULT_ALLOWED_TAGS as D, ElevenLabsClient as E, type PatchCompanionBody as F, type SpeechToSpeechParams as G, type TextToSpeechParams as H, type TextToSpeechResult as I, type TranscribeParams as J, type TranscriptionResult as K, type TtsPreviewBody as L, MEMORY_CLIENT_TOOLS as M, VOICE_SOUND_GENERATION_MODEL_IDS as N, VOICE_SPEECH_TO_TEXT_MODEL_IDS as O, type PatchAgentParams as P, VOICE_STS_MODEL_IDS as Q, VOICE_TTS_MODELS as R, type SoundEffectsParams as S, TTS_FALLBACK_MODEL as T, VOICE_TTS_MODEL_IDS as U, type VoiceUser as V, type VoiceSettings as W, type VoiceTtsModel as X, buildPreviewLine as Y, composeExpressivityBlock as Z, getVoiceTtsModel as _, type VoiceMemoryStore as a, normalizeAudioTags as a0, normalizeExpressivity as a1, normalizeVoiceSettings as a2, readAudioTags as a3, readExpressivity as a4, readVoiceSettings as a5, resolveConvaiTtsModel as a6, resolveConvaiTtsModelDetailed as a7, stripAudioTags as a8, stripExpressivityBlock as a9, type Expressivity as b, AUDIO_TAG_GROUPS as c, type AudioTag as d, type AudioTagGroup as e, CONVAI_SUPPORTED_TTS_MODELS as f, CONVAI_TTS_MODEL_FALLBACK as g, type Companion as h, type ComposeMusicParams as i, type ConvaiClientTool as j, type ConvaiTtsModelResolution as k, type CreateAgentParams as l, type CreateCompanionBody as m, DEFAULT_ELEVENLABS_BASE_URL as n, DEFAULT_MUSIC_MODEL as o, DEFAULT_SOUND_GENERATION_MODEL as p, DEFAULT_SPEECH_TO_TEXT_MODEL as q, DEFAULT_STS_MODEL as r, DEFAULT_TTS_MODEL as s, DEFAULT_VOICE_SETTINGS as t, EXPRESSIVITY_BLOCK_CLOSE as u, EXPRESSIVITY_BLOCK_OPEN as v, EXPRESSIVITY_OPTIONS as w, ElevenLabsApiError as x, type ElevenLabsClientConfig as y, type ElevenLabsRequestOptions as z };
|
|
@@ -96,11 +96,72 @@ declare function readVoiceSettings(raw: unknown): VoiceSettings;
|
|
|
96
96
|
*/
|
|
97
97
|
|
|
98
98
|
declare const DEFAULT_ELEVENLABS_BASE_URL = "https://api.elevenlabs.io";
|
|
99
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* The one ElevenLabs TTS model table. Everything that needs to know which
|
|
101
|
+
* models exist, which are realtime/convai-capable and how much text each
|
|
102
|
+
* accepts reads from here — `resolveConvaiTtsModel*()` below, the hosted
|
|
103
|
+
* `/api/voice/tts` route, and the docs.
|
|
104
|
+
*
|
|
105
|
+
* `maxChars` is ElevenLabs' per-request character cap for the model;
|
|
106
|
+
* `realtime` marks the subset that a convai agent can run on.
|
|
107
|
+
*/
|
|
108
|
+
interface VoiceTtsModel {
|
|
109
|
+
id: string;
|
|
110
|
+
label: string;
|
|
111
|
+
/** Usable as a convai agent's TTS model (low-latency websocket path). */
|
|
112
|
+
realtime: boolean;
|
|
113
|
+
/** Per-request character cap enforced by ElevenLabs. */
|
|
114
|
+
maxChars: number;
|
|
115
|
+
/** Listed for back-compat; still callable, but not what new agents get. */
|
|
116
|
+
deprecated?: boolean;
|
|
117
|
+
}
|
|
118
|
+
declare const VOICE_TTS_MODELS: readonly VoiceTtsModel[];
|
|
119
|
+
/** Every model id we know about, in table order. */
|
|
120
|
+
declare const VOICE_TTS_MODEL_IDS: readonly string[];
|
|
121
|
+
/** Default model for a plain one-shot `textToSpeech()` call. */
|
|
122
|
+
declare const DEFAULT_TTS_MODEL = "eleven_v4";
|
|
123
|
+
/** TTS models a convai agent can run on. */
|
|
100
124
|
declare const CONVAI_SUPPORTED_TTS_MODELS: Set<string>;
|
|
101
|
-
declare const CONVAI_TTS_MODEL_FALLBACK = "
|
|
125
|
+
declare const CONVAI_TTS_MODEL_FALLBACK = "eleven_v4_turbo";
|
|
126
|
+
/**
|
|
127
|
+
* Last-resort model for a one-shot {@link ElevenLabsClient.textToSpeech} retry.
|
|
128
|
+
*
|
|
129
|
+
* Deliberately *not* {@link CONVAI_TTS_MODEL_FALLBACK}: a BYO account on an
|
|
130
|
+
* older plan can have neither v4 model, and the whole point of the retry is to
|
|
131
|
+
* land on one that is available to everybody. Flash v2.5 is the
|
|
132
|
+
* widest-available and cheapest of the current models.
|
|
133
|
+
*/
|
|
134
|
+
declare const TTS_FALLBACK_MODEL = "eleven_flash_v2_5";
|
|
135
|
+
/** Look up a model's metadata, or `undefined` when the id is unknown. */
|
|
136
|
+
declare function getVoiceTtsModel(modelId: string | null | undefined): VoiceTtsModel | undefined;
|
|
137
|
+
interface ConvaiTtsModelResolution {
|
|
138
|
+
/** The model the agent will actually be configured with. */
|
|
139
|
+
modelId: string;
|
|
140
|
+
/** What the caller asked for (null/undefined when they asked for nothing). */
|
|
141
|
+
requested: string | null;
|
|
142
|
+
/** True when a requested model was replaced by {@link CONVAI_TTS_MODEL_FALLBACK}. */
|
|
143
|
+
downgraded: boolean;
|
|
144
|
+
/** Why the requested model was rejected (absent when nothing was requested). */
|
|
145
|
+
reason?: string;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Resolve a requested convai TTS model, reporting whether we had to
|
|
149
|
+
* substitute it. `eleven_v4`, `eleven_v3` and any unknown id are not
|
|
150
|
+
* convai-capable and resolve to {@link CONVAI_TTS_MODEL_FALLBACK}; every
|
|
151
|
+
* distinct downgrade is logged once so a caller can see it in pod logs
|
|
152
|
+
* instead of silently getting a different voice model.
|
|
153
|
+
*/
|
|
154
|
+
declare function resolveConvaiTtsModelDetailed(requested: string | null | undefined): ConvaiTtsModelResolution;
|
|
102
155
|
/** If `requested` isn't a convai-compatible TTS model, fall back to the default. */
|
|
103
156
|
declare function resolveConvaiTtsModel(requested: string | null | undefined): string;
|
|
157
|
+
/**
|
|
158
|
+
* Whether an ElevenLabs TTS failure is plausibly about the model rather than
|
|
159
|
+
* about the request as a whole: 402 (model not in the plan) always counts,
|
|
160
|
+
* and 400/403/404/422 count only when the body mentions model / plan /
|
|
161
|
+
* permission. 401, 429, 5xx and network errors never do — retrying those on
|
|
162
|
+
* another model only hides the real problem.
|
|
163
|
+
*/
|
|
164
|
+
declare function isModelRelatedTtsFailure(status: number, body: string): boolean;
|
|
104
165
|
interface ElevenLabsClientConfig {
|
|
105
166
|
apiKey: string;
|
|
106
167
|
/** Override for tests or self-hosted proxies. Defaults to the public API. */
|
|
@@ -156,11 +217,25 @@ interface PatchAgentParams {
|
|
|
156
217
|
interface TextToSpeechParams {
|
|
157
218
|
voiceId: string;
|
|
158
219
|
text: string;
|
|
220
|
+
/** Defaults to {@link DEFAULT_TTS_MODEL} (`eleven_v4`). */
|
|
159
221
|
modelId?: string;
|
|
160
222
|
voiceSettings?: VoiceSettings;
|
|
161
223
|
/** Accept header; defaults to `audio/mpeg`. */
|
|
162
224
|
accept?: string;
|
|
163
225
|
}
|
|
226
|
+
/** Result of {@link ElevenLabsClient.textToSpeech}. */
|
|
227
|
+
interface TextToSpeechResult {
|
|
228
|
+
audio: ArrayBuffer;
|
|
229
|
+
/** The model that actually produced the audio. */
|
|
230
|
+
modelId: string;
|
|
231
|
+
/** The model the caller asked for (defaulted when they passed none). */
|
|
232
|
+
requestedModel: string;
|
|
233
|
+
/** True when `modelId !== requestedModel` because of a model-related error. */
|
|
234
|
+
fellBack: boolean;
|
|
235
|
+
/** Why we fell back (upstream status + body snippet). */
|
|
236
|
+
fallbackReason?: string;
|
|
237
|
+
contentType: string;
|
|
238
|
+
}
|
|
164
239
|
/** Options for the low-level {@link ElevenLabsClient.request} escape hatch. */
|
|
165
240
|
interface ElevenLabsRequestOptions {
|
|
166
241
|
/** HTTP method, e.g. `'POST'`. */
|
|
@@ -204,6 +279,70 @@ interface ComposeMusicParams {
|
|
|
204
279
|
outputFormat?: string;
|
|
205
280
|
}
|
|
206
281
|
declare const DEFAULT_MUSIC_MODEL = "music_v1";
|
|
282
|
+
/**
|
|
283
|
+
* ElevenLabs speech-to-speech ("voice changer") models. The multilingual one
|
|
284
|
+
* is the cross-language default; the English one is cheaper and sharper on
|
|
285
|
+
* English input.
|
|
286
|
+
*/
|
|
287
|
+
declare const VOICE_STS_MODEL_IDS: readonly string[];
|
|
288
|
+
declare const DEFAULT_STS_MODEL = "eleven_multilingual_sts_v2";
|
|
289
|
+
/** ElevenLabs Scribe speech-to-text models. */
|
|
290
|
+
declare const VOICE_SPEECH_TO_TEXT_MODEL_IDS: readonly string[];
|
|
291
|
+
declare const DEFAULT_SPEECH_TO_TEXT_MODEL = "scribe_v1";
|
|
292
|
+
/** ElevenLabs text-to-sound-effects models. */
|
|
293
|
+
declare const VOICE_SOUND_GENERATION_MODEL_IDS: readonly string[];
|
|
294
|
+
declare const DEFAULT_SOUND_GENERATION_MODEL = "eleven_text_to_sound_v2";
|
|
295
|
+
/** Parameters for {@link ElevenLabsClient.speechToSpeech} (the voice changer). */
|
|
296
|
+
interface SpeechToSpeechParams {
|
|
297
|
+
/** Target voice. `POST /v1/speech-to-speech/{voiceId}`. */
|
|
298
|
+
voiceId: string;
|
|
299
|
+
/** Source audio to convert. */
|
|
300
|
+
audio: Blob;
|
|
301
|
+
/** Filename sent in the multipart part; defaults to `audio`. */
|
|
302
|
+
fileName?: string;
|
|
303
|
+
/** One of `VOICE_STS_MODEL_IDS`; defaults to `eleven_multilingual_sts_v2`. */
|
|
304
|
+
modelId?: string;
|
|
305
|
+
voiceSettings?: VoiceSettings;
|
|
306
|
+
/** Output container/quality, e.g. `mp3_44100_192`. */
|
|
307
|
+
outputFormat?: string;
|
|
308
|
+
/** `pcm_s16le_16` / `other` (mp3) / `ulaw_8000`. */
|
|
309
|
+
fileFormat?: string;
|
|
310
|
+
seed?: number;
|
|
311
|
+
removeBackgroundNoise?: boolean;
|
|
312
|
+
}
|
|
313
|
+
/** Parameters for {@link ElevenLabsClient.soundEffects}. */
|
|
314
|
+
interface SoundEffectsParams {
|
|
315
|
+
text: string;
|
|
316
|
+
/** 0.5–30 s. */
|
|
317
|
+
durationSeconds?: number;
|
|
318
|
+
/** 0–1; how literally the prompt is followed. */
|
|
319
|
+
promptInfluence?: number;
|
|
320
|
+
loop?: boolean;
|
|
321
|
+
/** Defaults to `eleven_text_to_sound_v2`. */
|
|
322
|
+
modelId?: string;
|
|
323
|
+
outputFormat?: string;
|
|
324
|
+
}
|
|
325
|
+
/** Parameters for {@link ElevenLabsClient.transcribe} (Scribe speech-to-text). */
|
|
326
|
+
interface TranscribeParams {
|
|
327
|
+
file: Blob;
|
|
328
|
+
/** Filename sent in the multipart part; defaults to `audio`. */
|
|
329
|
+
fileName?: string;
|
|
330
|
+
/** Defaults to `scribe_v1`. */
|
|
331
|
+
modelId?: string;
|
|
332
|
+
/** ISO-639-1/3 code; omit to auto-detect. */
|
|
333
|
+
languageCode?: string;
|
|
334
|
+
diarize?: boolean;
|
|
335
|
+
tagAudioEvents?: boolean;
|
|
336
|
+
numSpeakers?: number;
|
|
337
|
+
}
|
|
338
|
+
/** A Scribe transcription. Extra provider fields are passed through as-is. */
|
|
339
|
+
interface TranscriptionResult {
|
|
340
|
+
text: string;
|
|
341
|
+
language_code?: string;
|
|
342
|
+
language_probability?: number;
|
|
343
|
+
words?: unknown[];
|
|
344
|
+
[key: string]: unknown;
|
|
345
|
+
}
|
|
207
346
|
/**
|
|
208
347
|
* An error thrown when ElevenLabs returns a non-2xx response. Preserves the
|
|
209
348
|
* status and response body so callers can decide how to surface it.
|
|
@@ -231,15 +370,17 @@ declare class ElevenLabsClient {
|
|
|
231
370
|
/** Fetch a short-lived signed URL the browser can use to start a session. */
|
|
232
371
|
getSignedUrl(agentId: string): Promise<string>;
|
|
233
372
|
/**
|
|
234
|
-
* One-shot TTS. Returns the raw audio bytes plus the model
|
|
235
|
-
*
|
|
236
|
-
*
|
|
373
|
+
* One-shot TTS. Returns the raw audio bytes plus the model that actually
|
|
374
|
+
* produced them.
|
|
375
|
+
*
|
|
376
|
+
* The requested model is never swapped silently: we only retry on
|
|
377
|
+
* {@link TTS_FALLBACK_MODEL} when the failure is plausibly about
|
|
378
|
+
* the model (400/403/404/422 whose body mentions model/plan/permission,
|
|
379
|
+
* or 402 for an out-of-plan model). Auth (401), rate limit (429), 5xx and
|
|
380
|
+
* network errors are surfaced as-is. When a fallback does happen the
|
|
381
|
+
* result reports `requestedModel`, `fellBack` and `fallbackReason`.
|
|
237
382
|
*/
|
|
238
|
-
textToSpeech(params: TextToSpeechParams): Promise<
|
|
239
|
-
audio: ArrayBuffer;
|
|
240
|
-
modelId: string;
|
|
241
|
-
contentType: string;
|
|
242
|
-
}>;
|
|
383
|
+
textToSpeech(params: TextToSpeechParams): Promise<TextToSpeechResult>;
|
|
243
384
|
/**
|
|
244
385
|
* Low-level escape hatch for any ElevenLabs endpoint not covered by a
|
|
245
386
|
* dedicated method (music, sound-generation, speech-to-text, dubbing,
|
|
@@ -276,6 +417,45 @@ declare class ElevenLabsClient {
|
|
|
276
417
|
audio: ArrayBuffer;
|
|
277
418
|
contentType: string;
|
|
278
419
|
}>;
|
|
420
|
+
/**
|
|
421
|
+
* Convert speech to speech — the "voice changer": keep the performance,
|
|
422
|
+
* swap the voice. `POST /v1/speech-to-speech/{voiceId}` with a multipart
|
|
423
|
+
* audio part. Returns the converted audio bytes.
|
|
424
|
+
*
|
|
425
|
+
* @example
|
|
426
|
+
* ```ts
|
|
427
|
+
* const { audio } = await el.speechToSpeech({
|
|
428
|
+
* voiceId: '21m00Tcm4TlvDq8ikWAM',
|
|
429
|
+
* audio: await fetch(myRecording).then((r) => r.blob()),
|
|
430
|
+
* modelId: 'eleven_multilingual_sts_v2',
|
|
431
|
+
* })
|
|
432
|
+
* ```
|
|
433
|
+
*/
|
|
434
|
+
speechToSpeech(params: SpeechToSpeechParams): Promise<{
|
|
435
|
+
audio: ArrayBuffer;
|
|
436
|
+
contentType: string;
|
|
437
|
+
}>;
|
|
438
|
+
/**
|
|
439
|
+
* Generate a sound effect from a text prompt. `POST /v1/sound-generation`.
|
|
440
|
+
*
|
|
441
|
+
* @example
|
|
442
|
+
* ```ts
|
|
443
|
+
* const { audio } = await el.soundEffects({ text: 'heavy wooden door creaking' })
|
|
444
|
+
* ```
|
|
445
|
+
*/
|
|
446
|
+
soundEffects(params: SoundEffectsParams): Promise<{
|
|
447
|
+
audio: ArrayBuffer;
|
|
448
|
+
contentType: string;
|
|
449
|
+
}>;
|
|
450
|
+
/**
|
|
451
|
+
* Transcribe audio with Scribe. `POST /v1/speech-to-text` (multipart).
|
|
452
|
+
*
|
|
453
|
+
* @example
|
|
454
|
+
* ```ts
|
|
455
|
+
* const { text } = await el.transcribe({ file: recording })
|
|
456
|
+
* ```
|
|
457
|
+
*/
|
|
458
|
+
transcribe(params: TranscribeParams): Promise<TranscriptionResult>;
|
|
279
459
|
/** Probe whether a given voice id still exists on the caller's account. */
|
|
280
460
|
voiceExists(voiceId: string): Promise<boolean>;
|
|
281
461
|
/**
|
|
@@ -420,7 +600,8 @@ interface CreateCompanionBody {
|
|
|
420
600
|
type PatchCompanionBody = Partial<CreateCompanionBody>;
|
|
421
601
|
/** Shape of the JSON body for `POST /voice/tts-preview`. */
|
|
422
602
|
interface TtsPreviewBody {
|
|
423
|
-
|
|
603
|
+
/** ElevenLabs voice id. Optional in proxy mode (the project's voice wins). */
|
|
604
|
+
voiceId?: string;
|
|
424
605
|
text?: string;
|
|
425
606
|
audioTags?: string[];
|
|
426
607
|
modelId?: string;
|
|
@@ -428,4 +609,4 @@ interface TtsPreviewBody {
|
|
|
428
609
|
characterName?: string;
|
|
429
610
|
}
|
|
430
611
|
|
|
431
|
-
export { AUDIO_TAGS as A,
|
|
612
|
+
export { isModelRelatedTtsFailure as $, AUDIO_TAGS as A, type ElevenLabsResponse as B, type CompanionStore as C, DEFAULT_ALLOWED_TAGS as D, ElevenLabsClient as E, type PatchCompanionBody as F, type SpeechToSpeechParams as G, type TextToSpeechParams as H, type TextToSpeechResult as I, type TranscribeParams as J, type TranscriptionResult as K, type TtsPreviewBody as L, MEMORY_CLIENT_TOOLS as M, VOICE_SOUND_GENERATION_MODEL_IDS as N, VOICE_SPEECH_TO_TEXT_MODEL_IDS as O, type PatchAgentParams as P, VOICE_STS_MODEL_IDS as Q, VOICE_TTS_MODELS as R, type SoundEffectsParams as S, TTS_FALLBACK_MODEL as T, VOICE_TTS_MODEL_IDS as U, type VoiceUser as V, type VoiceSettings as W, type VoiceTtsModel as X, buildPreviewLine as Y, composeExpressivityBlock as Z, getVoiceTtsModel as _, type VoiceMemoryStore as a, normalizeAudioTags as a0, normalizeExpressivity as a1, normalizeVoiceSettings as a2, readAudioTags as a3, readExpressivity as a4, readVoiceSettings as a5, resolveConvaiTtsModel as a6, resolveConvaiTtsModelDetailed as a7, stripAudioTags as a8, stripExpressivityBlock as a9, type Expressivity as b, AUDIO_TAG_GROUPS as c, type AudioTag as d, type AudioTagGroup as e, CONVAI_SUPPORTED_TTS_MODELS as f, CONVAI_TTS_MODEL_FALLBACK as g, type Companion as h, type ComposeMusicParams as i, type ConvaiClientTool as j, type ConvaiTtsModelResolution as k, type CreateAgentParams as l, type CreateCompanionBody as m, DEFAULT_ELEVENLABS_BASE_URL as n, DEFAULT_MUSIC_MODEL as o, DEFAULT_SOUND_GENERATION_MODEL as p, DEFAULT_SPEECH_TO_TEXT_MODEL as q, DEFAULT_STS_MODEL as r, DEFAULT_TTS_MODEL as s, DEFAULT_VOICE_SETTINGS as t, EXPRESSIVITY_BLOCK_CLOSE as u, EXPRESSIVITY_BLOCK_OPEN as v, EXPRESSIVITY_OPTIONS as w, ElevenLabsApiError as x, type ElevenLabsClientConfig as y, type ElevenLabsRequestOptions as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shogo-ai/voice",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.4.2",
|
|
4
4
|
"description": "Shogo Voice — ElevenLabs/Twilio voice agent infrastructure with React + React Native UI primitives.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
"import": "./dist/index.js",
|
|
15
15
|
"require": "./dist/index.cjs"
|
|
16
16
|
},
|
|
17
|
+
"./live": {
|
|
18
|
+
"types": "./dist/live/client.d.ts",
|
|
19
|
+
"import": "./dist/live/client.js",
|
|
20
|
+
"require": "./dist/live/client.cjs"
|
|
21
|
+
},
|
|
17
22
|
"./server": {
|
|
18
23
|
"types": "./dist/server.d.ts",
|
|
19
24
|
"import": "./dist/server.js",
|
|
@@ -24,6 +29,16 @@
|
|
|
24
29
|
"import": "./dist/react/index.js",
|
|
25
30
|
"require": "./dist/react/index.cjs"
|
|
26
31
|
},
|
|
32
|
+
"./react/conversation": {
|
|
33
|
+
"types": "./dist/react/conversation.d.ts",
|
|
34
|
+
"import": "./dist/react/conversation.js",
|
|
35
|
+
"require": "./dist/react/conversation.cjs"
|
|
36
|
+
},
|
|
37
|
+
"./react/visuals": {
|
|
38
|
+
"types": "./dist/react/visuals.d.ts",
|
|
39
|
+
"import": "./dist/react/visuals.js",
|
|
40
|
+
"require": "./dist/react/visuals.cjs"
|
|
41
|
+
},
|
|
27
42
|
"./native": {
|
|
28
43
|
"types": "./dist/native/index.d.ts",
|
|
29
44
|
"import": "./dist/native/index.js",
|
|
@@ -58,6 +73,11 @@
|
|
|
58
73
|
"types": "./dist/route/audio-tags.d.ts",
|
|
59
74
|
"import": "./dist/route/audio-tags.js",
|
|
60
75
|
"require": "./dist/route/audio-tags.cjs"
|
|
76
|
+
},
|
|
77
|
+
"./route/op": {
|
|
78
|
+
"types": "./dist/route/op.d.ts",
|
|
79
|
+
"import": "./dist/route/op.js",
|
|
80
|
+
"require": "./dist/route/op.cjs"
|
|
61
81
|
}
|
|
62
82
|
},
|
|
63
83
|
"files": [
|