@juspay/neurolink 9.66.0 → 9.67.0
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/CHANGELOG.md +6 -0
- package/README.md +12 -12
- package/dist/avatar/index.d.ts +13 -0
- package/dist/avatar/index.js +72 -0
- package/dist/browser/neurolink.min.js +357 -357
- package/dist/core/baseProvider.js +49 -8
- package/dist/factories/providerRegistry.js +23 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.js +36 -1
- package/dist/lib/avatar/index.d.ts +13 -0
- package/dist/lib/avatar/index.js +72 -0
- package/dist/lib/core/baseProvider.js +49 -8
- package/dist/lib/factories/providerRegistry.js +23 -0
- package/dist/lib/files/fileTools.d.ts +1 -1
- package/dist/lib/index.d.ts +10 -1
- package/dist/lib/index.js +36 -1
- package/dist/lib/music/index.d.ts +14 -0
- package/dist/lib/music/index.js +80 -0
- package/dist/lib/types/avatar.d.ts +8 -1
- package/dist/lib/types/multimodal.d.ts +20 -7
- package/dist/lib/types/music.d.ts +8 -1
- package/dist/lib/types/tts.d.ts +9 -1
- package/dist/lib/utils/avatarProcessor.d.ts +7 -1
- package/dist/lib/utils/avatarProcessor.js +6 -0
- package/dist/lib/utils/musicProcessor.d.ts +7 -1
- package/dist/lib/utils/musicProcessor.js +6 -0
- package/dist/lib/utils/parameterValidation.js +5 -1
- package/dist/lib/utils/sttProcessor.d.ts +5 -3
- package/dist/lib/utils/sttProcessor.js +4 -2
- package/dist/lib/utils/ttsProcessor.d.ts +6 -3
- package/dist/lib/utils/ttsProcessor.js +5 -2
- package/dist/lib/voice/RealtimeVoiceAPI.d.ts +5 -2
- package/dist/lib/voice/RealtimeVoiceAPI.js +4 -1
- package/dist/lib/voice/index.d.ts +23 -0
- package/dist/lib/voice/index.js +124 -2
- package/dist/lib/voice/providers/CartesiaTTS.d.ts +31 -0
- package/dist/lib/voice/providers/CartesiaTTS.js +189 -0
- package/dist/lib/workflow/config.d.ts +3 -3
- package/dist/music/index.d.ts +14 -0
- package/dist/music/index.js +80 -0
- package/dist/types/avatar.d.ts +8 -1
- package/dist/types/multimodal.d.ts +20 -7
- package/dist/types/music.d.ts +8 -1
- package/dist/types/tts.d.ts +9 -1
- package/dist/utils/avatarProcessor.d.ts +7 -1
- package/dist/utils/avatarProcessor.js +6 -0
- package/dist/utils/musicProcessor.d.ts +7 -1
- package/dist/utils/musicProcessor.js +6 -0
- package/dist/utils/parameterValidation.js +5 -1
- package/dist/utils/sttProcessor.d.ts +5 -3
- package/dist/utils/sttProcessor.js +4 -2
- package/dist/utils/ttsProcessor.d.ts +6 -3
- package/dist/utils/ttsProcessor.js +5 -2
- package/dist/voice/RealtimeVoiceAPI.d.ts +5 -2
- package/dist/voice/RealtimeVoiceAPI.js +4 -1
- package/dist/voice/index.d.ts +23 -0
- package/dist/voice/index.js +124 -2
- package/dist/voice/providers/CartesiaTTS.d.ts +31 -0
- package/dist/voice/providers/CartesiaTTS.js +188 -0
- package/package.json +65 -2
|
@@ -20,6 +20,13 @@ export type AvatarVideoFormat = "mp4" | "webm" | "mov";
|
|
|
20
20
|
* - MuseTalk (Replicate): single quality only; "hd" is no-op
|
|
21
21
|
*/
|
|
22
22
|
export type AvatarQuality = "standard" | "hd";
|
|
23
|
+
/**
|
|
24
|
+
* Known avatar provider identifiers shipped with NeuroLink.
|
|
25
|
+
*
|
|
26
|
+
* `(string & {})` keeps the union open for custom provider names
|
|
27
|
+
* registered via `AvatarProcessor.registerHandler()`.
|
|
28
|
+
*/
|
|
29
|
+
export type AvatarProviderName = "d-id" | "heygen" | "replicate" | "musetalk" | (string & {});
|
|
23
30
|
/**
|
|
24
31
|
* Options for avatar video generation.
|
|
25
32
|
*/
|
|
@@ -42,7 +49,7 @@ export type AvatarOptions = {
|
|
|
42
49
|
/** Voice id passed through to the TTS provider when `text` is used. */
|
|
43
50
|
voice?: string;
|
|
44
51
|
/** Avatar provider override (e.g. "d-id", "heygen", "replicate"). */
|
|
45
|
-
provider?:
|
|
52
|
+
provider?: AvatarProviderName;
|
|
46
53
|
/** Output quality preset. */
|
|
47
54
|
quality?: AvatarQuality;
|
|
48
55
|
/** Output format (default: "mp4"). */
|
|
@@ -124,6 +124,13 @@ export type AudioContent = {
|
|
|
124
124
|
language?: string;
|
|
125
125
|
};
|
|
126
126
|
};
|
|
127
|
+
/**
|
|
128
|
+
* Known video provider identifiers shipped with NeuroLink.
|
|
129
|
+
*
|
|
130
|
+
* `(string & {})` keeps the union open for custom provider names
|
|
131
|
+
* registered via `VideoProcessor.registerHandler()`.
|
|
132
|
+
*/
|
|
133
|
+
export type VideoProviderName = "vertex" | "kling" | "runway" | "replicate" | (string & {});
|
|
127
134
|
/**
|
|
128
135
|
* Video output configuration options for video generation
|
|
129
136
|
*
|
|
@@ -148,14 +155,15 @@ export type VideoOutputOptions = {
|
|
|
148
155
|
*/
|
|
149
156
|
abortSignal?: AbortSignal;
|
|
150
157
|
/**
|
|
151
|
-
* Override the video-gen provider. Defaults to "vertex"
|
|
152
|
-
* provider name if it is also a registered video handler.
|
|
158
|
+
* Override the video-gen provider. Defaults to `"vertex"` when omitted.
|
|
153
159
|
*
|
|
154
160
|
* Registered providers are managed via `VideoProcessor.registerHandler`
|
|
155
|
-
* (see src/lib/utils/videoProcessor.ts). Examples: "vertex"
|
|
156
|
-
* "runway"
|
|
161
|
+
* (see src/lib/utils/videoProcessor.ts). Examples: `"vertex"`, `"kling"`,
|
|
162
|
+
* `"runway"`, `"replicate"`. An unknown provider throws
|
|
163
|
+
* `VIDEO_ERROR_CODES.PROVIDER_NOT_SUPPORTED` — there is no implicit
|
|
164
|
+
* fallback to the LLM provider name.
|
|
157
165
|
*/
|
|
158
|
-
provider?:
|
|
166
|
+
provider?: VideoProviderName;
|
|
159
167
|
/**
|
|
160
168
|
* Specific model to use within the provider. Provider-specific shape
|
|
161
169
|
* (e.g. "veo-3.1-generate-001" for vertex; "atonamy/wan-alpha:..." for
|
|
@@ -164,8 +172,13 @@ export type VideoOutputOptions = {
|
|
|
164
172
|
model?: string;
|
|
165
173
|
/** Output resolution - "720p" (1280x720) or "1080p" (1920x1080) */
|
|
166
174
|
resolution?: "720p" | "1080p";
|
|
167
|
-
/**
|
|
168
|
-
|
|
175
|
+
/**
|
|
176
|
+
* Video duration in seconds. Provider-specific support — Vertex Veo
|
|
177
|
+
* accepts 4 / 6 / 8 s, Kling and Runway accept 5 / 10 s, Replicate is
|
|
178
|
+
* model-specific. The type intentionally enumerates the common shipped
|
|
179
|
+
* values; pass any other positive number for custom Replicate models.
|
|
180
|
+
*/
|
|
181
|
+
length?: 4 | 5 | 6 | 8 | 10 | (number & {});
|
|
169
182
|
/** Aspect ratio - "9:16" for portrait, "16:9" for landscape, "1:1" for square */
|
|
170
183
|
aspectRatio?: "9:16" | "16:9" | "1:1";
|
|
171
184
|
/** Enable audio generation (default: true) */
|
|
@@ -27,6 +27,13 @@ export type MusicGenre = string;
|
|
|
27
27
|
* "mysterious", "romantic", "epic".
|
|
28
28
|
*/
|
|
29
29
|
export type MusicMood = string;
|
|
30
|
+
/**
|
|
31
|
+
* Known music provider identifiers shipped with NeuroLink.
|
|
32
|
+
*
|
|
33
|
+
* `(string & {})` keeps the union open for custom provider names
|
|
34
|
+
* registered via `MusicProcessor.registerHandler()`.
|
|
35
|
+
*/
|
|
36
|
+
export type MusicProviderName = "beatoven" | "elevenlabs-music" | "elevenlabs-sound" | "lyria" | "replicate" | "musicgen" | (string & {});
|
|
30
37
|
/**
|
|
31
38
|
* Options for music generation requests.
|
|
32
39
|
*/
|
|
@@ -44,7 +51,7 @@ export type MusicOptions = {
|
|
|
44
51
|
/** Tempo in BPM (provider-specific support). */
|
|
45
52
|
tempo?: number;
|
|
46
53
|
/** Override the music provider (e.g. "beatoven", "elevenlabs-music", "lyria", "replicate"). */
|
|
47
|
-
provider?:
|
|
54
|
+
provider?: MusicProviderName;
|
|
48
55
|
/** Reference audio for melody / style guidance (Buffer or path). */
|
|
49
56
|
referenceAudio?: Buffer | string;
|
|
50
57
|
/** Output file path (optional — buffer is always returned in result). */
|
package/dist/lib/types/tts.d.ts
CHANGED
|
@@ -17,6 +17,14 @@ export type TTSAudioFormat = "mp3" | "wav" | "ogg" | "opus" | "m4a" | "flac" | "
|
|
|
17
17
|
* TTS quality settings
|
|
18
18
|
*/
|
|
19
19
|
export type TTSQuality = "standard" | "hd";
|
|
20
|
+
/**
|
|
21
|
+
* Known TTS provider identifiers shipped with NeuroLink.
|
|
22
|
+
*
|
|
23
|
+
* The `(string & {})` intersection keeps the union open for custom
|
|
24
|
+
* provider names registered via `TTSProcessor.registerHandler()` while
|
|
25
|
+
* still surfacing the built-in choices in editor autocomplete.
|
|
26
|
+
*/
|
|
27
|
+
export type TTSProviderName = "google-ai" | "vertex" | "openai-tts" | "elevenlabs" | "elevenlabs-tts" | "azure-tts" | "fish-audio" | "cartesia" | (string & {});
|
|
20
28
|
/**
|
|
21
29
|
* TTS configuration options
|
|
22
30
|
*/
|
|
@@ -69,7 +77,7 @@ export type TTSOptions = {
|
|
|
69
77
|
/** Auto-play audio after generation (default: false) */
|
|
70
78
|
play?: boolean;
|
|
71
79
|
/** Override TTS provider (e.g., "elevenlabs", "openai-tts", "azure-tts") */
|
|
72
|
-
provider?:
|
|
80
|
+
provider?: TTSProviderName;
|
|
73
81
|
};
|
|
74
82
|
/**
|
|
75
83
|
* TTS audio result returned from generation
|
|
@@ -56,7 +56,13 @@ export declare class AvatarProcessor {
|
|
|
56
56
|
* List the names of all registered providers.
|
|
57
57
|
*/
|
|
58
58
|
static listProviders(): string[];
|
|
59
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Get a registered avatar handler by provider name.
|
|
61
|
+
*
|
|
62
|
+
* Exposed publicly so module-level auto-registration code can reuse an
|
|
63
|
+
* already-registered primary handler when backfilling its aliases.
|
|
64
|
+
*/
|
|
65
|
+
static getHandler(providerName: string): AvatarHandler | undefined;
|
|
60
66
|
private static buildSpanAttributes;
|
|
61
67
|
/**
|
|
62
68
|
* Generate an avatar video via the registered handler.
|
|
@@ -80,6 +80,12 @@ export class AvatarProcessor {
|
|
|
80
80
|
static listProviders() {
|
|
81
81
|
return Array.from(this.handlers.keys());
|
|
82
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Get a registered avatar handler by provider name.
|
|
85
|
+
*
|
|
86
|
+
* Exposed publicly so module-level auto-registration code can reuse an
|
|
87
|
+
* already-registered primary handler when backfilling its aliases.
|
|
88
|
+
*/
|
|
83
89
|
static getHandler(providerName) {
|
|
84
90
|
return this.handlers.get(providerName.toLowerCase());
|
|
85
91
|
}
|
|
@@ -55,7 +55,13 @@ export declare class MusicProcessor {
|
|
|
55
55
|
* List the names of all registered providers.
|
|
56
56
|
*/
|
|
57
57
|
static listProviders(): string[];
|
|
58
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Get a registered music handler by provider name.
|
|
60
|
+
*
|
|
61
|
+
* Exposed publicly so module-level auto-registration code can reuse an
|
|
62
|
+
* already-registered primary handler when backfilling its aliases.
|
|
63
|
+
*/
|
|
64
|
+
static getHandler(providerName: string): MusicHandler | undefined;
|
|
59
65
|
private static buildSpanAttributes;
|
|
60
66
|
/**
|
|
61
67
|
* Generate a music track via the registered handler.
|
|
@@ -79,6 +79,12 @@ export class MusicProcessor {
|
|
|
79
79
|
static listProviders() {
|
|
80
80
|
return Array.from(this.handlers.keys());
|
|
81
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Get a registered music handler by provider name.
|
|
84
|
+
*
|
|
85
|
+
* Exposed publicly so module-level auto-registration code can reuse an
|
|
86
|
+
* already-registered primary handler when backfilling its aliases.
|
|
87
|
+
*/
|
|
82
88
|
static getHandler(providerName) {
|
|
83
89
|
return this.handlers.get(providerName.toLowerCase());
|
|
84
90
|
}
|
|
@@ -435,7 +435,11 @@ function toValidationError(error) {
|
|
|
435
435
|
* Valid video generation options
|
|
436
436
|
*/
|
|
437
437
|
const VALID_VIDEO_RESOLUTIONS = ["720p", "1080p"];
|
|
438
|
-
|
|
438
|
+
// Cross-provider literal whitelist: Vertex Veo uses 4 / 6 / 8 s, Kling and
|
|
439
|
+
// Runway use 5 / 10 s. The handler-level adapter is the source of truth
|
|
440
|
+
// for per-provider rejection (e.g. Runway 400 for length=4); this gate
|
|
441
|
+
// just rejects obviously invalid integers.
|
|
442
|
+
const VALID_VIDEO_LENGTHS = [4, 5, 6, 8, 10];
|
|
439
443
|
const VALID_VIDEO_ASPECT_RATIOS = ["9:16", "16:9"];
|
|
440
444
|
const MAX_VIDEO_PROMPT_LENGTH = 500;
|
|
441
445
|
const MAX_VIDEO_IMAGE_SIZE = 10 * 1024 * 1024; // 10MB
|
|
@@ -63,13 +63,15 @@ export declare class STTProcessor {
|
|
|
63
63
|
*/
|
|
64
64
|
static registerHandler(providerName: string, handler: STTHandler): void;
|
|
65
65
|
/**
|
|
66
|
-
* Get a registered STT handler by provider name
|
|
66
|
+
* Get a registered STT handler by provider name.
|
|
67
|
+
*
|
|
68
|
+
* Exposed publicly so module-level auto-registration code can reuse an
|
|
69
|
+
* already-registered primary handler when backfilling its aliases.
|
|
67
70
|
*
|
|
68
|
-
* @private
|
|
69
71
|
* @param providerName - Provider identifier
|
|
70
72
|
* @returns Handler instance or undefined if not registered
|
|
71
73
|
*/
|
|
72
|
-
|
|
74
|
+
static getHandler(providerName: string): STTHandler | undefined;
|
|
73
75
|
/**
|
|
74
76
|
* Check if a provider is supported (has a registered STT handler)
|
|
75
77
|
*
|
|
@@ -80,9 +80,11 @@ export class STTProcessor {
|
|
|
80
80
|
logger.debug(`[STTProcessor] Registered STT handler for provider: ${normalizedName}`);
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
|
-
* Get a registered STT handler by provider name
|
|
83
|
+
* Get a registered STT handler by provider name.
|
|
84
|
+
*
|
|
85
|
+
* Exposed publicly so module-level auto-registration code can reuse an
|
|
86
|
+
* already-registered primary handler when backfilling its aliases.
|
|
84
87
|
*
|
|
85
|
-
* @private
|
|
86
88
|
* @param providerName - Provider identifier
|
|
87
89
|
* @returns Handler instance or undefined if not registered
|
|
88
90
|
*/
|
|
@@ -90,13 +90,16 @@ export declare class TTSProcessor {
|
|
|
90
90
|
*/
|
|
91
91
|
static registerHandler(providerName: string, handler: TTSHandler): void;
|
|
92
92
|
/**
|
|
93
|
-
* Get a registered TTS handler by provider name
|
|
93
|
+
* Get a registered TTS handler by provider name.
|
|
94
|
+
*
|
|
95
|
+
* Exposed publicly so module-level auto-registration code can reuse an
|
|
96
|
+
* already-registered primary handler when backfilling its aliases —
|
|
97
|
+
* see `src/lib/voice/index.ts:registerDefaultTTSHandlers`.
|
|
94
98
|
*
|
|
95
|
-
* @private
|
|
96
99
|
* @param providerName - Provider identifier
|
|
97
100
|
* @returns Handler instance or undefined if not registered
|
|
98
101
|
*/
|
|
99
|
-
|
|
102
|
+
static getHandler(providerName: string): TTSHandler | undefined;
|
|
100
103
|
/**
|
|
101
104
|
* Check if a provider is supported (has a registered TTS handler)
|
|
102
105
|
*
|
|
@@ -107,9 +107,12 @@ export class TTSProcessor {
|
|
|
107
107
|
logger.debug(`[TTSProcessor] Registered TTS handler for provider: ${normalizedName}`);
|
|
108
108
|
}
|
|
109
109
|
/**
|
|
110
|
-
* Get a registered TTS handler by provider name
|
|
110
|
+
* Get a registered TTS handler by provider name.
|
|
111
|
+
*
|
|
112
|
+
* Exposed publicly so module-level auto-registration code can reuse an
|
|
113
|
+
* already-registered primary handler when backfilling its aliases —
|
|
114
|
+
* see `src/lib/voice/index.ts:registerDefaultTTSHandlers`.
|
|
111
115
|
*
|
|
112
|
-
* @private
|
|
113
116
|
* @param providerName - Provider identifier
|
|
114
117
|
* @returns Handler instance or undefined if not registered
|
|
115
118
|
*/
|
|
@@ -49,9 +49,12 @@ export declare class RealtimeProcessor {
|
|
|
49
49
|
*/
|
|
50
50
|
static registerHandler(providerName: string, handler: RealtimeHandler): void;
|
|
51
51
|
/**
|
|
52
|
-
* Get a registered Realtime handler by provider name
|
|
52
|
+
* Get a registered Realtime handler by provider name.
|
|
53
|
+
*
|
|
54
|
+
* Exposed publicly so module-level auto-registration code can reuse an
|
|
55
|
+
* already-registered primary handler when backfilling its aliases.
|
|
53
56
|
*/
|
|
54
|
-
|
|
57
|
+
static getHandler(providerName: string): RealtimeHandler | undefined;
|
|
55
58
|
/**
|
|
56
59
|
* Check if a provider is supported
|
|
57
60
|
*/
|
|
@@ -65,7 +65,10 @@ export class RealtimeProcessor {
|
|
|
65
65
|
logger.debug(`[RealtimeProcessor] Registered Realtime handler for provider: ${normalizedName}`);
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
|
-
* Get a registered Realtime handler by provider name
|
|
68
|
+
* Get a registered Realtime handler by provider name.
|
|
69
|
+
*
|
|
70
|
+
* Exposed publicly so module-level auto-registration code can reuse an
|
|
71
|
+
* already-registered primary handler when backfilling its aliases.
|
|
69
72
|
*/
|
|
70
73
|
static getHandler(providerName) {
|
|
71
74
|
const normalizedName = providerName.toLowerCase();
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
* Use STTProcessor (src/lib/utils/sttProcessor.ts) for STT.
|
|
9
9
|
* Use RealtimeProcessor for realtime voice sessions.
|
|
10
10
|
*
|
|
11
|
+
* Importing this module also auto-registers every shipped TTS / STT /
|
|
12
|
+
* Realtime handler whose backing API key is present in `process.env`.
|
|
13
|
+
* Registration is idempotent and silently skipped on failure.
|
|
14
|
+
*
|
|
11
15
|
* @module voice
|
|
12
16
|
*/
|
|
13
17
|
export { AUDIO_FORMAT_DETAILS, DEFAULT_REALTIME_CONFIG, DEFAULT_STT_OPTIONS, isSTTResult, isTranscriptionSegment, isValidRealtimeConfig, isValidSTTOptions, REALTIME_ERROR_CODES, STT_ERROR_CODES, VOICE_ERROR_CODES, } from "../types/index.js";
|
|
@@ -15,8 +19,11 @@ export { RealtimeError, STTError, VoiceError } from "./errors.js";
|
|
|
15
19
|
export { BaseRealtimeHandler, RealtimeProcessor } from "./RealtimeVoiceAPI.js";
|
|
16
20
|
export { AUDIO_SIGNATURES, calculateDuration, convertAudioFormat, createPcmBuffer, createWavFile, createWavHeader, detectAudioFormat, extractPcmSamples, getFileExtension, getMimeType, MIME_TYPES, normalizeAudio, resamplePcm, splitIntoChunks, } from "./audio-utils.js";
|
|
17
21
|
export { asyncIterableToStream, ChunkedAudioStream, StreamHandler, StreamMerger, StreamSplitter, streamToAsyncIterable, } from "./stream-handler.js";
|
|
22
|
+
export { GoogleTTSHandler } from "../adapters/tts/googleTTSHandler.js";
|
|
18
23
|
export { AzureTTS, AzureTTS as AzureTTSHandler } from "./providers/AzureTTS.js";
|
|
24
|
+
export { CartesiaTTS, CartesiaTTS as CartesiaTTSHandler, } from "./providers/CartesiaTTS.js";
|
|
19
25
|
export { ElevenLabsTTS, ElevenLabsTTS as ElevenLabsTTSHandler, } from "./providers/ElevenLabsTTS.js";
|
|
26
|
+
export { FishAudioTTS, FishAudioTTS as FishAudioTTSHandler, } from "./providers/FishAudioTTS.js";
|
|
20
27
|
export { OpenAITTS, OpenAITTS as OpenAITTSHandler, } from "./providers/OpenAITTS.js";
|
|
21
28
|
export { AzureSTT, AzureSTT as AzureSTTHandler } from "./providers/AzureSTT.js";
|
|
22
29
|
export { DeepgramSTT, DeepgramSTT as DeepgramSTTHandler, } from "./providers/DeepgramSTT.js";
|
|
@@ -24,3 +31,19 @@ export { GoogleSTT, GoogleSTT as GoogleSTTHandler, } from "./providers/GoogleSTT
|
|
|
24
31
|
export { OpenAISTT, OpenAISTTHandler, WhisperSTT, WhisperSTTHandler, } from "./providers/OpenAISTT.js";
|
|
25
32
|
export { GeminiLive, GeminiLive as GeminiLiveHandler, } from "./providers/GeminiLive.js";
|
|
26
33
|
export { OpenAIRealtime, OpenAIRealtime as OpenAIRealtimeHandler, } from "./providers/OpenAIRealtime.js";
|
|
34
|
+
/**
|
|
35
|
+
* Register every shipped TTS handler whose backing credentials are
|
|
36
|
+
* present in the environment. Safe to call multiple times.
|
|
37
|
+
*/
|
|
38
|
+
export declare function registerDefaultTTSHandlers(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Register every shipped STT handler whose backing credentials are
|
|
41
|
+
* present in the environment. Safe to call multiple times.
|
|
42
|
+
*/
|
|
43
|
+
export declare function registerDefaultSTTHandlers(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Register every shipped Realtime handler. Realtime handlers don't gate
|
|
46
|
+
* registration on isConfigured() because session-time API keys can be
|
|
47
|
+
* supplied per-call; missing creds surface when `connect()` is invoked.
|
|
48
|
+
*/
|
|
49
|
+
export declare function registerDefaultRealtimeHandlers(): void;
|
package/dist/lib/voice/index.js
CHANGED
|
@@ -8,8 +8,17 @@
|
|
|
8
8
|
* Use STTProcessor (src/lib/utils/sttProcessor.ts) for STT.
|
|
9
9
|
* Use RealtimeProcessor for realtime voice sessions.
|
|
10
10
|
*
|
|
11
|
+
* Importing this module also auto-registers every shipped TTS / STT /
|
|
12
|
+
* Realtime handler whose backing API key is present in `process.env`.
|
|
13
|
+
* Registration is idempotent and silently skipped on failure.
|
|
14
|
+
*
|
|
11
15
|
* @module voice
|
|
12
16
|
*/
|
|
17
|
+
import { logger } from "../utils/logger.js";
|
|
18
|
+
import { STTProcessor } from "../utils/sttProcessor.js";
|
|
19
|
+
import { TTSProcessor } from "../utils/ttsProcessor.js";
|
|
20
|
+
import { GoogleTTSHandler } from "../adapters/tts/googleTTSHandler.js";
|
|
21
|
+
import { RealtimeProcessor } from "./RealtimeVoiceAPI.js";
|
|
13
22
|
// ============================================================================
|
|
14
23
|
// ERROR CODES AND CONSTANTS
|
|
15
24
|
// ============================================================================
|
|
@@ -35,21 +44,134 @@ export { asyncIterableToStream, ChunkedAudioStream, StreamHandler, StreamMerger,
|
|
|
35
44
|
// ============================================================================
|
|
36
45
|
// TTS PROVIDERS
|
|
37
46
|
// ============================================================================
|
|
47
|
+
export { GoogleTTSHandler } from "../adapters/tts/googleTTSHandler.js";
|
|
38
48
|
export { AzureTTS, AzureTTS as AzureTTSHandler } from "./providers/AzureTTS.js";
|
|
49
|
+
export { CartesiaTTS, CartesiaTTS as CartesiaTTSHandler, } from "./providers/CartesiaTTS.js";
|
|
39
50
|
export { ElevenLabsTTS, ElevenLabsTTS as ElevenLabsTTSHandler, } from "./providers/ElevenLabsTTS.js";
|
|
51
|
+
export { FishAudioTTS, FishAudioTTS as FishAudioTTSHandler, } from "./providers/FishAudioTTS.js";
|
|
40
52
|
export { OpenAITTS, OpenAITTS as OpenAITTSHandler, } from "./providers/OpenAITTS.js";
|
|
41
53
|
// ============================================================================
|
|
42
54
|
// STT PROVIDERS
|
|
43
55
|
// ============================================================================
|
|
44
56
|
export { AzureSTT, AzureSTT as AzureSTTHandler } from "./providers/AzureSTT.js";
|
|
45
57
|
export { DeepgramSTT, DeepgramSTT as DeepgramSTTHandler, } from "./providers/DeepgramSTT.js";
|
|
46
|
-
// Export STT provider classes for direct use
|
|
47
58
|
export { GoogleSTT, GoogleSTT as GoogleSTTHandler, } from "./providers/GoogleSTT.js";
|
|
48
59
|
export { OpenAISTT, OpenAISTTHandler, WhisperSTT, WhisperSTTHandler, } from "./providers/OpenAISTT.js";
|
|
49
60
|
// ============================================================================
|
|
50
61
|
// REALTIME PROVIDERS
|
|
51
62
|
// ============================================================================
|
|
52
63
|
export { GeminiLive, GeminiLive as GeminiLiveHandler, } from "./providers/GeminiLive.js";
|
|
53
|
-
// Export Realtime provider classes for direct use
|
|
54
64
|
export { OpenAIRealtime, OpenAIRealtime as OpenAIRealtimeHandler, } from "./providers/OpenAIRealtime.js";
|
|
65
|
+
// ============================================================================
|
|
66
|
+
// AUTO-REGISTRATION
|
|
67
|
+
// ============================================================================
|
|
68
|
+
import { AzureTTS } from "./providers/AzureTTS.js";
|
|
69
|
+
import { CartesiaTTS } from "./providers/CartesiaTTS.js";
|
|
70
|
+
import { ElevenLabsTTS } from "./providers/ElevenLabsTTS.js";
|
|
71
|
+
import { FishAudioTTS } from "./providers/FishAudioTTS.js";
|
|
72
|
+
import { OpenAITTS } from "./providers/OpenAITTS.js";
|
|
73
|
+
import { AzureSTT } from "./providers/AzureSTT.js";
|
|
74
|
+
import { DeepgramSTT } from "./providers/DeepgramSTT.js";
|
|
75
|
+
import { GoogleSTT } from "./providers/GoogleSTT.js";
|
|
76
|
+
import { OpenAISTT } from "./providers/OpenAISTT.js";
|
|
77
|
+
import { GeminiLive } from "./providers/GeminiLive.js";
|
|
78
|
+
import { OpenAIRealtime } from "./providers/OpenAIRealtime.js";
|
|
79
|
+
const TTS_HANDLER_CANDIDATES = [
|
|
80
|
+
{
|
|
81
|
+
// Google TTS doubles as both the AI Studio and Vertex TTS handler.
|
|
82
|
+
name: "google-ai",
|
|
83
|
+
aliases: ["vertex"],
|
|
84
|
+
factory: () => new GoogleTTSHandler(),
|
|
85
|
+
},
|
|
86
|
+
{ name: "openai-tts", factory: () => new OpenAITTS() },
|
|
87
|
+
{
|
|
88
|
+
name: "elevenlabs",
|
|
89
|
+
aliases: ["elevenlabs-tts"],
|
|
90
|
+
factory: () => new ElevenLabsTTS(),
|
|
91
|
+
},
|
|
92
|
+
{ name: "azure-tts", factory: () => new AzureTTS() },
|
|
93
|
+
{ name: "fish-audio", factory: () => new FishAudioTTS() },
|
|
94
|
+
{ name: "cartesia", factory: () => new CartesiaTTS() },
|
|
95
|
+
];
|
|
96
|
+
const STT_HANDLER_CANDIDATES = [
|
|
97
|
+
{
|
|
98
|
+
name: "whisper",
|
|
99
|
+
aliases: ["openai-stt"],
|
|
100
|
+
factory: () => new OpenAISTT(),
|
|
101
|
+
},
|
|
102
|
+
{ name: "deepgram", factory: () => new DeepgramSTT() },
|
|
103
|
+
{ name: "google-stt", factory: () => new GoogleSTT() },
|
|
104
|
+
{ name: "azure-stt", factory: () => new AzureSTT() },
|
|
105
|
+
];
|
|
106
|
+
const REALTIME_HANDLER_CANDIDATES = [
|
|
107
|
+
{ name: "openai-realtime", factory: () => new OpenAIRealtime() },
|
|
108
|
+
{ name: "gemini-live", factory: () => new GeminiLive() },
|
|
109
|
+
];
|
|
110
|
+
function registerCandidates(candidates, supports, getRegistered, register, scope, requireConfigured) {
|
|
111
|
+
for (const { name, aliases, factory } of candidates) {
|
|
112
|
+
// Compute missingName / missingAliases separately so a manually-
|
|
113
|
+
// registered primary name doesn't block alias backfill. Important for
|
|
114
|
+
// BC: existing callers that register e.g. "elevenlabs" should still
|
|
115
|
+
// see "elevenlabs-tts" wired up by this loop.
|
|
116
|
+
const missingName = !supports(name);
|
|
117
|
+
const missingAliases = (aliases ?? []).filter((alias) => !supports(alias));
|
|
118
|
+
if (!missingName && missingAliases.length === 0) {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
try {
|
|
122
|
+
// If the primary is already registered, reuse that exact handler
|
|
123
|
+
// instance for any alias backfill — wiring an alias to a *different*
|
|
124
|
+
// factory-fresh instance would silently diverge from the canonical
|
|
125
|
+
// primary's behavior (different config, different credentials).
|
|
126
|
+
// Only call factory() when we actually need to register the primary.
|
|
127
|
+
let handler;
|
|
128
|
+
if (!missingName) {
|
|
129
|
+
handler = getRegistered(name);
|
|
130
|
+
}
|
|
131
|
+
if (!handler) {
|
|
132
|
+
handler = factory();
|
|
133
|
+
if (requireConfigured && !handler.isConfigured()) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (missingName) {
|
|
138
|
+
register(name, handler);
|
|
139
|
+
}
|
|
140
|
+
for (const alias of missingAliases) {
|
|
141
|
+
register(alias, handler);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
catch (err) {
|
|
145
|
+
logger.debug(`[${scope}] ${name} auto-registration skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Register every shipped TTS handler whose backing credentials are
|
|
151
|
+
* present in the environment. Safe to call multiple times.
|
|
152
|
+
*/
|
|
153
|
+
export function registerDefaultTTSHandlers() {
|
|
154
|
+
registerCandidates(TTS_HANDLER_CANDIDATES, (name) => TTSProcessor.supports(name), (name) => TTSProcessor.getHandler(name), (name, handler) => TTSProcessor.registerHandler(name, handler), "voice/tts", true);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Register every shipped STT handler whose backing credentials are
|
|
158
|
+
* present in the environment. Safe to call multiple times.
|
|
159
|
+
*/
|
|
160
|
+
export function registerDefaultSTTHandlers() {
|
|
161
|
+
registerCandidates(STT_HANDLER_CANDIDATES, (name) => STTProcessor.supports(name), (name) => STTProcessor.getHandler(name), (name, handler) => STTProcessor.registerHandler(name, handler), "voice/stt", true);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Register every shipped Realtime handler. Realtime handlers don't gate
|
|
165
|
+
* registration on isConfigured() because session-time API keys can be
|
|
166
|
+
* supplied per-call; missing creds surface when `connect()` is invoked.
|
|
167
|
+
*/
|
|
168
|
+
export function registerDefaultRealtimeHandlers() {
|
|
169
|
+
registerCandidates(REALTIME_HANDLER_CANDIDATES, (name) => RealtimeProcessor.supports(name), (name) => RealtimeProcessor.getHandler(name), (name, handler) => RealtimeProcessor.registerHandler(name, handler), "voice/realtime", false);
|
|
170
|
+
}
|
|
171
|
+
// Run once at module import so consumers who follow the documented
|
|
172
|
+
// `nl.generate(...)` flow get every configured handler without manually
|
|
173
|
+
// calling `registerHandler`.
|
|
174
|
+
registerDefaultTTSHandlers();
|
|
175
|
+
registerDefaultSTTHandlers();
|
|
176
|
+
registerDefaultRealtimeHandlers();
|
|
55
177
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cartesia TTS Handler (synchronous /tts/bytes endpoint)
|
|
3
|
+
*
|
|
4
|
+
* Implements the standard `TTSHandler` synchronous-request contract on top
|
|
5
|
+
* of Cartesia's REST `/tts/bytes` endpoint. The pre-existing
|
|
6
|
+
* `adapters/tts/cartesiaHandler.ts` (`CartesiaStream`) targets the
|
|
7
|
+
* realtime WebSocket flow used by the voice server and does NOT implement
|
|
8
|
+
* `TTSHandler`; this file fills the gap so `nl.generate({ tts: { provider:
|
|
9
|
+
* "cartesia" } })` works through the same `TTSProcessor` dispatch as
|
|
10
|
+
* every other shipped TTS provider.
|
|
11
|
+
*
|
|
12
|
+
* @module voice/providers/CartesiaTTS
|
|
13
|
+
* @see https://docs.cartesia.ai/api-reference/tts/bytes
|
|
14
|
+
*/
|
|
15
|
+
import type { TTSHandler, TTSOptions, TTSResult } from "../../types/index.js";
|
|
16
|
+
/**
|
|
17
|
+
* Cartesia synchronous TTS handler.
|
|
18
|
+
*
|
|
19
|
+
* Auth: `X-API-Key: ${CARTESIA_API_KEY}` + `Cartesia-Version` header.
|
|
20
|
+
*/
|
|
21
|
+
export declare class CartesiaTTS implements TTSHandler {
|
|
22
|
+
readonly maxTextLength = 5000;
|
|
23
|
+
private readonly apiKey;
|
|
24
|
+
private readonly baseUrl;
|
|
25
|
+
private readonly apiVersion;
|
|
26
|
+
constructor(apiKey?: string);
|
|
27
|
+
isConfigured(): boolean;
|
|
28
|
+
synthesize(text: string, options?: TTSOptions): Promise<TTSResult>;
|
|
29
|
+
private mapOutputFormat;
|
|
30
|
+
private effectiveFormat;
|
|
31
|
+
}
|