getpatter 0.4.3 → 0.5.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/README.md +136 -162
- package/dist/carrier-config-CPG5CROM.mjs +84 -0
- package/dist/{chunk-35EVXMGB.mjs → chunk-757NVN4L.mjs} +396 -458
- package/dist/cli.js +92 -5
- package/dist/index.d.mts +901 -241
- package/dist/index.d.ts +901 -241
- package/dist/index.js +1763 -921
- package/dist/index.mjs +1240 -419
- package/dist/{test-mode-RH65MMSP.mjs → test-mode-YFOL2HYH.mjs} +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,245 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
2
|
import { Request, Response, NextFunction, Express } from 'express';
|
|
3
3
|
|
|
4
|
+
/** Twilio carrier credentials holder for Patter. */
|
|
5
|
+
interface TwilioCarrierOptions {
|
|
6
|
+
/** Twilio Account SID. Falls back to TWILIO_ACCOUNT_SID env var. */
|
|
7
|
+
accountSid?: string;
|
|
8
|
+
/** Twilio Auth Token. Falls back to TWILIO_AUTH_TOKEN env var. */
|
|
9
|
+
authToken?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Twilio telephony carrier — holds Account SID + Auth Token.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import * as twilio from "getpatter/carriers/twilio";
|
|
17
|
+
* const carrier = new twilio.Carrier(); // reads env
|
|
18
|
+
* const carrier = new twilio.Carrier({ accountSid: "AC...", authToken: "..." });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare class Carrier$1 {
|
|
22
|
+
readonly kind: "twilio";
|
|
23
|
+
readonly accountSid: string;
|
|
24
|
+
readonly authToken: string;
|
|
25
|
+
constructor(opts?: TwilioCarrierOptions);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Telnyx carrier credentials holder for Patter. */
|
|
29
|
+
interface TelnyxCarrierOptions {
|
|
30
|
+
/** Telnyx API key. Falls back to TELNYX_API_KEY env var. */
|
|
31
|
+
apiKey?: string;
|
|
32
|
+
/** Telnyx connection ID. Falls back to TELNYX_CONNECTION_ID env var. */
|
|
33
|
+
connectionId?: string;
|
|
34
|
+
/** Optional Ed25519 public key for webhook signature verification. Falls back to TELNYX_PUBLIC_KEY env var. */
|
|
35
|
+
publicKey?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Telnyx telephony carrier — holds API key, connection ID, and optional webhook public key.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* import * as telnyx from "getpatter/carriers/telnyx";
|
|
43
|
+
* const carrier = new telnyx.Carrier(); // reads env
|
|
44
|
+
* const carrier = new telnyx.Carrier({ apiKey: "KEY...", connectionId: "123" });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
declare class Carrier {
|
|
48
|
+
readonly kind: "telnyx";
|
|
49
|
+
readonly apiKey: string;
|
|
50
|
+
readonly connectionId: string;
|
|
51
|
+
readonly publicKey: string | undefined;
|
|
52
|
+
constructor(opts?: TelnyxCarrierOptions);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** OpenAI Realtime engine — marker class for Patter client dispatch. */
|
|
56
|
+
interface RealtimeOptions {
|
|
57
|
+
/** API key. Falls back to OPENAI_API_KEY env var when omitted. */
|
|
58
|
+
apiKey?: string;
|
|
59
|
+
/** Realtime model. Defaults to gpt-4o-mini-realtime-preview. */
|
|
60
|
+
model?: string;
|
|
61
|
+
/** Voice preset. Defaults to alloy. */
|
|
62
|
+
voice?: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* OpenAI Realtime engine marker.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* import * as openai from "getpatter/engines/openai";
|
|
70
|
+
* const engine = new openai.Realtime(); // reads OPENAI_API_KEY
|
|
71
|
+
* const engine = new openai.Realtime({ voice: "alloy" });
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
declare class Realtime {
|
|
75
|
+
readonly kind: "openai_realtime";
|
|
76
|
+
readonly apiKey: string;
|
|
77
|
+
readonly model: string;
|
|
78
|
+
readonly voice: string;
|
|
79
|
+
constructor(opts?: RealtimeOptions);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** ElevenLabs ConvAI engine — marker class for Patter client dispatch. */
|
|
83
|
+
interface ConvAIOptions {
|
|
84
|
+
/** API key. Falls back to ELEVENLABS_API_KEY env var when omitted. */
|
|
85
|
+
apiKey?: string;
|
|
86
|
+
/** ElevenLabs Agent ID. Falls back to ELEVENLABS_AGENT_ID env var when omitted. */
|
|
87
|
+
agentId?: string;
|
|
88
|
+
/** Voice ID to override the agent's default voice. */
|
|
89
|
+
voice?: string;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* ElevenLabs ConvAI engine marker.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* import * as elevenlabs from "getpatter/engines/elevenlabs";
|
|
97
|
+
* const engine = new elevenlabs.ConvAI(); // reads env vars
|
|
98
|
+
* const engine = new elevenlabs.ConvAI({ agentId: "agent_..." });
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
declare class ConvAI {
|
|
102
|
+
readonly kind: "elevenlabs_convai";
|
|
103
|
+
readonly apiKey: string;
|
|
104
|
+
readonly agentId: string;
|
|
105
|
+
readonly voice: string | undefined;
|
|
106
|
+
constructor(opts?: ConvAIOptions);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Tunnel marker classes for Patter. Dispatched by the client to decide how to expose local servers. */
|
|
110
|
+
/**
|
|
111
|
+
* Cloudflare Quick Tunnel marker — ask Patter to start a cloudflared tunnel.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```ts
|
|
115
|
+
* import { CloudflareTunnel } from "getpatter/tunnels";
|
|
116
|
+
* const tunnel = new CloudflareTunnel();
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
declare class CloudflareTunnel {
|
|
120
|
+
readonly kind: "cloudflare";
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Static hostname marker — use a pre-existing public hostname (no tunnel).
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* import { Static } from "getpatter/tunnels";
|
|
128
|
+
* const tunnel = new Static({ hostname: "agent.example.com" });
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
declare class Static {
|
|
132
|
+
readonly kind: "static";
|
|
133
|
+
readonly hostname: string;
|
|
134
|
+
constructor(opts: {
|
|
135
|
+
hostname: string;
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Public API primitives — `Tool` and `Guardrail` classes, plus the
|
|
141
|
+
* `tool()` / `guardrail()` factory functions.
|
|
142
|
+
*
|
|
143
|
+
* These mirror the Python SDK's `patter.Tool` / `patter.Guardrail`. The
|
|
144
|
+
* classes are structurally compatible with the existing `Guardrail`
|
|
145
|
+
* interface and `ToolDefinition` shape used internally, so code that
|
|
146
|
+
* consumed either form keeps working.
|
|
147
|
+
*/
|
|
148
|
+
|
|
149
|
+
interface GuardrailOptions {
|
|
150
|
+
/** Name for logging when triggered. */
|
|
151
|
+
name: string;
|
|
152
|
+
/** List of terms that trigger the guardrail (case-insensitive). */
|
|
153
|
+
blockedTerms?: string[];
|
|
154
|
+
/** Custom check function — return true to block the response. */
|
|
155
|
+
check?: (text: string) => boolean;
|
|
156
|
+
/** Replacement text spoken when guardrail triggers. */
|
|
157
|
+
replacement?: string;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Guardrail definition. Structurally matches the internal `Guardrail`
|
|
161
|
+
* interface so existing code consuming plain objects keeps working.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```ts
|
|
165
|
+
* import { Guardrail } from "getpatter";
|
|
166
|
+
* const rail = new Guardrail({ name: "profanity", blockedTerms: ["badword"] });
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
declare class Guardrail$1 {
|
|
170
|
+
readonly name: string;
|
|
171
|
+
readonly blockedTerms?: string[];
|
|
172
|
+
readonly check?: (text: string) => boolean;
|
|
173
|
+
readonly replacement: string;
|
|
174
|
+
constructor(opts: GuardrailOptions);
|
|
175
|
+
}
|
|
176
|
+
/** Factory helper mirroring Python's `guardrail(...)` function. */
|
|
177
|
+
declare function guardrail(opts: GuardrailOptions): Guardrail$1;
|
|
178
|
+
type ToolHandler = (args: Record<string, unknown>, context: Record<string, unknown>) => Promise<string>;
|
|
179
|
+
interface ToolOptions {
|
|
180
|
+
/** Tool name (visible to the LLM). */
|
|
181
|
+
name: string;
|
|
182
|
+
/** What the tool does (visible to the LLM). */
|
|
183
|
+
description?: string;
|
|
184
|
+
/** JSON Schema for tool arguments. */
|
|
185
|
+
parameters?: Record<string, unknown>;
|
|
186
|
+
/** Async function called in-process when the LLM invokes the tool. */
|
|
187
|
+
handler?: ToolHandler;
|
|
188
|
+
/** URL to POST to when the LLM invokes the tool. */
|
|
189
|
+
webhookUrl?: string;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Tool definition. Structurally matches `ToolDefinition` so it drops
|
|
193
|
+
* directly into `agent({ tools: [...] })`.
|
|
194
|
+
*
|
|
195
|
+
* Exactly one of `handler` or `webhookUrl` must be provided.
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```ts
|
|
199
|
+
* import { Tool } from "getpatter";
|
|
200
|
+
* const t = new Tool({
|
|
201
|
+
* name: "check_menu",
|
|
202
|
+
* description: "Check available menu items",
|
|
203
|
+
* handler: async () => JSON.stringify({ items: ["margherita"] }),
|
|
204
|
+
* });
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
declare class Tool implements ToolDefinition {
|
|
208
|
+
readonly name: string;
|
|
209
|
+
readonly description: string;
|
|
210
|
+
readonly parameters: Record<string, unknown>;
|
|
211
|
+
readonly handler?: ToolHandler;
|
|
212
|
+
readonly webhookUrl?: string;
|
|
213
|
+
constructor(opts: ToolOptions);
|
|
214
|
+
}
|
|
215
|
+
/** Factory helper mirroring Python's `tool(...)` function. */
|
|
216
|
+
declare function tool(opts: ToolOptions): Tool;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Shared STT / TTS adapter dispatch.
|
|
220
|
+
*
|
|
221
|
+
* In v0.5.0+ callers always pass pre-instantiated adapters (``agent.stt`` /
|
|
222
|
+
* ``agent.tts`` are ``STTAdapter`` / ``TTSAdapter`` instances), so these
|
|
223
|
+
* helpers are thin pass-throughs that return the instance or null. Kept as
|
|
224
|
+
* functions so the Twilio/Telnyx bridges have a single dispatch point.
|
|
225
|
+
*/
|
|
226
|
+
|
|
227
|
+
interface STTTranscript {
|
|
228
|
+
text: string;
|
|
229
|
+
isFinal?: boolean;
|
|
230
|
+
}
|
|
231
|
+
type STTTranscriptCallback = (t: STTTranscript) => Promise<void> | void;
|
|
232
|
+
/** Shape shared by every STT adapter in the SDK. */
|
|
233
|
+
interface STTAdapter {
|
|
234
|
+
connect(): Promise<void>;
|
|
235
|
+
sendAudio(pcm: Buffer): void | Promise<void>;
|
|
236
|
+
onTranscript(cb: STTTranscriptCallback): void;
|
|
237
|
+
close(): void | Promise<void>;
|
|
238
|
+
}
|
|
239
|
+
interface TTSAdapter {
|
|
240
|
+
synthesizeStream(text: string): AsyncIterable<Buffer>;
|
|
241
|
+
}
|
|
242
|
+
|
|
4
243
|
interface IncomingMessage {
|
|
5
244
|
readonly text: string;
|
|
6
245
|
readonly callId: string;
|
|
@@ -10,13 +249,21 @@ interface STTConfig {
|
|
|
10
249
|
readonly provider: string;
|
|
11
250
|
readonly apiKey: string;
|
|
12
251
|
readonly language: string;
|
|
13
|
-
|
|
252
|
+
/**
|
|
253
|
+
* Optional — when present, called by internal serialisation. Not required for
|
|
254
|
+
* callers that pass a plain object literal (``{ provider, apiKey, language }``)
|
|
255
|
+
* to maintain parity with the Python SDK, which accepts dataclass-like inputs.
|
|
256
|
+
*/
|
|
257
|
+
toDict?(): Record<string, string | Record<string, unknown>>;
|
|
258
|
+
/** Provider-specific knobs (e.g. Deepgram endpointing). */
|
|
259
|
+
options?: Record<string, unknown>;
|
|
14
260
|
}
|
|
15
261
|
interface TTSConfig {
|
|
16
262
|
readonly provider: string;
|
|
17
263
|
readonly apiKey: string;
|
|
18
264
|
readonly voice: string;
|
|
19
|
-
toDict(): Record<string, string
|
|
265
|
+
toDict?(): Record<string, string | Record<string, unknown>>;
|
|
266
|
+
options?: Record<string, unknown>;
|
|
20
267
|
}
|
|
21
268
|
type MessageHandler = (msg: IncomingMessage) => Promise<string>;
|
|
22
269
|
type CallEventHandler = (data: Record<string, unknown>) => Promise<void>;
|
|
@@ -99,20 +346,35 @@ interface Call {
|
|
|
99
346
|
}> | null;
|
|
100
347
|
}
|
|
101
348
|
interface LocalOptions {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
349
|
+
/**
|
|
350
|
+
* Local mode is auto-detected when a ``carrier`` is passed. Pass
|
|
351
|
+
* ``mode: 'local'`` to force local mode explicitly.
|
|
352
|
+
*/
|
|
353
|
+
mode?: 'local';
|
|
354
|
+
/**
|
|
355
|
+
* Telephony carrier instance. Required for local mode.
|
|
356
|
+
*
|
|
357
|
+
* @example
|
|
358
|
+
* ```ts
|
|
359
|
+
* import { Patter, Twilio } from "getpatter";
|
|
360
|
+
* const phone = new Patter({ carrier: new Twilio(), phoneNumber: "+1..." });
|
|
361
|
+
* ```
|
|
362
|
+
*/
|
|
363
|
+
carrier: Carrier$1 | Carrier;
|
|
364
|
+
/**
|
|
365
|
+
* Tunnel configuration. Accepts a tunnel instance, ``true`` (alias for
|
|
366
|
+
* ``new CloudflareTunnel()``), or ``false`` / omitted (no tunnel).
|
|
367
|
+
*/
|
|
368
|
+
tunnel?: CloudflareTunnel | Static | boolean;
|
|
106
369
|
phoneNumber: string;
|
|
107
370
|
webhookUrl?: string;
|
|
108
|
-
telephonyProvider?: 'twilio' | 'telnyx';
|
|
109
|
-
telnyxKey?: string;
|
|
110
|
-
telnyxConnectionId?: string;
|
|
111
371
|
/**
|
|
112
|
-
*
|
|
113
|
-
*
|
|
372
|
+
* @internal — allows ``StreamHandler`` to build the default OpenAI
|
|
373
|
+
* ``LLMLoop`` when no ``onMessage`` handler is supplied. The
|
|
374
|
+
* ``OpenAIRealtime`` engine instance carries its own key when one is
|
|
375
|
+
* used via ``phone.agent({ engine: new OpenAIRealtime({ apiKey }) })``.
|
|
114
376
|
*/
|
|
115
|
-
|
|
377
|
+
openaiKey?: string;
|
|
116
378
|
}
|
|
117
379
|
interface Guardrail {
|
|
118
380
|
/** Name for logging when triggered */
|
|
@@ -168,23 +430,40 @@ interface BackgroundAudioPlayer$1 {
|
|
|
168
430
|
}
|
|
169
431
|
interface AgentOptions {
|
|
170
432
|
systemPrompt: string;
|
|
433
|
+
/**
|
|
434
|
+
* Voice preset. When ``engine`` is provided, its ``voice`` is used unless
|
|
435
|
+
* explicitly overridden here.
|
|
436
|
+
*/
|
|
171
437
|
voice?: string;
|
|
438
|
+
/**
|
|
439
|
+
* LLM / Realtime model. When ``engine`` is provided, its ``model`` is used
|
|
440
|
+
* unless explicitly overridden here.
|
|
441
|
+
*/
|
|
172
442
|
model?: string;
|
|
173
443
|
language?: string;
|
|
174
444
|
firstMessage?: string;
|
|
175
|
-
|
|
445
|
+
/** Tool definitions — ``Tool`` class instances from ``getpatter``. */
|
|
446
|
+
tools?: Array<Tool>;
|
|
447
|
+
/**
|
|
448
|
+
* Realtime / ConvAI engine instance. When present, the agent runs in the
|
|
449
|
+
* matching mode (``openai_realtime`` or ``elevenlabs_convai``). When absent,
|
|
450
|
+
* pipeline mode is selected if ``stt`` and ``tts`` are provided.
|
|
451
|
+
*/
|
|
452
|
+
engine?: Realtime | ConvAI;
|
|
453
|
+
/**
|
|
454
|
+
* Provider mode. Normally derived from ``engine`` / ``stt`` + ``tts``. Pass
|
|
455
|
+
* ``'pipeline'`` explicitly when building a pipeline-mode agent without
|
|
456
|
+
* an engine instance.
|
|
457
|
+
*/
|
|
176
458
|
provider?: 'openai_realtime' | 'elevenlabs_convai' | 'pipeline';
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
stt?: STTConfig;
|
|
182
|
-
/** TTS provider config for pipeline mode. Use ``Patter.elevenlabs()`` or ``Patter.openaiTts()``. */
|
|
183
|
-
tts?: TTSConfig;
|
|
459
|
+
/** Pre-instantiated STT adapter (e.g. ``new DeepgramSTT({ apiKey })``). */
|
|
460
|
+
stt?: STTAdapter;
|
|
461
|
+
/** Pre-instantiated TTS adapter (e.g. ``new ElevenLabsTTS({ apiKey })``). */
|
|
462
|
+
tts?: TTSAdapter;
|
|
184
463
|
/** Dynamic variables for ``{placeholder}`` substitution in systemPrompt at call time. */
|
|
185
464
|
variables?: Record<string, string>;
|
|
186
|
-
/** Output guardrails —
|
|
187
|
-
guardrails?: Guardrail
|
|
465
|
+
/** Output guardrails — ``Guardrail`` class instances from ``getpatter``. */
|
|
466
|
+
guardrails?: Array<Guardrail>;
|
|
188
467
|
/** Pipeline hooks — intercept and transform data at each pipeline stage (pipeline mode only). */
|
|
189
468
|
hooks?: PipelineHooks;
|
|
190
469
|
/** Text transforms applied to LLM output before TTS (pipeline mode only).
|
|
@@ -197,6 +476,13 @@ interface AgentOptions {
|
|
|
197
476
|
audioFilter?: AudioFilter;
|
|
198
477
|
/** Optional background audio mixer (hold music, thinking cues). Pipeline mode only. */
|
|
199
478
|
backgroundAudio?: BackgroundAudioPlayer$1;
|
|
479
|
+
/**
|
|
480
|
+
* Minimum sustained voice (ms) before treating caller audio as a barge-in
|
|
481
|
+
* and interrupting TTS. `0` disables barge-in entirely — useful on noisy
|
|
482
|
+
* links (ngrok tunnels, speakerphone) where the agent can hear itself.
|
|
483
|
+
* Default: 300.
|
|
484
|
+
*/
|
|
485
|
+
bargeInThresholdMs?: number;
|
|
200
486
|
}
|
|
201
487
|
type PipelineMessageHandler = (data: Record<string, unknown>) => Promise<string>;
|
|
202
488
|
interface ServeOptions {
|
|
@@ -235,32 +521,22 @@ interface LocalCallOptions {
|
|
|
235
521
|
voicemailMessage?: string;
|
|
236
522
|
/** Dynamic variables merged into agent.variables before call. Override agent-level variables. */
|
|
237
523
|
variables?: Record<string, string>;
|
|
524
|
+
/**
|
|
525
|
+
* Ring timeout in seconds. Forwarded to Twilio as `Timeout` and to Telnyx
|
|
526
|
+
* as `timeout_secs`. Defaults to the carrier default (~28 s on Twilio) when
|
|
527
|
+
* omitted. Increase for international routes where the remote carrier
|
|
528
|
+
* silences short US→IT rings.
|
|
529
|
+
*/
|
|
530
|
+
ringTimeout?: number;
|
|
238
531
|
}
|
|
239
532
|
|
|
240
|
-
declare function deepgram(opts: {
|
|
241
|
-
apiKey: string;
|
|
242
|
-
language?: string;
|
|
243
|
-
}): STTConfig;
|
|
244
|
-
declare function whisper(opts: {
|
|
245
|
-
apiKey: string;
|
|
246
|
-
language?: string;
|
|
247
|
-
}): STTConfig;
|
|
248
|
-
declare function elevenlabs(opts: {
|
|
249
|
-
apiKey: string;
|
|
250
|
-
voice?: string;
|
|
251
|
-
}): TTSConfig;
|
|
252
|
-
declare function openaiTts(opts: {
|
|
253
|
-
apiKey: string;
|
|
254
|
-
voice?: string;
|
|
255
|
-
}): TTSConfig;
|
|
256
|
-
|
|
257
533
|
declare class Patter {
|
|
258
534
|
readonly apiKey: string;
|
|
259
535
|
private readonly backendUrl;
|
|
260
536
|
private readonly restUrl;
|
|
261
537
|
private readonly connection;
|
|
262
538
|
private readonly mode;
|
|
263
|
-
private
|
|
539
|
+
private localConfig;
|
|
264
540
|
private embeddedServer;
|
|
265
541
|
private tunnelHandle;
|
|
266
542
|
constructor(options: PatterOptions | LocalOptions);
|
|
@@ -278,48 +554,6 @@ declare class Patter {
|
|
|
278
554
|
}): Promise<PhoneNumber>;
|
|
279
555
|
assignAgent(numberId: string, agentId: string): Promise<void>;
|
|
280
556
|
listCalls(limit?: number): Promise<Call[]>;
|
|
281
|
-
static deepgram: typeof deepgram;
|
|
282
|
-
static whisper: typeof whisper;
|
|
283
|
-
static elevenlabs: typeof elevenlabs;
|
|
284
|
-
static openaiTts: typeof openaiTts;
|
|
285
|
-
static guardrail(opts: {
|
|
286
|
-
name: string;
|
|
287
|
-
blockedTerms?: string[];
|
|
288
|
-
check?: (text: string) => boolean;
|
|
289
|
-
replacement?: string;
|
|
290
|
-
}): Guardrail;
|
|
291
|
-
/**
|
|
292
|
-
* Create a tool definition for use with `agent({ tools: [...] })`.
|
|
293
|
-
*
|
|
294
|
-
* Either `handler` (a function) or `webhookUrl` must be provided.
|
|
295
|
-
*
|
|
296
|
-
* @param opts.name - Tool name (visible to the LLM).
|
|
297
|
-
* @param opts.description - What the tool does (visible to the LLM).
|
|
298
|
-
* @param opts.parameters - JSON Schema for tool arguments.
|
|
299
|
-
* @param opts.handler - Async function called in-process when the LLM invokes the tool.
|
|
300
|
-
* @param opts.webhookUrl - URL to POST to when the LLM invokes the tool.
|
|
301
|
-
*
|
|
302
|
-
* @example
|
|
303
|
-
* ```ts
|
|
304
|
-
* phone.agent({
|
|
305
|
-
* systemPrompt: 'You are a pizza bot.',
|
|
306
|
-
* tools: [
|
|
307
|
-
* Patter.tool({
|
|
308
|
-
* name: 'check_menu',
|
|
309
|
-
* description: 'Check available menu items',
|
|
310
|
-
* handler: async (args) => JSON.stringify({ items: ['margherita'] }),
|
|
311
|
-
* }),
|
|
312
|
-
* ],
|
|
313
|
-
* });
|
|
314
|
-
* ```
|
|
315
|
-
*/
|
|
316
|
-
static tool(opts: {
|
|
317
|
-
name: string;
|
|
318
|
-
description?: string;
|
|
319
|
-
parameters?: Record<string, unknown>;
|
|
320
|
-
handler?: (args: Record<string, unknown>, context: Record<string, unknown>) => Promise<string>;
|
|
321
|
-
webhookUrl?: string;
|
|
322
|
-
}): ToolDefinition;
|
|
323
557
|
private registerNumber;
|
|
324
558
|
}
|
|
325
559
|
|
|
@@ -492,6 +726,34 @@ declare class ProvisionError extends PatterError {
|
|
|
492
726
|
constructor(message: string);
|
|
493
727
|
}
|
|
494
728
|
|
|
729
|
+
/**
|
|
730
|
+
* Deepgram STT config builder. Tune latency via ``endpointingMs`` /
|
|
731
|
+
* ``utteranceEndMs``. Internal only — public code should use ``DeepgramSTT``
|
|
732
|
+
* from ``getpatter/stt/deepgram``.
|
|
733
|
+
*/
|
|
734
|
+
declare function deepgram(opts: {
|
|
735
|
+
apiKey: string;
|
|
736
|
+
language?: string;
|
|
737
|
+
model?: string;
|
|
738
|
+
endpointingMs?: number;
|
|
739
|
+
utteranceEndMs?: number | null;
|
|
740
|
+
smartFormat?: boolean;
|
|
741
|
+
interimResults?: boolean;
|
|
742
|
+
vadEvents?: boolean;
|
|
743
|
+
}): STTConfig;
|
|
744
|
+
declare function whisper(opts: {
|
|
745
|
+
apiKey: string;
|
|
746
|
+
language?: string;
|
|
747
|
+
}): STTConfig;
|
|
748
|
+
declare function elevenlabs(opts: {
|
|
749
|
+
apiKey: string;
|
|
750
|
+
voice?: string;
|
|
751
|
+
}): TTSConfig;
|
|
752
|
+
declare function openaiTts(opts: {
|
|
753
|
+
apiKey: string;
|
|
754
|
+
voice?: string;
|
|
755
|
+
}): TTSConfig;
|
|
756
|
+
|
|
495
757
|
/**
|
|
496
758
|
* Default provider pricing and merge utilities.
|
|
497
759
|
*
|
|
@@ -693,79 +955,92 @@ declare class ElevenLabsConvAIAdapter {
|
|
|
693
955
|
close(): void;
|
|
694
956
|
}
|
|
695
957
|
|
|
696
|
-
interface Transcript$4 {
|
|
697
|
-
readonly text: string;
|
|
698
|
-
readonly isFinal: boolean;
|
|
699
|
-
readonly confidence: number;
|
|
700
|
-
}
|
|
701
|
-
type TranscriptCallback$4 = (transcript: Transcript$4) => void;
|
|
702
|
-
declare class DeepgramSTT {
|
|
703
|
-
private readonly apiKey;
|
|
704
|
-
private readonly language;
|
|
705
|
-
private readonly model;
|
|
706
|
-
private readonly encoding;
|
|
707
|
-
private readonly sampleRate;
|
|
708
|
-
private ws;
|
|
709
|
-
private callbacks;
|
|
710
|
-
/** Request ID from Deepgram — used to query actual cost post-call. */
|
|
711
|
-
requestId: string;
|
|
712
|
-
constructor(apiKey: string, language?: string, model?: string, encoding?: string, sampleRate?: number);
|
|
713
|
-
/** Factory for Twilio calls — mulaw 8 kHz. */
|
|
714
|
-
static forTwilio(apiKey: string, language?: string, model?: string): DeepgramSTT;
|
|
715
|
-
connect(): Promise<void>;
|
|
716
|
-
sendAudio(audio: Buffer): void;
|
|
717
|
-
onTranscript(callback: TranscriptCallback$4): void;
|
|
718
|
-
close(): void;
|
|
719
|
-
}
|
|
720
|
-
|
|
721
958
|
/**
|
|
722
|
-
*
|
|
959
|
+
* In-memory metrics store for the local dashboard.
|
|
723
960
|
*
|
|
724
|
-
*
|
|
725
|
-
*
|
|
961
|
+
* Keeps the last `maxCalls` completed calls and tracks active calls.
|
|
962
|
+
* Supports SSE event subscribers for real-time updates.
|
|
726
963
|
*/
|
|
727
|
-
interface Transcript$3 {
|
|
728
|
-
readonly text: string;
|
|
729
|
-
readonly isFinal: boolean;
|
|
730
|
-
readonly confidence: number;
|
|
731
|
-
}
|
|
732
|
-
type TranscriptCallback$3 = (transcript: Transcript$3) => void;
|
|
733
|
-
declare class WhisperSTT {
|
|
734
|
-
private readonly apiKey;
|
|
735
|
-
private readonly model;
|
|
736
|
-
private readonly language;
|
|
737
|
-
private readonly bufferSize;
|
|
738
|
-
private buffer;
|
|
739
|
-
private callbacks;
|
|
740
|
-
private running;
|
|
741
|
-
private pendingTranscriptions;
|
|
742
|
-
constructor(apiKey: string, model?: string, language?: string, bufferSize?: number);
|
|
743
|
-
/** Factory for Twilio calls — mulaw 8 kHz is transcoded upstream, so we still receive PCM 16-bit. */
|
|
744
|
-
static forTwilio(apiKey: string, language?: string, model?: string): WhisperSTT;
|
|
745
|
-
connect(): Promise<void>;
|
|
746
|
-
sendAudio(audio: Buffer): void;
|
|
747
|
-
private trackTranscription;
|
|
748
|
-
onTranscript(callback: TranscriptCallback$3): void;
|
|
749
|
-
close(): Promise<void>;
|
|
750
|
-
private transcribeBuffer;
|
|
751
|
-
}
|
|
752
964
|
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
declare class RemoteMessageHandler {
|
|
761
|
-
private readonly webhookSecret;
|
|
965
|
+
interface CallRecord {
|
|
966
|
+
call_id: string;
|
|
967
|
+
caller: string;
|
|
968
|
+
callee: string;
|
|
969
|
+
direction: string;
|
|
970
|
+
started_at: number;
|
|
971
|
+
ended_at?: number;
|
|
762
972
|
/**
|
|
763
|
-
*
|
|
764
|
-
*
|
|
765
|
-
*
|
|
973
|
+
* Current lifecycle state: ``initiated`` (pre-registered), ``ringing``,
|
|
974
|
+
* ``in-progress``, ``completed``, ``no-answer``, ``busy``, ``failed``,
|
|
975
|
+
* ``canceled``, or ``webhook_error``.
|
|
766
976
|
*/
|
|
767
|
-
|
|
768
|
-
|
|
977
|
+
status?: string;
|
|
978
|
+
transcript?: Array<{
|
|
979
|
+
role: string;
|
|
980
|
+
text: string;
|
|
981
|
+
timestamp: number;
|
|
982
|
+
}>;
|
|
983
|
+
turns?: unknown[];
|
|
984
|
+
metrics?: Record<string, unknown> | null;
|
|
985
|
+
[key: string]: unknown;
|
|
986
|
+
}
|
|
987
|
+
interface SSEEvent {
|
|
988
|
+
type: string;
|
|
989
|
+
data: Record<string, unknown>;
|
|
990
|
+
}
|
|
991
|
+
declare class MetricsStore extends EventEmitter {
|
|
992
|
+
private readonly maxCalls;
|
|
993
|
+
private calls;
|
|
994
|
+
private activeCalls;
|
|
995
|
+
/**
|
|
996
|
+
* Accepts either a numeric ``maxCalls`` (legacy positional — matches the
|
|
997
|
+
* original TS API) or an options object ``{ maxCalls }`` to align with the
|
|
998
|
+
* Python SDK's keyword-argument style. Plain literals also work:
|
|
999
|
+
* ``new MetricsStore()`` / ``new MetricsStore(100)`` / ``new MetricsStore({ maxCalls: 100 })``.
|
|
1000
|
+
*/
|
|
1001
|
+
constructor(maxCallsOrOpts?: number | {
|
|
1002
|
+
maxCalls?: number;
|
|
1003
|
+
});
|
|
1004
|
+
private publish;
|
|
1005
|
+
recordCallStart(data: Record<string, unknown>): void;
|
|
1006
|
+
/**
|
|
1007
|
+
* Pre-register an outbound call before any webhook fires. Lets the
|
|
1008
|
+
* dashboard surface attempts that never reach media (no-answer, busy,
|
|
1009
|
+
* carrier-rejected). Mirrors the Python ``record_call_initiated``.
|
|
1010
|
+
*/
|
|
1011
|
+
recordCallInitiated(data: Record<string, unknown>): void;
|
|
1012
|
+
/**
|
|
1013
|
+
* Update the status of an active or completed call. Terminal states
|
|
1014
|
+
* (completed, no-answer, busy, failed, canceled, webhook_error) move the
|
|
1015
|
+
* row from active to completed so the UI freezes the live duration timer.
|
|
1016
|
+
*/
|
|
1017
|
+
updateCallStatus(callId: string, status: string, extra?: Record<string, unknown>): void;
|
|
1018
|
+
recordTurn(data: Record<string, unknown>): void;
|
|
1019
|
+
recordCallEnd(data: Record<string, unknown>, metrics?: Record<string, unknown> | null): void;
|
|
1020
|
+
getCalls(limit?: number, offset?: number): CallRecord[];
|
|
1021
|
+
getCall(callId: string): CallRecord | null;
|
|
1022
|
+
getActiveCalls(): CallRecord[];
|
|
1023
|
+
getAggregates(): Record<string, unknown>;
|
|
1024
|
+
getCallsInRange(fromTs?: number, toTs?: number): CallRecord[];
|
|
1025
|
+
get callCount(): number;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
/**
|
|
1029
|
+
* Remote message handler for B2B webhook and WebSocket integration.
|
|
1030
|
+
*
|
|
1031
|
+
* Allows onMessage to be a URL string instead of a callable:
|
|
1032
|
+
* - HTTP webhook: onMessage="https://api.customer.com/patter/message"
|
|
1033
|
+
* - WebSocket: onMessage="ws://localhost:9000/stream"
|
|
1034
|
+
*/
|
|
1035
|
+
declare class RemoteMessageHandler {
|
|
1036
|
+
private readonly webhookSecret;
|
|
1037
|
+
/**
|
|
1038
|
+
* @param webhookSecret Optional HMAC secret. When provided, outgoing webhook
|
|
1039
|
+
* requests include an `X-Patter-Signature` header so the receiver can
|
|
1040
|
+
* verify the payload originated from Patter.
|
|
1041
|
+
*/
|
|
1042
|
+
constructor(webhookSecret?: string);
|
|
1043
|
+
/**
|
|
769
1044
|
* Compute HMAC-SHA256 hex digest for the given body.
|
|
770
1045
|
*/
|
|
771
1046
|
private signPayload;
|
|
@@ -800,50 +1075,6 @@ declare function isRemoteUrl(onMessage: unknown): onMessage is string;
|
|
|
800
1075
|
/** Check if a URL is a WebSocket URL. */
|
|
801
1076
|
declare function isWebSocketUrl(url: string): boolean;
|
|
802
1077
|
|
|
803
|
-
/**
|
|
804
|
-
* In-memory metrics store for the local dashboard.
|
|
805
|
-
*
|
|
806
|
-
* Keeps the last `maxCalls` completed calls and tracks active calls.
|
|
807
|
-
* Supports SSE event subscribers for real-time updates.
|
|
808
|
-
*/
|
|
809
|
-
|
|
810
|
-
interface CallRecord {
|
|
811
|
-
call_id: string;
|
|
812
|
-
caller: string;
|
|
813
|
-
callee: string;
|
|
814
|
-
direction: string;
|
|
815
|
-
started_at: number;
|
|
816
|
-
ended_at?: number;
|
|
817
|
-
transcript?: Array<{
|
|
818
|
-
role: string;
|
|
819
|
-
text: string;
|
|
820
|
-
timestamp: number;
|
|
821
|
-
}>;
|
|
822
|
-
turns?: unknown[];
|
|
823
|
-
metrics?: Record<string, unknown> | null;
|
|
824
|
-
[key: string]: unknown;
|
|
825
|
-
}
|
|
826
|
-
interface SSEEvent {
|
|
827
|
-
type: string;
|
|
828
|
-
data: Record<string, unknown>;
|
|
829
|
-
}
|
|
830
|
-
declare class MetricsStore extends EventEmitter {
|
|
831
|
-
private readonly maxCalls;
|
|
832
|
-
private calls;
|
|
833
|
-
private activeCalls;
|
|
834
|
-
constructor(maxCalls?: number);
|
|
835
|
-
private publish;
|
|
836
|
-
recordCallStart(data: Record<string, unknown>): void;
|
|
837
|
-
recordTurn(data: Record<string, unknown>): void;
|
|
838
|
-
recordCallEnd(data: Record<string, unknown>, metrics?: Record<string, unknown> | null): void;
|
|
839
|
-
getCalls(limit?: number, offset?: number): CallRecord[];
|
|
840
|
-
getCall(callId: string): CallRecord | null;
|
|
841
|
-
getActiveCalls(): CallRecord[];
|
|
842
|
-
getAggregates(): Record<string, unknown>;
|
|
843
|
-
getCallsInRange(fromTs?: number, toTs?: number): CallRecord[];
|
|
844
|
-
get callCount(): number;
|
|
845
|
-
}
|
|
846
|
-
|
|
847
1078
|
interface LocalConfig {
|
|
848
1079
|
twilioSid?: string;
|
|
849
1080
|
twilioToken?: string;
|
|
@@ -1009,6 +1240,27 @@ declare class FallbackLLMProvider implements LLMProvider {
|
|
|
1009
1240
|
getAvailability(): ReadonlyArray<boolean>;
|
|
1010
1241
|
/** Clears all background recovery timers. Call this when shutting down. */
|
|
1011
1242
|
destroy(): void;
|
|
1243
|
+
/**
|
|
1244
|
+
* Async-friendly disposer. Parity with Python's ``FallbackLLMProvider.aclose()``
|
|
1245
|
+
* — safe to call multiple times, returns a resolved Promise once all probe
|
|
1246
|
+
* timers are cleared. Prefer this in async contexts so awaiting the
|
|
1247
|
+
* shutdown integrates naturally with the owning lifecycle.
|
|
1248
|
+
*/
|
|
1249
|
+
aclose(): Promise<void>;
|
|
1250
|
+
/**
|
|
1251
|
+
* Explicit-resource-management hook so callers can write
|
|
1252
|
+
* ``await using fallback = new FallbackLLMProvider([...])`` and have
|
|
1253
|
+
* background probe timers cleared automatically when the block exits.
|
|
1254
|
+
* Mirrors Python's ``async with FallbackLLMProvider(...)``.
|
|
1255
|
+
*/
|
|
1256
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
1257
|
+
/**
|
|
1258
|
+
* Stream only the text deltas, flattening the chunk envelope. Parity with
|
|
1259
|
+
* Python's ``FallbackLLMProvider.complete_stream``. Tool-call and done
|
|
1260
|
+
* markers are filtered out so callers can concatenate the yielded strings
|
|
1261
|
+
* directly.
|
|
1262
|
+
*/
|
|
1263
|
+
completeStream(messages: Array<Record<string, unknown>>, tools?: Array<Record<string, unknown>> | null): AsyncGenerator<string, void, unknown>;
|
|
1012
1264
|
stream(messages: Array<Record<string, unknown>>, tools?: Array<Record<string, unknown>> | null): AsyncGenerator<LLMChunk, void, unknown>;
|
|
1013
1265
|
private tryProviders;
|
|
1014
1266
|
private markUnavailable;
|
|
@@ -1159,12 +1411,33 @@ interface ScheduleHandle {
|
|
|
1159
1411
|
cancel(): void;
|
|
1160
1412
|
readonly pending: boolean;
|
|
1161
1413
|
}
|
|
1162
|
-
/** Schedule ``callback`` on a cron expression (node-cron dialect).
|
|
1163
|
-
|
|
1414
|
+
/** Schedule ``callback`` on a cron expression (node-cron dialect).
|
|
1415
|
+
*
|
|
1416
|
+
* Returns a ``ScheduleHandle`` synchronously (parity with Python
|
|
1417
|
+
* ``schedule_cron``). The handle is "pending" until the lazy ``node-cron``
|
|
1418
|
+
* import resolves; cancelling the handle before then discards the pending
|
|
1419
|
+
* job cleanly. If ``node-cron`` is not installed, the returned promise
|
|
1420
|
+
* attached to ``.ready`` rejects with a helpful install message.
|
|
1421
|
+
*/
|
|
1422
|
+
declare function scheduleCron(cron: string, callback: JobCallback): ScheduleHandle;
|
|
1164
1423
|
/** Schedule ``callback`` once at the given date. */
|
|
1165
1424
|
declare function scheduleOnce(at: Date, callback: JobCallback): ScheduleHandle;
|
|
1166
|
-
/**
|
|
1167
|
-
|
|
1425
|
+
/**
|
|
1426
|
+
* Schedule ``callback`` on a recurring interval.
|
|
1427
|
+
*
|
|
1428
|
+
* Accepts either a millisecond number (legacy, matches the original TS API)
|
|
1429
|
+
* or an object with ``seconds`` / ``intervalMs`` for parity with Python's
|
|
1430
|
+
* ``schedule_interval(seconds=...)``.
|
|
1431
|
+
*
|
|
1432
|
+
* Examples:
|
|
1433
|
+
* scheduleInterval(5000, cb) // 5 s, legacy
|
|
1434
|
+
* scheduleInterval({ intervalMs: 5000 }, cb)
|
|
1435
|
+
* scheduleInterval({ seconds: 5 }, cb) // parity with Python
|
|
1436
|
+
*/
|
|
1437
|
+
declare function scheduleInterval(intervalOrOpts: number | {
|
|
1438
|
+
seconds?: number;
|
|
1439
|
+
intervalMs?: number;
|
|
1440
|
+
}, callback: JobCallback): ScheduleHandle;
|
|
1168
1441
|
|
|
1169
1442
|
/**
|
|
1170
1443
|
* Soniox Speech-to-Text adapter for Patter (TypeScript).
|
|
@@ -1184,13 +1457,13 @@ declare function scheduleInterval(intervalMs: number, callback: JobCallback): Sc
|
|
|
1184
1457
|
* `speechmatics` extra; TypeScript users need to wait for an official
|
|
1185
1458
|
* upstream SDK before this adapter can land without a WS-handshake reimpl.
|
|
1186
1459
|
*/
|
|
1187
|
-
interface Transcript$
|
|
1460
|
+
interface Transcript$4 {
|
|
1188
1461
|
readonly text: string;
|
|
1189
1462
|
readonly isFinal: boolean;
|
|
1190
1463
|
readonly confidence: number;
|
|
1191
1464
|
}
|
|
1192
|
-
type TranscriptCallback$
|
|
1193
|
-
interface SonioxSTTOptions {
|
|
1465
|
+
type TranscriptCallback$4 = (transcript: Transcript$4) => void;
|
|
1466
|
+
interface SonioxSTTOptions$1 {
|
|
1194
1467
|
model?: string;
|
|
1195
1468
|
languageHints?: string[];
|
|
1196
1469
|
languageHintsStrict?: boolean;
|
|
@@ -1218,7 +1491,7 @@ declare class SonioxSTT {
|
|
|
1218
1491
|
private readonly maxEndpointDelayMs;
|
|
1219
1492
|
private readonly clientReferenceId?;
|
|
1220
1493
|
private readonly baseUrl;
|
|
1221
|
-
constructor(apiKey: string, options?: SonioxSTTOptions);
|
|
1494
|
+
constructor(apiKey: string, options?: SonioxSTTOptions$1);
|
|
1222
1495
|
/** Factory for Twilio-style 8 kHz linear PCM. */
|
|
1223
1496
|
static forTwilio(apiKey: string, languageHints?: string[]): SonioxSTT;
|
|
1224
1497
|
private buildConfig;
|
|
@@ -1227,7 +1500,7 @@ declare class SonioxSTT {
|
|
|
1227
1500
|
private handleMessage;
|
|
1228
1501
|
private emit;
|
|
1229
1502
|
sendAudio(audio: Buffer): void;
|
|
1230
|
-
onTranscript(callback: TranscriptCallback$
|
|
1503
|
+
onTranscript(callback: TranscriptCallback$4): void;
|
|
1231
1504
|
close(): void;
|
|
1232
1505
|
}
|
|
1233
1506
|
|
|
@@ -1242,15 +1515,15 @@ declare class SonioxSTT {
|
|
|
1242
1515
|
* Source: livekit-plugins/livekit-plugins-assemblyai/livekit/plugins/assemblyai/stt.py
|
|
1243
1516
|
* Upstream ref SHA: 78a66bcf79c5cea82989401c408f1dff4b961a5b
|
|
1244
1517
|
*/
|
|
1245
|
-
interface Transcript$
|
|
1518
|
+
interface Transcript$3 {
|
|
1246
1519
|
readonly text: string;
|
|
1247
1520
|
readonly isFinal: boolean;
|
|
1248
1521
|
readonly confidence: number;
|
|
1249
1522
|
}
|
|
1250
|
-
type TranscriptCallback$
|
|
1523
|
+
type TranscriptCallback$3 = (transcript: Transcript$3) => void;
|
|
1251
1524
|
type AssemblyAIEncoding = 'pcm_s16le' | 'pcm_mulaw';
|
|
1252
1525
|
type AssemblyAIModel = 'universal-streaming-english' | 'universal-streaming-multilingual' | 'u3-rt-pro';
|
|
1253
|
-
interface AssemblyAISTTOptions {
|
|
1526
|
+
interface AssemblyAISTTOptions$1 {
|
|
1254
1527
|
/** One of the AssemblyAI speech models. */
|
|
1255
1528
|
readonly model?: AssemblyAIModel;
|
|
1256
1529
|
/** PCM encoding: 16-bit little-endian (default) or G.711 mu-law for telephony. */
|
|
@@ -1291,7 +1564,7 @@ declare class AssemblyAISTT {
|
|
|
1291
1564
|
sessionId: string;
|
|
1292
1565
|
/** Unix timestamp when the AssemblyAI session expires. */
|
|
1293
1566
|
expiresAt: number;
|
|
1294
|
-
constructor(apiKey: string, options?: AssemblyAISTTOptions);
|
|
1567
|
+
constructor(apiKey: string, options?: AssemblyAISTTOptions$1);
|
|
1295
1568
|
/** Factory for Twilio calls — mulaw 8 kHz. */
|
|
1296
1569
|
static forTwilio(apiKey: string, model?: AssemblyAIModel): AssemblyAISTT;
|
|
1297
1570
|
private buildUrl;
|
|
@@ -1299,7 +1572,7 @@ declare class AssemblyAISTT {
|
|
|
1299
1572
|
private handleEvent;
|
|
1300
1573
|
private emit;
|
|
1301
1574
|
sendAudio(audio: Buffer): void;
|
|
1302
|
-
onTranscript(callback: TranscriptCallback$
|
|
1575
|
+
onTranscript(callback: TranscriptCallback$3): void;
|
|
1303
1576
|
close(): void;
|
|
1304
1577
|
}
|
|
1305
1578
|
|
|
@@ -1314,15 +1587,15 @@ declare class AssemblyAISTT {
|
|
|
1314
1587
|
* Source: livekit-plugins/livekit-plugins-cartesia/livekit/plugins/cartesia/stt.py
|
|
1315
1588
|
* Upstream ref SHA: 78a66bcf79c5cea82989401c408f1dff4b961a5b
|
|
1316
1589
|
*/
|
|
1317
|
-
interface Transcript {
|
|
1590
|
+
interface Transcript$2 {
|
|
1318
1591
|
readonly text: string;
|
|
1319
1592
|
readonly isFinal: boolean;
|
|
1320
1593
|
readonly confidence: number;
|
|
1321
1594
|
}
|
|
1322
|
-
type TranscriptCallback = (transcript: Transcript) => void;
|
|
1595
|
+
type TranscriptCallback$2 = (transcript: Transcript$2) => void;
|
|
1323
1596
|
/** Cartesia STT currently only accepts 16-bit PCM little-endian. */
|
|
1324
1597
|
type CartesiaEncoding = 'pcm_s16le';
|
|
1325
|
-
interface CartesiaSTTOptions {
|
|
1598
|
+
interface CartesiaSTTOptions$1 {
|
|
1326
1599
|
/** Cartesia STT model. Currently only `"ink-whisper"`. */
|
|
1327
1600
|
readonly model?: string;
|
|
1328
1601
|
/** BCP-47 language code. */
|
|
@@ -1342,21 +1615,296 @@ declare class CartesiaSTT {
|
|
|
1342
1615
|
private keepaliveTimer;
|
|
1343
1616
|
/** Cartesia request id — set from the server transcript events. */
|
|
1344
1617
|
requestId: string;
|
|
1345
|
-
constructor(apiKey: string, options?: CartesiaSTTOptions);
|
|
1618
|
+
constructor(apiKey: string, options?: CartesiaSTTOptions$1);
|
|
1346
1619
|
private buildWsUrl;
|
|
1347
1620
|
connect(): Promise<void>;
|
|
1348
1621
|
private handleEvent;
|
|
1349
1622
|
private emit;
|
|
1350
1623
|
sendAudio(audio: Buffer): void;
|
|
1351
|
-
onTranscript(callback: TranscriptCallback): void;
|
|
1624
|
+
onTranscript(callback: TranscriptCallback$2): void;
|
|
1625
|
+
close(): void;
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
type LMNTAudioFormat = 'aac' | 'mp3' | 'mulaw' | 'raw' | 'wav';
|
|
1629
|
+
type LMNTModel = 'blizzard' | 'aurora';
|
|
1630
|
+
type LMNTSampleRate = 8000 | 16000 | 24000;
|
|
1631
|
+
interface LMNTTTSOptions$1 {
|
|
1632
|
+
model?: LMNTModel;
|
|
1633
|
+
voice?: string;
|
|
1634
|
+
language?: string;
|
|
1635
|
+
format?: LMNTAudioFormat;
|
|
1636
|
+
sampleRate?: LMNTSampleRate;
|
|
1637
|
+
temperature?: number;
|
|
1638
|
+
topP?: number;
|
|
1639
|
+
baseUrl?: string;
|
|
1640
|
+
}
|
|
1641
|
+
declare class LMNTTTS {
|
|
1642
|
+
private readonly apiKey;
|
|
1643
|
+
private readonly model;
|
|
1644
|
+
private readonly voice;
|
|
1645
|
+
private readonly language;
|
|
1646
|
+
private readonly format;
|
|
1647
|
+
private readonly sampleRate;
|
|
1648
|
+
private readonly temperature;
|
|
1649
|
+
private readonly topP;
|
|
1650
|
+
private readonly baseUrl;
|
|
1651
|
+
constructor(apiKey: string, opts?: LMNTTTSOptions$1);
|
|
1652
|
+
private buildPayload;
|
|
1653
|
+
synthesize(text: string): Promise<Buffer>;
|
|
1654
|
+
/** Yield audio chunks as they arrive — raw PCM_S16LE by default. */
|
|
1655
|
+
synthesizeStream(text: string): AsyncGenerator<Buffer>;
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
interface Transcript$1 {
|
|
1659
|
+
readonly text: string;
|
|
1660
|
+
readonly isFinal: boolean;
|
|
1661
|
+
readonly confidence: number;
|
|
1662
|
+
}
|
|
1663
|
+
type TranscriptCallback$1 = (transcript: Transcript$1) => void;
|
|
1664
|
+
/**
|
|
1665
|
+
* Optional tuning knobs for Deepgram live transcription.
|
|
1666
|
+
*
|
|
1667
|
+
* Mirrors Python's ``DeepgramSTT`` kwargs so callers can lower turn latency
|
|
1668
|
+
* without monkey-patching (BUG #13).
|
|
1669
|
+
*/
|
|
1670
|
+
interface DeepgramSTTOptions$1 {
|
|
1671
|
+
/** Model name. Default ``nova-3``. */
|
|
1672
|
+
readonly model?: string;
|
|
1673
|
+
/** Audio encoding (``linear16`` | ``mulaw`` | etc). Default ``linear16``. */
|
|
1674
|
+
readonly encoding?: string;
|
|
1675
|
+
/** Sample rate in Hz. Default ``16000``. */
|
|
1676
|
+
readonly sampleRate?: number;
|
|
1677
|
+
/**
|
|
1678
|
+
* Voice-activity endpointing threshold in milliseconds.
|
|
1679
|
+
* Lower values reduce turn latency at the cost of more false-start cuts.
|
|
1680
|
+
* Default ``150``.
|
|
1681
|
+
*/
|
|
1682
|
+
readonly endpointingMs?: number;
|
|
1683
|
+
/**
|
|
1684
|
+
* End-of-utterance silence window in milliseconds. Deepgram enforces a
|
|
1685
|
+
* hard minimum of 1000 ms. Set to ``null`` to disable. Default ``1000``.
|
|
1686
|
+
*/
|
|
1687
|
+
readonly utteranceEndMs?: number | null;
|
|
1688
|
+
/** Enable smart formatting (punctuation + numerals). Default ``true``. */
|
|
1689
|
+
readonly smartFormat?: boolean;
|
|
1690
|
+
/** Emit interim (non-final) transcripts. Default ``true``. */
|
|
1691
|
+
readonly interimResults?: boolean;
|
|
1692
|
+
/** Emit VAD events (``SpeechStarted`` / ``UtteranceEnd``). Default ``true``. */
|
|
1693
|
+
readonly vadEvents?: boolean;
|
|
1694
|
+
}
|
|
1695
|
+
declare class DeepgramSTT {
|
|
1696
|
+
private ws;
|
|
1697
|
+
private callbacks;
|
|
1698
|
+
/** Request ID from Deepgram — used to query actual cost post-call. */
|
|
1699
|
+
requestId: string;
|
|
1700
|
+
private readonly apiKey;
|
|
1701
|
+
private readonly language;
|
|
1702
|
+
private readonly model;
|
|
1703
|
+
private readonly encoding;
|
|
1704
|
+
private readonly sampleRate;
|
|
1705
|
+
private readonly endpointingMs;
|
|
1706
|
+
private readonly utteranceEndMs;
|
|
1707
|
+
private readonly smartFormat;
|
|
1708
|
+
private readonly interimResults;
|
|
1709
|
+
private readonly vadEvents;
|
|
1710
|
+
/**
|
|
1711
|
+
* New ergonomic constructor accepting an options object (mirrors Python kwargs).
|
|
1712
|
+
*
|
|
1713
|
+
* Also accepts the legacy positional form
|
|
1714
|
+
* ``(apiKey, language?, model?, encoding?, sampleRate?)`` for backward
|
|
1715
|
+
* compatibility with code that predated BUG #13.
|
|
1716
|
+
*/
|
|
1717
|
+
constructor(apiKey: string, language?: string, model?: string, encoding?: string, sampleRate?: number, options?: DeepgramSTTOptions$1);
|
|
1718
|
+
constructor(apiKey: string, options: DeepgramSTTOptions$1 & {
|
|
1719
|
+
language?: string;
|
|
1720
|
+
});
|
|
1721
|
+
/** Factory for Twilio calls — mulaw 8 kHz. Forwards tuning options through. */
|
|
1722
|
+
static forTwilio(apiKey: string, language?: string, model?: string, options?: DeepgramSTTOptions$1): DeepgramSTT;
|
|
1723
|
+
connect(): Promise<void>;
|
|
1724
|
+
sendAudio(audio: Buffer): void;
|
|
1725
|
+
onTranscript(callback: TranscriptCallback$1): void;
|
|
1352
1726
|
close(): void;
|
|
1353
1727
|
}
|
|
1354
1728
|
|
|
1729
|
+
/** Deepgram streaming STT for Patter pipeline mode. */
|
|
1730
|
+
|
|
1731
|
+
interface DeepgramSTTOptions {
|
|
1732
|
+
/** API key. Falls back to DEEPGRAM_API_KEY env var when omitted. */
|
|
1733
|
+
apiKey?: string;
|
|
1734
|
+
language?: string;
|
|
1735
|
+
model?: string;
|
|
1736
|
+
encoding?: string;
|
|
1737
|
+
sampleRate?: number;
|
|
1738
|
+
endpointingMs?: number;
|
|
1739
|
+
utteranceEndMs?: number | null;
|
|
1740
|
+
smartFormat?: boolean;
|
|
1741
|
+
interimResults?: boolean;
|
|
1742
|
+
vadEvents?: boolean;
|
|
1743
|
+
}
|
|
1744
|
+
/**
|
|
1745
|
+
* Deepgram streaming STT.
|
|
1746
|
+
*
|
|
1747
|
+
* @example
|
|
1748
|
+
* ```ts
|
|
1749
|
+
* import * as deepgram from "getpatter/stt/deepgram";
|
|
1750
|
+
* const stt = new deepgram.STT(); // reads DEEPGRAM_API_KEY
|
|
1751
|
+
* const stt = new deepgram.STT({ apiKey: "dg_...", endpointingMs: 80 });
|
|
1752
|
+
* ```
|
|
1753
|
+
*/
|
|
1754
|
+
declare class STT$4 extends DeepgramSTT {
|
|
1755
|
+
constructor(opts?: DeepgramSTTOptions);
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
/**
|
|
1759
|
+
* OpenAI Whisper STT adapter for the Patter SDK pipeline mode.
|
|
1760
|
+
*
|
|
1761
|
+
* Buffers incoming PCM16 audio and periodically sends it to the
|
|
1762
|
+
* OpenAI Whisper transcription API as a WAV file.
|
|
1763
|
+
*/
|
|
1764
|
+
interface Transcript {
|
|
1765
|
+
readonly text: string;
|
|
1766
|
+
readonly isFinal: boolean;
|
|
1767
|
+
readonly confidence: number;
|
|
1768
|
+
}
|
|
1769
|
+
type TranscriptCallback = (transcript: Transcript) => void;
|
|
1770
|
+
declare class WhisperSTT {
|
|
1771
|
+
private readonly apiKey;
|
|
1772
|
+
private readonly model;
|
|
1773
|
+
private readonly language;
|
|
1774
|
+
private readonly bufferSize;
|
|
1775
|
+
private buffer;
|
|
1776
|
+
private callbacks;
|
|
1777
|
+
private running;
|
|
1778
|
+
private pendingTranscriptions;
|
|
1779
|
+
constructor(apiKey: string, model?: string, language?: string, bufferSize?: number);
|
|
1780
|
+
/** Factory for Twilio calls — mulaw 8 kHz is transcoded upstream, so we still receive PCM 16-bit. */
|
|
1781
|
+
static forTwilio(apiKey: string, language?: string, model?: string): WhisperSTT;
|
|
1782
|
+
connect(): Promise<void>;
|
|
1783
|
+
sendAudio(audio: Buffer): void;
|
|
1784
|
+
private trackTranscription;
|
|
1785
|
+
onTranscript(callback: TranscriptCallback): void;
|
|
1786
|
+
close(): Promise<void>;
|
|
1787
|
+
private transcribeBuffer;
|
|
1788
|
+
}
|
|
1789
|
+
|
|
1790
|
+
/** OpenAI Whisper STT for Patter pipeline mode. */
|
|
1791
|
+
|
|
1792
|
+
interface WhisperSTTOptions {
|
|
1793
|
+
/** API key. Falls back to OPENAI_API_KEY env var when omitted. */
|
|
1794
|
+
apiKey?: string;
|
|
1795
|
+
model?: string;
|
|
1796
|
+
language?: string;
|
|
1797
|
+
bufferSize?: number;
|
|
1798
|
+
}
|
|
1799
|
+
/**
|
|
1800
|
+
* OpenAI Whisper STT.
|
|
1801
|
+
*
|
|
1802
|
+
* @example
|
|
1803
|
+
* ```ts
|
|
1804
|
+
* import * as whisper from "getpatter/stt/whisper";
|
|
1805
|
+
* const stt = new whisper.STT(); // reads OPENAI_API_KEY
|
|
1806
|
+
* const stt = new whisper.STT({ apiKey: "sk-...", language: "en" });
|
|
1807
|
+
* ```
|
|
1808
|
+
*/
|
|
1809
|
+
declare class STT$3 extends WhisperSTT {
|
|
1810
|
+
constructor(opts?: WhisperSTTOptions);
|
|
1811
|
+
}
|
|
1812
|
+
|
|
1813
|
+
/** Cartesia streaming STT for Patter pipeline mode. */
|
|
1814
|
+
|
|
1815
|
+
interface CartesiaSTTOptions {
|
|
1816
|
+
/** API key. Falls back to CARTESIA_API_KEY env var when omitted. */
|
|
1817
|
+
apiKey?: string;
|
|
1818
|
+
model?: string;
|
|
1819
|
+
language?: string;
|
|
1820
|
+
encoding?: CartesiaEncoding;
|
|
1821
|
+
sampleRate?: number;
|
|
1822
|
+
baseUrl?: string;
|
|
1823
|
+
}
|
|
1824
|
+
/**
|
|
1825
|
+
* Cartesia streaming STT (ink-whisper).
|
|
1826
|
+
*
|
|
1827
|
+
* @example
|
|
1828
|
+
* ```ts
|
|
1829
|
+
* import * as cartesia from "getpatter/stt/cartesia";
|
|
1830
|
+
* const stt = new cartesia.STT(); // reads CARTESIA_API_KEY
|
|
1831
|
+
* const stt = new cartesia.STT({ apiKey: "..." });
|
|
1832
|
+
* ```
|
|
1833
|
+
*/
|
|
1834
|
+
declare class STT$2 extends CartesiaSTT {
|
|
1835
|
+
constructor(opts?: CartesiaSTTOptions);
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1838
|
+
/** Soniox streaming STT for Patter pipeline mode. */
|
|
1839
|
+
|
|
1840
|
+
interface SonioxSTTOptions {
|
|
1841
|
+
/** API key. Falls back to SONIOX_API_KEY env var when omitted. */
|
|
1842
|
+
apiKey?: string;
|
|
1843
|
+
model?: string;
|
|
1844
|
+
languageHints?: string[];
|
|
1845
|
+
languageHintsStrict?: boolean;
|
|
1846
|
+
sampleRate?: number;
|
|
1847
|
+
numChannels?: number;
|
|
1848
|
+
enableSpeakerDiarization?: boolean;
|
|
1849
|
+
enableLanguageIdentification?: boolean;
|
|
1850
|
+
maxEndpointDelayMs?: number;
|
|
1851
|
+
clientReferenceId?: string;
|
|
1852
|
+
baseUrl?: string;
|
|
1853
|
+
}
|
|
1854
|
+
/**
|
|
1855
|
+
* Soniox streaming STT.
|
|
1856
|
+
*
|
|
1857
|
+
* @example
|
|
1858
|
+
* ```ts
|
|
1859
|
+
* import * as soniox from "getpatter/stt/soniox";
|
|
1860
|
+
* const stt = new soniox.STT(); // reads SONIOX_API_KEY
|
|
1861
|
+
* const stt = new soniox.STT({ apiKey: "..." });
|
|
1862
|
+
* ```
|
|
1863
|
+
*/
|
|
1864
|
+
declare class STT$1 extends SonioxSTT {
|
|
1865
|
+
constructor(opts?: SonioxSTTOptions);
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
/** AssemblyAI Universal Streaming STT for Patter pipeline mode. */
|
|
1869
|
+
|
|
1870
|
+
interface AssemblyAISTTOptions {
|
|
1871
|
+
/** API key. Falls back to ASSEMBLYAI_API_KEY env var when omitted. */
|
|
1872
|
+
apiKey?: string;
|
|
1873
|
+
model?: AssemblyAIModel;
|
|
1874
|
+
encoding?: AssemblyAIEncoding;
|
|
1875
|
+
sampleRate?: number;
|
|
1876
|
+
baseUrl?: string;
|
|
1877
|
+
languageDetection?: boolean;
|
|
1878
|
+
endOfTurnConfidenceThreshold?: number;
|
|
1879
|
+
minTurnSilence?: number;
|
|
1880
|
+
maxTurnSilence?: number;
|
|
1881
|
+
formatTurns?: boolean;
|
|
1882
|
+
keytermsPrompt?: readonly string[];
|
|
1883
|
+
prompt?: string;
|
|
1884
|
+
vadThreshold?: number;
|
|
1885
|
+
speakerLabels?: boolean;
|
|
1886
|
+
maxSpeakers?: number;
|
|
1887
|
+
domain?: string;
|
|
1888
|
+
}
|
|
1889
|
+
/**
|
|
1890
|
+
* AssemblyAI Universal Streaming STT.
|
|
1891
|
+
*
|
|
1892
|
+
* @example
|
|
1893
|
+
* ```ts
|
|
1894
|
+
* import * as assemblyai from "getpatter/stt/assemblyai";
|
|
1895
|
+
* const stt = new assemblyai.STT(); // reads ASSEMBLYAI_API_KEY
|
|
1896
|
+
* const stt = new assemblyai.STT({ apiKey: "..." });
|
|
1897
|
+
* ```
|
|
1898
|
+
*/
|
|
1899
|
+
declare class STT extends AssemblyAISTT {
|
|
1900
|
+
constructor(opts?: AssemblyAISTTOptions);
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1355
1903
|
declare class ElevenLabsTTS {
|
|
1356
1904
|
private readonly apiKey;
|
|
1357
|
-
private readonly voiceId;
|
|
1358
1905
|
private readonly modelId;
|
|
1359
1906
|
private readonly outputFormat;
|
|
1907
|
+
private readonly voiceId;
|
|
1360
1908
|
constructor(apiKey: string, voiceId?: string, modelId?: string, outputFormat?: string);
|
|
1361
1909
|
/**
|
|
1362
1910
|
* Synthesise text to speech and return the full audio as a single Buffer.
|
|
@@ -1373,6 +1921,29 @@ declare class ElevenLabsTTS {
|
|
|
1373
1921
|
synthesizeStream(text: string): AsyncGenerator<Buffer>;
|
|
1374
1922
|
}
|
|
1375
1923
|
|
|
1924
|
+
/** ElevenLabs TTS for Patter pipeline mode. */
|
|
1925
|
+
|
|
1926
|
+
interface ElevenLabsTTSOptions {
|
|
1927
|
+
/** API key. Falls back to ELEVENLABS_API_KEY env var when omitted. */
|
|
1928
|
+
apiKey?: string;
|
|
1929
|
+
voiceId?: string;
|
|
1930
|
+
modelId?: string;
|
|
1931
|
+
outputFormat?: string;
|
|
1932
|
+
}
|
|
1933
|
+
/**
|
|
1934
|
+
* ElevenLabs TTS.
|
|
1935
|
+
*
|
|
1936
|
+
* @example
|
|
1937
|
+
* ```ts
|
|
1938
|
+
* import * as elevenlabs from "getpatter/tts/elevenlabs";
|
|
1939
|
+
* const tts = new elevenlabs.TTS(); // reads ELEVENLABS_API_KEY
|
|
1940
|
+
* const tts = new elevenlabs.TTS({ apiKey: "...", voiceId: "rachel" });
|
|
1941
|
+
* ```
|
|
1942
|
+
*/
|
|
1943
|
+
declare class TTS$4 extends ElevenLabsTTS {
|
|
1944
|
+
constructor(opts?: ElevenLabsTTSOptions);
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1376
1947
|
declare class OpenAITTS {
|
|
1377
1948
|
private readonly apiKey;
|
|
1378
1949
|
private readonly voice;
|
|
@@ -1389,19 +1960,48 @@ declare class OpenAITTS {
|
|
|
1389
1960
|
*
|
|
1390
1961
|
* OpenAI returns 24 kHz PCM16; each chunk is resampled to 16 kHz before
|
|
1391
1962
|
* yielding so the output is ready for telephony pipelines.
|
|
1963
|
+
*
|
|
1964
|
+
* The resampler carries state (buffered samples + odd trailing byte)
|
|
1965
|
+
* between chunks — without that state cross-chunk sample alignment drifts
|
|
1966
|
+
* and the caller hears pops / dropped audio (BUG #23, mirror of the
|
|
1967
|
+
* Python `audioop.ratecv` fix).
|
|
1392
1968
|
*/
|
|
1393
1969
|
synthesizeStream(text: string): AsyncGenerator<Buffer>;
|
|
1394
1970
|
/**
|
|
1395
|
-
*
|
|
1396
|
-
*
|
|
1397
|
-
* For each group of 3 input samples the first is kept as-is and the second
|
|
1398
|
-
* output sample is the average of input samples 2 and 3. This matches the
|
|
1399
|
-
* Python SDK implementation.
|
|
1971
|
+
* Streaming 24 kHz → 16 kHz resampler (PCM16-LE). Maintains cross-chunk
|
|
1972
|
+
* state so the 3:2 pattern doesn't reset at every network read.
|
|
1400
1973
|
*/
|
|
1974
|
+
static resampleStreaming(audio: Buffer, ctx: {
|
|
1975
|
+
carryByte: number | null;
|
|
1976
|
+
leftover: number[];
|
|
1977
|
+
}): Buffer;
|
|
1978
|
+
/** @deprecated use {@link resampleStreaming} with persistent state. */
|
|
1401
1979
|
static resample24kTo16k(audio: Buffer): Buffer;
|
|
1402
1980
|
}
|
|
1403
1981
|
|
|
1404
|
-
|
|
1982
|
+
/** OpenAI TTS for Patter pipeline mode. */
|
|
1983
|
+
|
|
1984
|
+
interface OpenAITTSOptions {
|
|
1985
|
+
/** API key. Falls back to OPENAI_API_KEY env var when omitted. */
|
|
1986
|
+
apiKey?: string;
|
|
1987
|
+
voice?: string;
|
|
1988
|
+
model?: string;
|
|
1989
|
+
}
|
|
1990
|
+
/**
|
|
1991
|
+
* OpenAI TTS.
|
|
1992
|
+
*
|
|
1993
|
+
* @example
|
|
1994
|
+
* ```ts
|
|
1995
|
+
* import * as openai from "getpatter/tts/openai";
|
|
1996
|
+
* const tts = new openai.TTS(); // reads OPENAI_API_KEY
|
|
1997
|
+
* const tts = new openai.TTS({ apiKey: "sk-...", voice: "alloy" });
|
|
1998
|
+
* ```
|
|
1999
|
+
*/
|
|
2000
|
+
declare class TTS$3 extends OpenAITTS {
|
|
2001
|
+
constructor(opts?: OpenAITTSOptions);
|
|
2002
|
+
}
|
|
2003
|
+
|
|
2004
|
+
interface CartesiaTTSOptions$1 {
|
|
1405
2005
|
model?: string;
|
|
1406
2006
|
voice?: string;
|
|
1407
2007
|
language?: string;
|
|
@@ -1423,7 +2023,7 @@ declare class CartesiaTTS {
|
|
|
1423
2023
|
private readonly volume?;
|
|
1424
2024
|
private readonly baseUrl;
|
|
1425
2025
|
private readonly apiVersion;
|
|
1426
|
-
constructor(apiKey: string, opts?: CartesiaTTSOptions);
|
|
2026
|
+
constructor(apiKey: string, opts?: CartesiaTTSOptions$1);
|
|
1427
2027
|
/** Build the JSON payload for the Cartesia bytes endpoint. */
|
|
1428
2028
|
private buildPayload;
|
|
1429
2029
|
/** Synthesize text and return the concatenated audio buffer. */
|
|
@@ -1435,7 +2035,36 @@ declare class CartesiaTTS {
|
|
|
1435
2035
|
synthesizeStream(text: string): AsyncGenerator<Buffer>;
|
|
1436
2036
|
}
|
|
1437
2037
|
|
|
1438
|
-
|
|
2038
|
+
/** Cartesia TTS for Patter pipeline mode. */
|
|
2039
|
+
|
|
2040
|
+
interface CartesiaTTSOptions {
|
|
2041
|
+
/** API key. Falls back to CARTESIA_API_KEY env var when omitted. */
|
|
2042
|
+
apiKey?: string;
|
|
2043
|
+
model?: string;
|
|
2044
|
+
voice?: string;
|
|
2045
|
+
language?: string;
|
|
2046
|
+
sampleRate?: number;
|
|
2047
|
+
speed?: string | number;
|
|
2048
|
+
emotion?: string | string[];
|
|
2049
|
+
volume?: number;
|
|
2050
|
+
baseUrl?: string;
|
|
2051
|
+
apiVersion?: string;
|
|
2052
|
+
}
|
|
2053
|
+
/**
|
|
2054
|
+
* Cartesia TTS (sonic-2).
|
|
2055
|
+
*
|
|
2056
|
+
* @example
|
|
2057
|
+
* ```ts
|
|
2058
|
+
* import * as cartesia from "getpatter/tts/cartesia";
|
|
2059
|
+
* const tts = new cartesia.TTS(); // reads CARTESIA_API_KEY
|
|
2060
|
+
* const tts = new cartesia.TTS({ apiKey: "..." });
|
|
2061
|
+
* ```
|
|
2062
|
+
*/
|
|
2063
|
+
declare class TTS$2 extends CartesiaTTS {
|
|
2064
|
+
constructor(opts?: CartesiaTTSOptions);
|
|
2065
|
+
}
|
|
2066
|
+
|
|
2067
|
+
interface RimeTTSOptions$1 {
|
|
1439
2068
|
model?: string;
|
|
1440
2069
|
speaker?: string;
|
|
1441
2070
|
lang?: string;
|
|
@@ -1466,7 +2095,7 @@ declare class RimeTTS {
|
|
|
1466
2095
|
private readonly phonemizeBetweenBrackets?;
|
|
1467
2096
|
private readonly baseUrl;
|
|
1468
2097
|
private readonly totalTimeoutMs;
|
|
1469
|
-
constructor(apiKey: string, opts?: RimeTTSOptions);
|
|
2098
|
+
constructor(apiKey: string, opts?: RimeTTSOptions$1);
|
|
1470
2099
|
private buildPayload;
|
|
1471
2100
|
synthesize(text: string): Promise<Buffer>;
|
|
1472
2101
|
/**
|
|
@@ -1476,10 +2105,44 @@ declare class RimeTTS {
|
|
|
1476
2105
|
synthesizeStream(text: string): AsyncGenerator<Buffer>;
|
|
1477
2106
|
}
|
|
1478
2107
|
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
2108
|
+
/** Rime TTS for Patter pipeline mode. */
|
|
2109
|
+
|
|
2110
|
+
interface RimeTTSOptions {
|
|
2111
|
+
/** API key. Falls back to RIME_API_KEY env var when omitted. */
|
|
2112
|
+
apiKey?: string;
|
|
2113
|
+
model?: string;
|
|
2114
|
+
speaker?: string;
|
|
2115
|
+
lang?: string;
|
|
2116
|
+
sampleRate?: number;
|
|
2117
|
+
repetitionPenalty?: number;
|
|
2118
|
+
temperature?: number;
|
|
2119
|
+
topP?: number;
|
|
2120
|
+
maxTokens?: number;
|
|
2121
|
+
speedAlpha?: number;
|
|
2122
|
+
reduceLatency?: boolean;
|
|
2123
|
+
pauseBetweenBrackets?: boolean;
|
|
2124
|
+
phonemizeBetweenBrackets?: boolean;
|
|
2125
|
+
baseUrl?: string;
|
|
2126
|
+
}
|
|
2127
|
+
/**
|
|
2128
|
+
* Rime TTS (Arcana or Mist models).
|
|
2129
|
+
*
|
|
2130
|
+
* @example
|
|
2131
|
+
* ```ts
|
|
2132
|
+
* import * as rime from "getpatter/tts/rime";
|
|
2133
|
+
* const tts = new rime.TTS(); // reads RIME_API_KEY
|
|
2134
|
+
* const tts = new rime.TTS({ apiKey: "...", speaker: "astra" });
|
|
2135
|
+
* ```
|
|
2136
|
+
*/
|
|
2137
|
+
declare class TTS$1 extends RimeTTS {
|
|
2138
|
+
constructor(opts?: RimeTTSOptions);
|
|
2139
|
+
}
|
|
2140
|
+
|
|
2141
|
+
/** LMNT TTS for Patter pipeline mode. */
|
|
2142
|
+
|
|
1482
2143
|
interface LMNTTTSOptions {
|
|
2144
|
+
/** API key. Falls back to LMNT_API_KEY env var when omitted. */
|
|
2145
|
+
apiKey?: string;
|
|
1483
2146
|
model?: LMNTModel;
|
|
1484
2147
|
voice?: string;
|
|
1485
2148
|
language?: string;
|
|
@@ -1489,21 +2152,18 @@ interface LMNTTTSOptions {
|
|
|
1489
2152
|
topP?: number;
|
|
1490
2153
|
baseUrl?: string;
|
|
1491
2154
|
}
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
synthesize(text: string): Promise<Buffer>;
|
|
1505
|
-
/** Yield audio chunks as they arrive — raw PCM_S16LE by default. */
|
|
1506
|
-
synthesizeStream(text: string): AsyncGenerator<Buffer>;
|
|
2155
|
+
/**
|
|
2156
|
+
* LMNT TTS (blizzard/aurora).
|
|
2157
|
+
*
|
|
2158
|
+
* @example
|
|
2159
|
+
* ```ts
|
|
2160
|
+
* import * as lmnt from "getpatter/tts/lmnt";
|
|
2161
|
+
* const tts = new lmnt.TTS(); // reads LMNT_API_KEY
|
|
2162
|
+
* const tts = new lmnt.TTS({ apiKey: "...", voice: "leah" });
|
|
2163
|
+
* ```
|
|
2164
|
+
*/
|
|
2165
|
+
declare class TTS extends LMNTTTS {
|
|
2166
|
+
constructor(opts?: LMNTTTSOptions);
|
|
1507
2167
|
}
|
|
1508
2168
|
|
|
1509
2169
|
/**
|
|
@@ -1867,4 +2527,4 @@ declare class BackgroundAudioPlayer implements BackgroundAudioPlayer$1 {
|
|
|
1867
2527
|
private resampleTo;
|
|
1868
2528
|
}
|
|
1869
2529
|
|
|
1870
|
-
export { type Agent, type AgentOptions, AllProvidersFailedError, type AnthropicConversion, type AnthropicMessage, type AssemblyAIEncoding, type AssemblyAIModel, AssemblyAISTT, type AssemblyAISTTOptions, type AudioConfig, type AudioSource, AuthenticationError, type BackgroundAudioOptions, BackgroundAudioPlayer, BuiltinAudioClip, type BuiltinAudioClipName, type BuiltinPcmSource, type Call, type CallControl, type CallEventHandler, type CallMetrics, CallMetricsAccumulator, type CallOptions, type CallRecord, type CartesiaEncoding, CartesiaSTT, type CartesiaSTTOptions, CartesiaTTS, type CartesiaTTSOptions, ChatContext, type ChatMessage, type ChatRole, type ConnectOptions, type CostBreakdown, type CreateAgentOptions, DEFAULT_MIN_SENTENCE_LEN, DEFAULT_PRICING, DTMF_EVENTS, DeepgramSTT, type DefineToolInput, type DtmfEvent, ElevenLabsConvAIAdapter, ElevenLabsTTS, FallbackLLMProvider, type FallbackLLMProviderOptions, type FilePcmSource, GEMINI_DEFAULT_INPUT_SR, GEMINI_DEFAULT_OUTPUT_SR, GeminiLiveAdapter, type GeminiLiveEventHandler,
|
|
2530
|
+
export { type Agent, type AgentOptions, AllProvidersFailedError, type AnthropicConversion, type AnthropicMessage, type AssemblyAIEncoding, type AssemblyAIModel, STT as AssemblyAISTT, type AssemblyAISTTOptions, type AudioConfig, type AudioSource, AuthenticationError, type BackgroundAudioOptions, BackgroundAudioPlayer, BuiltinAudioClip, type BuiltinAudioClipName, type BuiltinPcmSource, type Call, type CallControl, type CallEventHandler, type CallMetrics, CallMetricsAccumulator, type CallOptions, type CallRecord, type CartesiaEncoding, STT$2 as CartesiaSTT, type CartesiaSTTOptions, TTS$2 as CartesiaTTS, type CartesiaTTSOptions, ChatContext, type ChatMessage, type ChatRole, CloudflareTunnel, type ConnectOptions, type CostBreakdown, type CreateAgentOptions, DEFAULT_MIN_SENTENCE_LEN, DEFAULT_PRICING, DTMF_EVENTS, STT$4 as DeepgramSTT, type DeepgramSTTOptions, type DefineToolInput, type DtmfEvent, ConvAI as ElevenLabsConvAI, ElevenLabsConvAIAdapter, type ConvAIOptions as ElevenLabsConvAIOptions, TTS$4 as ElevenLabsTTS, type ElevenLabsTTSOptions, FallbackLLMProvider, type FallbackLLMProviderOptions, type FilePcmSource, GEMINI_DEFAULT_INPUT_SR, GEMINI_DEFAULT_OUTPUT_SR, GeminiLiveAdapter, type GeminiLiveEventHandler, Guardrail$1 as Guardrail, type GuardrailOptions, type HookContext, IVRActivity, type IVRActivityOptions, type IVRToolDefinition, type IncomingMessage, type JobCallback, type LLMChunk, LLMLoop, type LLMProvider, type LMNTAudioFormat, type LMNTModel, type LMNTSampleRate, TTS as LMNTTTS, type LMNTTTSOptions, type LatencyBreakdown, type LocalCallOptions, type LocalConfig, type LocalOptions, type Logger, type LoopCallback, type MessageHandler, MetricsStore, OpenAILLMProvider, type OpenAIMessage, Realtime as OpenAIRealtime, OpenAIRealtimeAdapter, type RealtimeOptions as OpenAIRealtimeOptions, TTS$3 as OpenAITTS, type OpenAITTSOptions, type ParamSpec, PartialStreamError, Patter, PatterConnectionError, PatterError, type PatterOptions, type PhoneNumber, PipelineHookExecutor, type PipelineHooks, type PipelineMessageHandler, type ProviderPricing, ProvisionError, type RawPcmSource, RemoteMessageHandler, TTS$1 as RimeTTS, type RimeTTSOptions, type SSEEvent, type STTConfig, type ScheduleHandle, SentenceChunker, type ServeOptions, type SilenceCallback, STT$1 as SonioxSTT, type SonioxSTTOptions$1 as SonioxSTTOptions, Static as StaticTunnel, type TTSConfig, Carrier as Telnyx, type TelnyxCarrierOptions, TestSession, TfidfLoopDetector, type TfidfLoopDetectorOptions, Tool, type ToolDefinition, type ToolHandler, type ToolOptions, type TunnelHandle, type TurnMetrics, Carrier$1 as Twilio, type TwilioCarrierOptions, ULTRAVOX_DEFAULT_API_BASE, ULTRAVOX_DEFAULT_SR, type UltravoxEventHandler, UltravoxRealtimeAdapter, STT$3 as WhisperSTT, type WhisperSTTOptions, builtinClipPath, calculateRealtimeCost, calculateSttCost, calculateTelephonyCost, calculateTtsCost, callsToCsv, callsToJson, deepgram, defineTool, elevenlabs, filterEmoji, filterForTTS, filterMarkdown, formatDtmf, getLogger, guardrail, isRemoteUrl, isWebSocketUrl, makeAuthMiddleware, mergePricing, mixPcm, mountApi, mountDashboard, mulawToPcm16, notifyDashboard, openaiTts, pcm16ToMulaw, resample16kTo8k, resample24kTo16k, resample8kTo16k, resamplePcm, scheduleCron, scheduleInterval, scheduleOnce, selectSoundFromList, setLogger, startTunnel, tool, whisper };
|