kugelaudio 0.2.3 → 0.3.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 +37 -13
- package/dist/index.d.mts +518 -26
- package/dist/index.d.ts +518 -26
- package/dist/index.js +864 -112
- package/dist/index.mjs +858 -112
- package/package.json +9 -8
- package/src/client.test.ts +548 -0
- package/src/client.ts +885 -103
- package/src/errors.ts +266 -18
- package/src/index.ts +17 -2
- package/src/types.ts +215 -8
- package/src/websocket.ts +38 -18
package/README.md
CHANGED
|
@@ -57,6 +57,33 @@ const client = new KugelAudio({
|
|
|
57
57
|
});
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
+
### Region Selection
|
|
61
|
+
|
|
62
|
+
KugelAudio is available in multiple regions. The default is EU.
|
|
63
|
+
|
|
64
|
+
| Region | Endpoint |
|
|
65
|
+
|--------|----------|
|
|
66
|
+
| `eu` | `api.kugelaudio.com` (default) |
|
|
67
|
+
| `us` | `us-api.kugelaudio.com` |
|
|
68
|
+
| `global` | `global-api.kugelaudio.com` (geo-routed) |
|
|
69
|
+
|
|
70
|
+
**Option 1 — API key prefix** (simplest, works with env vars):
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
const client = new KugelAudio({ apiKey: 'us-ka_your_api_key' }); // → US
|
|
74
|
+
const client = new KugelAudio({ apiKey: 'global-ka_your_api_key' }); // → Global
|
|
75
|
+
const client = new KugelAudio({ apiKey: 'eu-ka_your_api_key' }); // → EU (explicit)
|
|
76
|
+
const client = new KugelAudio({ apiKey: 'ka_your_api_key' }); // → EU (default)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Option 2 — `region` parameter**:
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
const client = new KugelAudio({ apiKey: 'ka_your_api_key', region: 'us' });
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
The prefix is always stripped before authentication. Priority: `apiUrl` > `region` > key prefix > default (EU).
|
|
86
|
+
|
|
60
87
|
### Single URL Architecture
|
|
61
88
|
|
|
62
89
|
The SDK uses a **single URL** for both REST API and WebSocket streaming. The TTS server provides both REST endpoints (`/v1/models`, `/v1/voices`) and WebSocket (`/ws/tts`) - no proxy needed, minimal latency.
|
|
@@ -84,10 +111,10 @@ const client = new KugelAudio({
|
|
|
84
111
|
|
|
85
112
|
## Available Models
|
|
86
113
|
|
|
87
|
-
| Model ID | Name |
|
|
88
|
-
|
|
89
|
-
| `kugel-1-turbo` | Kugel 1 Turbo |
|
|
90
|
-
| `kugel-1` | Kugel 1 |
|
|
114
|
+
| Model ID | Name | Description |
|
|
115
|
+
|----------|------|-------------|
|
|
116
|
+
| `kugel-1-turbo` | Kugel 1 Turbo | Fast, low-latency model for real-time applications |
|
|
117
|
+
| `kugel-1` | Kugel 1 | Premium quality model for pre-recorded content |
|
|
91
118
|
|
|
92
119
|
### List Available Models
|
|
93
120
|
|
|
@@ -97,7 +124,6 @@ const models = await client.models.list();
|
|
|
97
124
|
for (const model of models) {
|
|
98
125
|
console.log(`${model.id}: ${model.name}`);
|
|
99
126
|
console.log(` Description: ${model.description}`);
|
|
100
|
-
console.log(` Parameters: ${model.parameters}`);
|
|
101
127
|
console.log(` Max Input: ${model.maxInputLength} characters`);
|
|
102
128
|
console.log(` Sample Rate: ${model.sampleRate} Hz`);
|
|
103
129
|
}
|
|
@@ -213,7 +239,6 @@ await client.tts.stream(
|
|
|
213
239
|
},
|
|
214
240
|
onFinal: (stats) => {
|
|
215
241
|
console.log(`Total duration: ${stats.durationMs}ms`);
|
|
216
|
-
console.log(`Time to first audio: ${stats.ttfaMs}ms`);
|
|
217
242
|
console.log(`Generation time: ${stats.generationMs}ms`);
|
|
218
243
|
console.log(`RTF: ${stats.rtf}`);
|
|
219
244
|
},
|
|
@@ -336,10 +361,11 @@ try {
|
|
|
336
361
|
|
|
337
362
|
```typescript
|
|
338
363
|
interface KugelAudioOptions {
|
|
339
|
-
apiKey: string;
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
364
|
+
apiKey: string; // Required (can be prefixed with 'eu-', 'us-', or 'global-')
|
|
365
|
+
region?: Region; // 'eu' | 'us' | 'global' (default: 'eu')
|
|
366
|
+
apiUrl?: string; // Default: determined by region
|
|
367
|
+
ttsUrl?: string; // Default: same as apiUrl
|
|
368
|
+
timeout?: number; // Default: 60000 (ms)
|
|
343
369
|
}
|
|
344
370
|
```
|
|
345
371
|
|
|
@@ -394,7 +420,6 @@ interface GenerationStats {
|
|
|
394
420
|
totalSamples: number; // Total samples generated
|
|
395
421
|
durationMs: number; // Audio duration in ms
|
|
396
422
|
generationMs: number; // Generation time in ms
|
|
397
|
-
ttfaMs: number; // Time to first audio in ms
|
|
398
423
|
rtf: number; // Real-time factor
|
|
399
424
|
}
|
|
400
425
|
```
|
|
@@ -418,7 +443,6 @@ interface Model {
|
|
|
418
443
|
id: string; // 'kugel-1-turbo' or 'kugel-1'
|
|
419
444
|
name: string; // Human-readable name
|
|
420
445
|
description: string; // Model description
|
|
421
|
-
parameters: string; // Parameter count ('1.5B', '7B')
|
|
422
446
|
maxInputLength: number; // Maximum input characters
|
|
423
447
|
sampleRate: number; // Output sample rate
|
|
424
448
|
}
|
|
@@ -499,7 +523,7 @@ async function main() {
|
|
|
499
523
|
console.log('Available Models:');
|
|
500
524
|
const models = await client.models.list();
|
|
501
525
|
for (const model of models) {
|
|
502
|
-
console.log(` - ${model.id}: ${model.name}
|
|
526
|
+
console.log(` - ${model.id}: ${model.name}`);
|
|
503
527
|
}
|
|
504
528
|
|
|
505
529
|
// List available voices
|