kugelaudio 0.4.0 → 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/CHANGELOG.md +11 -0
- package/README.md +36 -0
- package/dist/index.d.mts +179 -2
- package/dist/index.d.ts +179 -2
- package/dist/index.js +202 -0
- package/dist/index.mjs +199 -0
- package/package.json +1 -1
- package/src/client.ts +4 -0
- package/src/dictionaries.test.ts +212 -0
- package/src/dictionaries.ts +278 -0
- package/src/errors.ts +24 -1
- package/src/index.ts +11 -0
- package/src/types.ts +88 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
## [kugelaudio-v0.5.0](https://github.com/Kugelaudio/KugelAudio/compare/js-sdk-v0.4.0...js-sdk-v0.5.0) (2026-05-21)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
* **ingress,sdks:** public API for custom word dictionaries (KUG-765) ([#875](https://github.com/Kugelaudio/KugelAudio/issues/875)) ([9988924](https://github.com/Kugelaudio/KugelAudio/commit/99889244997d1cb4dba9714e2633d84ace9852a3))
|
|
6
|
+
* **sdk:** add NotFoundError for unknown resources (KUG-423) ([#872](https://github.com/Kugelaudio/KugelAudio/issues/872)) ([d613b0f](https://github.com/Kugelaudio/KugelAudio/commit/d613b0fa1314c9e9e1f2af924652d94014626ddc))
|
|
7
|
+
|
|
8
|
+
### Reverts
|
|
9
|
+
|
|
10
|
+
* undo accidental merge of PR [#723](https://github.com/Kugelaudio/KugelAudio/issues/723) ([e8eff2e](https://github.com/Kugelaudio/KugelAudio/commit/e8eff2e86c76b893262782ff6ae763ed405396ce))
|
|
11
|
+
|
|
1
12
|
## [kugelaudio-v0.4.0](https://github.com/Kugelaudio/KugelAudio/compare/js-sdk-v0.3.0...js-sdk-v0.4.0) (2026-05-14)
|
|
2
13
|
|
|
3
14
|
### Features
|
package/README.md
CHANGED
|
@@ -274,6 +274,39 @@ onChunk: (chunk) => {
|
|
|
274
274
|
}
|
|
275
275
|
```
|
|
276
276
|
|
|
277
|
+
## LLM Integration: Streaming Text Input
|
|
278
|
+
|
|
279
|
+
For real-time TTS when streaming text from an LLM (GPT-4, Claude, etc.),
|
|
280
|
+
use a `StreamingSession`. Forward LLM tokens directly to `session.send()`
|
|
281
|
+
**without** `flush=true` — the server accumulates them and starts
|
|
282
|
+
generation at natural sentence boundaries. `session.close()` triggers a
|
|
283
|
+
single final flush at the end of the assistant turn.
|
|
284
|
+
|
|
285
|
+
```typescript
|
|
286
|
+
const session = client.tts.streamingSession(
|
|
287
|
+
{ voiceId: 123, modelId: 'kugel-1-turbo', language: 'en' },
|
|
288
|
+
{ onChunk: (chunk) => playAudio(chunk.audio) },
|
|
289
|
+
);
|
|
290
|
+
await session.connect();
|
|
291
|
+
|
|
292
|
+
// Forward every LLM token directly. No flush per token —
|
|
293
|
+
// the server's text buffer chunks at sentence boundaries.
|
|
294
|
+
for await (const token of llmTokenStream) {
|
|
295
|
+
session.send(token);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// Triggers the server-side final flush of any trailing text,
|
|
299
|
+
// streams the resulting audio through onChunk, then closes the WS.
|
|
300
|
+
await session.close();
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
> ⚠️ **Do not call `session.send(text, true)` (`flush=true`) between
|
|
304
|
+
> sentences or words.** Each explicit flush is a separate TTS request
|
|
305
|
+
> that pays the full model time-to-first-audio (TTFA) again and produces
|
|
306
|
+
> an audible gap. See [Streaming best practices](https://docs.kugelaudio.com/streaming-best-practices)
|
|
307
|
+
> for the full rationale, chunk-size ordering, and ElevenLabs migration
|
|
308
|
+
> notes.
|
|
309
|
+
|
|
277
310
|
## Text Normalization
|
|
278
311
|
|
|
279
312
|
Text normalization converts numbers, dates, times, and other non-verbal text into spoken words. For example:
|
|
@@ -331,6 +364,7 @@ import {
|
|
|
331
364
|
RateLimitError,
|
|
332
365
|
InsufficientCreditsError,
|
|
333
366
|
ValidationError,
|
|
367
|
+
NotFoundError,
|
|
334
368
|
ConnectionError,
|
|
335
369
|
} from 'kugelaudio';
|
|
336
370
|
|
|
@@ -345,6 +379,8 @@ try {
|
|
|
345
379
|
console.error('Not enough credits, please top up');
|
|
346
380
|
} else if (error instanceof ValidationError) {
|
|
347
381
|
console.error(`Invalid request: ${error.message}`);
|
|
382
|
+
} else if (error instanceof NotFoundError) {
|
|
383
|
+
console.error(`Resource not found (e.g. unknown voiceId): ${error.message}`);
|
|
348
384
|
} else if (error instanceof ConnectionError) {
|
|
349
385
|
console.error('Failed to connect to server');
|
|
350
386
|
} else if (error instanceof KugelAudioError) {
|
package/dist/index.d.mts
CHANGED
|
@@ -54,6 +54,84 @@ interface VoiceListResponse {
|
|
|
54
54
|
* Voice quality levels.
|
|
55
55
|
*/
|
|
56
56
|
type VoiceQuality = 'low' | 'mid' | 'high';
|
|
57
|
+
/**
|
|
58
|
+
* A per-project pronunciation dictionary.
|
|
59
|
+
*/
|
|
60
|
+
interface Dictionary {
|
|
61
|
+
id: number;
|
|
62
|
+
projectId: number;
|
|
63
|
+
name: string;
|
|
64
|
+
description?: string;
|
|
65
|
+
language?: string;
|
|
66
|
+
isActive: boolean;
|
|
67
|
+
createdAt: string;
|
|
68
|
+
updatedAt: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A single word → replacement / IPA mapping within a dictionary.
|
|
72
|
+
*/
|
|
73
|
+
interface DictionaryEntry {
|
|
74
|
+
id: number;
|
|
75
|
+
dictionaryId: number;
|
|
76
|
+
word: string;
|
|
77
|
+
replacement: string;
|
|
78
|
+
ipa?: string;
|
|
79
|
+
caseSensitive: boolean;
|
|
80
|
+
createdAt: string;
|
|
81
|
+
updatedAt: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Paginated response from listing entries.
|
|
85
|
+
*/
|
|
86
|
+
interface DictionaryEntryListResponse {
|
|
87
|
+
entries: DictionaryEntry[];
|
|
88
|
+
total: number;
|
|
89
|
+
limit: number;
|
|
90
|
+
offset: number;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Counts returned by `entries.replaceAll`.
|
|
94
|
+
*/
|
|
95
|
+
interface BulkReplaceResult {
|
|
96
|
+
upserted: number;
|
|
97
|
+
deleted: number;
|
|
98
|
+
total: number;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Options for creating a dictionary.
|
|
102
|
+
*/
|
|
103
|
+
interface CreateDictionaryOptions {
|
|
104
|
+
name: string;
|
|
105
|
+
description?: string;
|
|
106
|
+
language?: string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Options for updating a dictionary. Only provided fields are changed.
|
|
110
|
+
*/
|
|
111
|
+
interface UpdateDictionaryOptions {
|
|
112
|
+
name?: string;
|
|
113
|
+
description?: string;
|
|
114
|
+
language?: string;
|
|
115
|
+
isActive?: boolean;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Payload for creating or replacing a single entry.
|
|
119
|
+
*/
|
|
120
|
+
interface DictionaryEntryInput {
|
|
121
|
+
word: string;
|
|
122
|
+
replacement: string;
|
|
123
|
+
ipa?: string;
|
|
124
|
+
caseSensitive?: boolean;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Options for updating an entry.
|
|
128
|
+
*/
|
|
129
|
+
interface UpdateDictionaryEntryOptions {
|
|
130
|
+
word?: string;
|
|
131
|
+
replacement?: string;
|
|
132
|
+
ipa?: string;
|
|
133
|
+
caseSensitive?: boolean;
|
|
134
|
+
}
|
|
57
135
|
/**
|
|
58
136
|
* Extended voice information returned by voice management endpoints.
|
|
59
137
|
*/
|
|
@@ -482,6 +560,92 @@ interface MultiContextCallbacks {
|
|
|
482
560
|
onError?: (error: Error, contextId?: string) => void;
|
|
483
561
|
}
|
|
484
562
|
|
|
563
|
+
/**
|
|
564
|
+
* Resources for managing per-project custom word dictionaries.
|
|
565
|
+
*
|
|
566
|
+
* @example
|
|
567
|
+
* ```typescript
|
|
568
|
+
* const dict = await client.dictionaries.create({ name: 'Brand names' });
|
|
569
|
+
* await client.dictionaries.entries.add(dict.id, {
|
|
570
|
+
* word: 'Postgres',
|
|
571
|
+
* replacement: 'post-gres',
|
|
572
|
+
* });
|
|
573
|
+
*
|
|
574
|
+
* // Sync from an external source — atomic, idempotent
|
|
575
|
+
* await client.dictionaries.entries.replaceAll(dict.id, [
|
|
576
|
+
* { word: 'Postgres', replacement: 'post-gres' },
|
|
577
|
+
* { word: 'Kubernetes', replacement: 'koo-ber-net-eez' },
|
|
578
|
+
* ]);
|
|
579
|
+
* ```
|
|
580
|
+
*/
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* Resource for entries within a single dictionary.
|
|
584
|
+
* Access via ``client.dictionaries.entries`` and pass ``dictionaryId``
|
|
585
|
+
* to each call.
|
|
586
|
+
*/
|
|
587
|
+
declare class DictionaryEntriesResource {
|
|
588
|
+
private client;
|
|
589
|
+
constructor(client: KugelAudio);
|
|
590
|
+
/** List entries with optional search + pagination. */
|
|
591
|
+
list(dictionaryId: number, options?: {
|
|
592
|
+
search?: string;
|
|
593
|
+
limit?: number;
|
|
594
|
+
offset?: number;
|
|
595
|
+
projectId?: number;
|
|
596
|
+
}): Promise<DictionaryEntryListResponse>;
|
|
597
|
+
/** Add a single entry to a dictionary. */
|
|
598
|
+
add(dictionaryId: number, entry: DictionaryEntryInput, options?: {
|
|
599
|
+
projectId?: number;
|
|
600
|
+
}): Promise<DictionaryEntry>;
|
|
601
|
+
/** Update an existing entry. */
|
|
602
|
+
update(dictionaryId: number, entryId: number, updates: UpdateDictionaryEntryOptions, options?: {
|
|
603
|
+
projectId?: number;
|
|
604
|
+
}): Promise<DictionaryEntry>;
|
|
605
|
+
/** Delete a single entry. */
|
|
606
|
+
delete(dictionaryId: number, entryId: number, options?: {
|
|
607
|
+
projectId?: number;
|
|
608
|
+
}): Promise<void>;
|
|
609
|
+
/**
|
|
610
|
+
* Replace every entry in the dictionary atomically.
|
|
611
|
+
*
|
|
612
|
+
* Each item must have ``word`` and ``replacement``; existing entries
|
|
613
|
+
* whose ``word`` is not in the supplied list are deleted. Idempotent.
|
|
614
|
+
*/
|
|
615
|
+
replaceAll(dictionaryId: number, entries: DictionaryEntryInput[], options?: {
|
|
616
|
+
projectId?: number;
|
|
617
|
+
}): Promise<BulkReplaceResult>;
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Resource for managing per-project custom dictionaries.
|
|
621
|
+
*/
|
|
622
|
+
declare class DictionariesResource {
|
|
623
|
+
private client;
|
|
624
|
+
/** Per-entry operations within a dictionary. */
|
|
625
|
+
readonly entries: DictionaryEntriesResource;
|
|
626
|
+
constructor(client: KugelAudio);
|
|
627
|
+
/** List every dictionary in the caller's project. */
|
|
628
|
+
list(options?: {
|
|
629
|
+
projectId?: number;
|
|
630
|
+
}): Promise<Dictionary[]>;
|
|
631
|
+
/** Create a new dictionary scoped to the caller's project. */
|
|
632
|
+
create(body: CreateDictionaryOptions, options?: {
|
|
633
|
+
projectId?: number;
|
|
634
|
+
}): Promise<Dictionary>;
|
|
635
|
+
/** Fetch a single dictionary. */
|
|
636
|
+
get(dictionaryId: number, options?: {
|
|
637
|
+
projectId?: number;
|
|
638
|
+
}): Promise<Dictionary>;
|
|
639
|
+
/** Update name / description / language / isActive. */
|
|
640
|
+
update(dictionaryId: number, updates: UpdateDictionaryOptions, options?: {
|
|
641
|
+
projectId?: number;
|
|
642
|
+
}): Promise<Dictionary>;
|
|
643
|
+
/** Delete a dictionary (cascades to its entries). */
|
|
644
|
+
delete(dictionaryId: number, options?: {
|
|
645
|
+
projectId?: number;
|
|
646
|
+
}): Promise<void>;
|
|
647
|
+
}
|
|
648
|
+
|
|
485
649
|
/**
|
|
486
650
|
* Models resource for listing TTS models.
|
|
487
651
|
*/
|
|
@@ -929,6 +1093,8 @@ declare class KugelAudio {
|
|
|
929
1093
|
readonly models: ModelsResource;
|
|
930
1094
|
/** Voices resource */
|
|
931
1095
|
readonly voices: VoicesResource;
|
|
1096
|
+
/** Custom dictionaries resource */
|
|
1097
|
+
readonly dictionaries: DictionariesResource;
|
|
932
1098
|
/** TTS resource */
|
|
933
1099
|
readonly tts: TTSResource;
|
|
934
1100
|
constructor(options: KugelAudioOptions);
|
|
@@ -1005,7 +1171,7 @@ declare class KugelAudio {
|
|
|
1005
1171
|
*
|
|
1006
1172
|
* All SDK errors inherit from {@link KugelAudioError}. Specific subclasses
|
|
1007
1173
|
* map to the server's `error_code` field (see the server-side `ErrorCode`
|
|
1008
|
-
* enum at `
|
|
1174
|
+
* enum at `engine/src/serving/deployments/errors.py`) so callers can
|
|
1009
1175
|
* `instanceof AuthenticationError` without matching on message text.
|
|
1010
1176
|
*/
|
|
1011
1177
|
declare const ErrorCodes: {
|
|
@@ -1073,6 +1239,17 @@ declare class ValidationError extends KugelAudioError {
|
|
|
1073
1239
|
declare class ConnectionError extends KugelAudioError {
|
|
1074
1240
|
constructor(message: string, options?: KugelAudioErrorOptions);
|
|
1075
1241
|
}
|
|
1242
|
+
/**
|
|
1243
|
+
* A referenced resource doesn't exist or isn't visible to the caller.
|
|
1244
|
+
*
|
|
1245
|
+
* Surfaced when the server returns HTTP 404 with `error_code = NOT_FOUND` —
|
|
1246
|
+
* e.g. an unknown `voiceId`, a voice that belongs to another org, or a
|
|
1247
|
+
* deleted resource. Distinct from {@link ValidationError} (malformed
|
|
1248
|
+
* request) so callers can show "not found" UX without parsing messages.
|
|
1249
|
+
*/
|
|
1250
|
+
declare class NotFoundError extends KugelAudioError {
|
|
1251
|
+
constructor(message?: string, options?: KugelAudioErrorOptions);
|
|
1252
|
+
}
|
|
1076
1253
|
interface HttpResponseLike {
|
|
1077
1254
|
status: number;
|
|
1078
1255
|
headers: {
|
|
@@ -1133,4 +1310,4 @@ declare function createWavFile(audio: ArrayBuffer, sampleRate: number): ArrayBuf
|
|
|
1133
1310
|
*/
|
|
1134
1311
|
declare function createWavBlob(audio: ArrayBuffer, sampleRate: number): Blob;
|
|
1135
1312
|
|
|
1136
|
-
export { type AudioChunk, type AudioResponse, AuthenticationError, ConnectionError, type ContextVoiceSettings, type CreateVoiceOptions, type ErrorCode, ErrorCodes, type GenerateOptions, type GenerationStats, InsufficientCreditsError, KugelAudio, KugelAudioError, type KugelAudioErrorOptions, type KugelAudioOptions, type Model, type MultiContextAudioChunk, type MultiContextCallbacks, type MultiContextConfig, RateLimitError, type Region, type StreamCallbacks, type StreamConfig, type StreamingSessionCallbacks, type UpdateVoiceOptions, ValidationError, type Voice, type VoiceAge, type VoiceCategory, type VoiceDetail, type VoiceListResponse, type VoiceQuality, type VoiceReference, type VoiceSex, type WordTimestamp, WsCloseCodes, base64ToArrayBuffer, classifyHttpError, classifyWsClose, classifyWsFrame, classifyWsHandshakeError, createWavBlob, createWavFile, decodePCM16 };
|
|
1313
|
+
export { type AudioChunk, type AudioResponse, AuthenticationError, type BulkReplaceResult, ConnectionError, type ContextVoiceSettings, type CreateDictionaryOptions, type CreateVoiceOptions, DictionariesResource, type Dictionary, DictionaryEntriesResource, type DictionaryEntry, type DictionaryEntryInput, type DictionaryEntryListResponse, type ErrorCode, ErrorCodes, type GenerateOptions, type GenerationStats, InsufficientCreditsError, KugelAudio, KugelAudioError, type KugelAudioErrorOptions, type KugelAudioOptions, type Model, type MultiContextAudioChunk, type MultiContextCallbacks, type MultiContextConfig, NotFoundError, RateLimitError, type Region, type StreamCallbacks, type StreamConfig, type StreamingSessionCallbacks, type UpdateDictionaryEntryOptions, type UpdateDictionaryOptions, type UpdateVoiceOptions, ValidationError, type Voice, type VoiceAge, type VoiceCategory, type VoiceDetail, type VoiceListResponse, type VoiceQuality, type VoiceReference, type VoiceSex, type WordTimestamp, WsCloseCodes, base64ToArrayBuffer, classifyHttpError, classifyWsClose, classifyWsFrame, classifyWsHandshakeError, createWavBlob, createWavFile, decodePCM16 };
|
package/dist/index.d.ts
CHANGED
|
@@ -54,6 +54,84 @@ interface VoiceListResponse {
|
|
|
54
54
|
* Voice quality levels.
|
|
55
55
|
*/
|
|
56
56
|
type VoiceQuality = 'low' | 'mid' | 'high';
|
|
57
|
+
/**
|
|
58
|
+
* A per-project pronunciation dictionary.
|
|
59
|
+
*/
|
|
60
|
+
interface Dictionary {
|
|
61
|
+
id: number;
|
|
62
|
+
projectId: number;
|
|
63
|
+
name: string;
|
|
64
|
+
description?: string;
|
|
65
|
+
language?: string;
|
|
66
|
+
isActive: boolean;
|
|
67
|
+
createdAt: string;
|
|
68
|
+
updatedAt: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A single word → replacement / IPA mapping within a dictionary.
|
|
72
|
+
*/
|
|
73
|
+
interface DictionaryEntry {
|
|
74
|
+
id: number;
|
|
75
|
+
dictionaryId: number;
|
|
76
|
+
word: string;
|
|
77
|
+
replacement: string;
|
|
78
|
+
ipa?: string;
|
|
79
|
+
caseSensitive: boolean;
|
|
80
|
+
createdAt: string;
|
|
81
|
+
updatedAt: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Paginated response from listing entries.
|
|
85
|
+
*/
|
|
86
|
+
interface DictionaryEntryListResponse {
|
|
87
|
+
entries: DictionaryEntry[];
|
|
88
|
+
total: number;
|
|
89
|
+
limit: number;
|
|
90
|
+
offset: number;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Counts returned by `entries.replaceAll`.
|
|
94
|
+
*/
|
|
95
|
+
interface BulkReplaceResult {
|
|
96
|
+
upserted: number;
|
|
97
|
+
deleted: number;
|
|
98
|
+
total: number;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Options for creating a dictionary.
|
|
102
|
+
*/
|
|
103
|
+
interface CreateDictionaryOptions {
|
|
104
|
+
name: string;
|
|
105
|
+
description?: string;
|
|
106
|
+
language?: string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Options for updating a dictionary. Only provided fields are changed.
|
|
110
|
+
*/
|
|
111
|
+
interface UpdateDictionaryOptions {
|
|
112
|
+
name?: string;
|
|
113
|
+
description?: string;
|
|
114
|
+
language?: string;
|
|
115
|
+
isActive?: boolean;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Payload for creating or replacing a single entry.
|
|
119
|
+
*/
|
|
120
|
+
interface DictionaryEntryInput {
|
|
121
|
+
word: string;
|
|
122
|
+
replacement: string;
|
|
123
|
+
ipa?: string;
|
|
124
|
+
caseSensitive?: boolean;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Options for updating an entry.
|
|
128
|
+
*/
|
|
129
|
+
interface UpdateDictionaryEntryOptions {
|
|
130
|
+
word?: string;
|
|
131
|
+
replacement?: string;
|
|
132
|
+
ipa?: string;
|
|
133
|
+
caseSensitive?: boolean;
|
|
134
|
+
}
|
|
57
135
|
/**
|
|
58
136
|
* Extended voice information returned by voice management endpoints.
|
|
59
137
|
*/
|
|
@@ -482,6 +560,92 @@ interface MultiContextCallbacks {
|
|
|
482
560
|
onError?: (error: Error, contextId?: string) => void;
|
|
483
561
|
}
|
|
484
562
|
|
|
563
|
+
/**
|
|
564
|
+
* Resources for managing per-project custom word dictionaries.
|
|
565
|
+
*
|
|
566
|
+
* @example
|
|
567
|
+
* ```typescript
|
|
568
|
+
* const dict = await client.dictionaries.create({ name: 'Brand names' });
|
|
569
|
+
* await client.dictionaries.entries.add(dict.id, {
|
|
570
|
+
* word: 'Postgres',
|
|
571
|
+
* replacement: 'post-gres',
|
|
572
|
+
* });
|
|
573
|
+
*
|
|
574
|
+
* // Sync from an external source — atomic, idempotent
|
|
575
|
+
* await client.dictionaries.entries.replaceAll(dict.id, [
|
|
576
|
+
* { word: 'Postgres', replacement: 'post-gres' },
|
|
577
|
+
* { word: 'Kubernetes', replacement: 'koo-ber-net-eez' },
|
|
578
|
+
* ]);
|
|
579
|
+
* ```
|
|
580
|
+
*/
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* Resource for entries within a single dictionary.
|
|
584
|
+
* Access via ``client.dictionaries.entries`` and pass ``dictionaryId``
|
|
585
|
+
* to each call.
|
|
586
|
+
*/
|
|
587
|
+
declare class DictionaryEntriesResource {
|
|
588
|
+
private client;
|
|
589
|
+
constructor(client: KugelAudio);
|
|
590
|
+
/** List entries with optional search + pagination. */
|
|
591
|
+
list(dictionaryId: number, options?: {
|
|
592
|
+
search?: string;
|
|
593
|
+
limit?: number;
|
|
594
|
+
offset?: number;
|
|
595
|
+
projectId?: number;
|
|
596
|
+
}): Promise<DictionaryEntryListResponse>;
|
|
597
|
+
/** Add a single entry to a dictionary. */
|
|
598
|
+
add(dictionaryId: number, entry: DictionaryEntryInput, options?: {
|
|
599
|
+
projectId?: number;
|
|
600
|
+
}): Promise<DictionaryEntry>;
|
|
601
|
+
/** Update an existing entry. */
|
|
602
|
+
update(dictionaryId: number, entryId: number, updates: UpdateDictionaryEntryOptions, options?: {
|
|
603
|
+
projectId?: number;
|
|
604
|
+
}): Promise<DictionaryEntry>;
|
|
605
|
+
/** Delete a single entry. */
|
|
606
|
+
delete(dictionaryId: number, entryId: number, options?: {
|
|
607
|
+
projectId?: number;
|
|
608
|
+
}): Promise<void>;
|
|
609
|
+
/**
|
|
610
|
+
* Replace every entry in the dictionary atomically.
|
|
611
|
+
*
|
|
612
|
+
* Each item must have ``word`` and ``replacement``; existing entries
|
|
613
|
+
* whose ``word`` is not in the supplied list are deleted. Idempotent.
|
|
614
|
+
*/
|
|
615
|
+
replaceAll(dictionaryId: number, entries: DictionaryEntryInput[], options?: {
|
|
616
|
+
projectId?: number;
|
|
617
|
+
}): Promise<BulkReplaceResult>;
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Resource for managing per-project custom dictionaries.
|
|
621
|
+
*/
|
|
622
|
+
declare class DictionariesResource {
|
|
623
|
+
private client;
|
|
624
|
+
/** Per-entry operations within a dictionary. */
|
|
625
|
+
readonly entries: DictionaryEntriesResource;
|
|
626
|
+
constructor(client: KugelAudio);
|
|
627
|
+
/** List every dictionary in the caller's project. */
|
|
628
|
+
list(options?: {
|
|
629
|
+
projectId?: number;
|
|
630
|
+
}): Promise<Dictionary[]>;
|
|
631
|
+
/** Create a new dictionary scoped to the caller's project. */
|
|
632
|
+
create(body: CreateDictionaryOptions, options?: {
|
|
633
|
+
projectId?: number;
|
|
634
|
+
}): Promise<Dictionary>;
|
|
635
|
+
/** Fetch a single dictionary. */
|
|
636
|
+
get(dictionaryId: number, options?: {
|
|
637
|
+
projectId?: number;
|
|
638
|
+
}): Promise<Dictionary>;
|
|
639
|
+
/** Update name / description / language / isActive. */
|
|
640
|
+
update(dictionaryId: number, updates: UpdateDictionaryOptions, options?: {
|
|
641
|
+
projectId?: number;
|
|
642
|
+
}): Promise<Dictionary>;
|
|
643
|
+
/** Delete a dictionary (cascades to its entries). */
|
|
644
|
+
delete(dictionaryId: number, options?: {
|
|
645
|
+
projectId?: number;
|
|
646
|
+
}): Promise<void>;
|
|
647
|
+
}
|
|
648
|
+
|
|
485
649
|
/**
|
|
486
650
|
* Models resource for listing TTS models.
|
|
487
651
|
*/
|
|
@@ -929,6 +1093,8 @@ declare class KugelAudio {
|
|
|
929
1093
|
readonly models: ModelsResource;
|
|
930
1094
|
/** Voices resource */
|
|
931
1095
|
readonly voices: VoicesResource;
|
|
1096
|
+
/** Custom dictionaries resource */
|
|
1097
|
+
readonly dictionaries: DictionariesResource;
|
|
932
1098
|
/** TTS resource */
|
|
933
1099
|
readonly tts: TTSResource;
|
|
934
1100
|
constructor(options: KugelAudioOptions);
|
|
@@ -1005,7 +1171,7 @@ declare class KugelAudio {
|
|
|
1005
1171
|
*
|
|
1006
1172
|
* All SDK errors inherit from {@link KugelAudioError}. Specific subclasses
|
|
1007
1173
|
* map to the server's `error_code` field (see the server-side `ErrorCode`
|
|
1008
|
-
* enum at `
|
|
1174
|
+
* enum at `engine/src/serving/deployments/errors.py`) so callers can
|
|
1009
1175
|
* `instanceof AuthenticationError` without matching on message text.
|
|
1010
1176
|
*/
|
|
1011
1177
|
declare const ErrorCodes: {
|
|
@@ -1073,6 +1239,17 @@ declare class ValidationError extends KugelAudioError {
|
|
|
1073
1239
|
declare class ConnectionError extends KugelAudioError {
|
|
1074
1240
|
constructor(message: string, options?: KugelAudioErrorOptions);
|
|
1075
1241
|
}
|
|
1242
|
+
/**
|
|
1243
|
+
* A referenced resource doesn't exist or isn't visible to the caller.
|
|
1244
|
+
*
|
|
1245
|
+
* Surfaced when the server returns HTTP 404 with `error_code = NOT_FOUND` —
|
|
1246
|
+
* e.g. an unknown `voiceId`, a voice that belongs to another org, or a
|
|
1247
|
+
* deleted resource. Distinct from {@link ValidationError} (malformed
|
|
1248
|
+
* request) so callers can show "not found" UX without parsing messages.
|
|
1249
|
+
*/
|
|
1250
|
+
declare class NotFoundError extends KugelAudioError {
|
|
1251
|
+
constructor(message?: string, options?: KugelAudioErrorOptions);
|
|
1252
|
+
}
|
|
1076
1253
|
interface HttpResponseLike {
|
|
1077
1254
|
status: number;
|
|
1078
1255
|
headers: {
|
|
@@ -1133,4 +1310,4 @@ declare function createWavFile(audio: ArrayBuffer, sampleRate: number): ArrayBuf
|
|
|
1133
1310
|
*/
|
|
1134
1311
|
declare function createWavBlob(audio: ArrayBuffer, sampleRate: number): Blob;
|
|
1135
1312
|
|
|
1136
|
-
export { type AudioChunk, type AudioResponse, AuthenticationError, ConnectionError, type ContextVoiceSettings, type CreateVoiceOptions, type ErrorCode, ErrorCodes, type GenerateOptions, type GenerationStats, InsufficientCreditsError, KugelAudio, KugelAudioError, type KugelAudioErrorOptions, type KugelAudioOptions, type Model, type MultiContextAudioChunk, type MultiContextCallbacks, type MultiContextConfig, RateLimitError, type Region, type StreamCallbacks, type StreamConfig, type StreamingSessionCallbacks, type UpdateVoiceOptions, ValidationError, type Voice, type VoiceAge, type VoiceCategory, type VoiceDetail, type VoiceListResponse, type VoiceQuality, type VoiceReference, type VoiceSex, type WordTimestamp, WsCloseCodes, base64ToArrayBuffer, classifyHttpError, classifyWsClose, classifyWsFrame, classifyWsHandshakeError, createWavBlob, createWavFile, decodePCM16 };
|
|
1313
|
+
export { type AudioChunk, type AudioResponse, AuthenticationError, type BulkReplaceResult, ConnectionError, type ContextVoiceSettings, type CreateDictionaryOptions, type CreateVoiceOptions, DictionariesResource, type Dictionary, DictionaryEntriesResource, type DictionaryEntry, type DictionaryEntryInput, type DictionaryEntryListResponse, type ErrorCode, ErrorCodes, type GenerateOptions, type GenerationStats, InsufficientCreditsError, KugelAudio, KugelAudioError, type KugelAudioErrorOptions, type KugelAudioOptions, type Model, type MultiContextAudioChunk, type MultiContextCallbacks, type MultiContextConfig, NotFoundError, RateLimitError, type Region, type StreamCallbacks, type StreamConfig, type StreamingSessionCallbacks, type UpdateDictionaryEntryOptions, type UpdateDictionaryOptions, type UpdateVoiceOptions, ValidationError, type Voice, type VoiceAge, type VoiceCategory, type VoiceDetail, type VoiceListResponse, type VoiceQuality, type VoiceReference, type VoiceSex, type WordTimestamp, WsCloseCodes, base64ToArrayBuffer, classifyHttpError, classifyWsClose, classifyWsFrame, classifyWsHandshakeError, createWavBlob, createWavFile, decodePCM16 };
|