audixa 1.0.0 → 2.0.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 CHANGED
@@ -47,7 +47,7 @@ const audixa = new Audixa('your-api-key');
47
47
  // Generate TTS and wait for completion
48
48
  const audioUrl = await audixa.generateTTS({
49
49
  text: 'Hello! This is a test of the Audixa text-to-speech API.',
50
- voice: 'en-US-female-1',
50
+ voice_id: 'emma',
51
51
  model: 'base'
52
52
  });
53
53
 
@@ -61,10 +61,9 @@ const { Audixa } = require('audixa');
61
61
 
62
62
  const audixa = new Audixa('your-api-key');
63
63
 
64
- // Generate TTS and wait for completion
65
64
  audixa.generateTTS({
66
65
  text: 'Hello! This is a test of the Audixa text-to-speech API.',
67
- voice: 'en-US-female-1',
66
+ voice_id: 'emma',
68
67
  model: 'base'
69
68
  }).then(audioUrl => {
70
69
  console.log('Audio URL:', audioUrl);
@@ -80,7 +79,7 @@ const audixa = new Audixa('your-api-key');
80
79
 
81
80
  const audioUrl = await audixa.generateTTS({
82
81
  text: 'Hello! This is a test of the Audixa text-to-speech API.',
83
- voice: 'en-US-female-1'
82
+ voice_id: 'emma'
84
83
  });
85
84
 
86
85
  console.log('Audio URL:', audioUrl);
@@ -92,8 +91,9 @@ console.log('Audio URL:', audioUrl);
92
91
  import Audixa from 'audixa';
93
92
 
94
93
  const audixa = new Audixa('your-api-key', {
95
- baseUrl: 'https://api.audixa.ai/v2', // Custom API base URL (optional)
96
- timeout: 30000 // Request timeout in ms (default: 30000)
94
+ baseUrl: 'https://api.audixa.ai/v3', // Custom API base URL (optional)
95
+ timeout: 30000, // Request timeout in ms (default: 30000)
96
+ customEndpointSlug: 'client1' // Optional default custom endpoint
97
97
  });
98
98
  ```
99
99
 
@@ -101,26 +101,26 @@ const audixa = new Audixa('your-api-key', {
101
101
 
102
102
  ### Start TTS Generation
103
103
 
104
- Creates a new text-to-speech task and returns a generation ID.
104
+ Creates a new text-to-speech task and returns the generation details.
105
105
 
106
106
  ```typescript
107
- const { generation_id } = await audixa.startTTS({
107
+ const result = await audixa.startTTS({
108
108
  // Required parameters
109
109
  text: 'Your text here (minimum 30 characters)',
110
- voice: 'en-US-female-1',
110
+ voice_id: 'emma',
111
111
 
112
112
  // Optional parameters
113
- model: 'base', // 'base' or 'advance'
113
+ model: 'base', // 'base' or 'advanced'
114
114
  speed: 1.0, // 0.5 to 2.0
115
+ audio_format: 'mp3', // 'wav' or 'mp3'
115
116
 
116
- // Advance model only
117
- emotion: 'happy', // 'neutral', 'happy', 'sad', 'angry', 'surprised'
118
- temperature: 0.8, // 0.7 to 0.9
119
- top_p: 0.9, // 0.7 to 0.98
120
- do_sample: true
117
+ // Advanced model only
118
+ cfg_weight: 2.5, // 1.0 to 5.0
119
+ exaggeration: 0.5 // 0.0 to 1.0
121
120
  });
122
121
 
123
- console.log('Generation ID:', generation_id);
122
+ console.log('Generation ID:', result.generation_id);
123
+ console.log('Status:', result.status);
124
124
  ```
125
125
 
126
126
  ### Poll TTS Status
@@ -130,27 +130,27 @@ Check the status of a TTS generation job.
130
130
  ```typescript
131
131
  const status = await audixa.getStatus(generation_id);
132
132
 
133
- console.log('Status:', status.status); // 'Generating', 'Completed', or 'Failed'
134
- console.log('Audio URL:', status.audio_url); // Available when status is 'Completed'
133
+ console.log('Status:', status.status); // 'IN_QUEUE', 'GENERATING', 'COMPLETED', 'FAILED'
134
+ console.log('Audio URL:', status.audio_url); // Available when status is 'COMPLETED'
135
135
  ```
136
136
 
137
137
  ### Complete Polling Example
138
138
 
139
139
  ```typescript
140
- async function generateAndWait(text: string, voice: string): Promise<string> {
140
+ async function generateAndWait(text: string, voiceId: string): Promise<string> {
141
141
  // Start generation
142
- const { generation_id } = await audixa.startTTS({ text, voice });
142
+ const { generation_id } = await audixa.startTTS({ text, voice_id: voiceId });
143
143
 
144
144
  // Poll until complete
145
145
  while (true) {
146
146
  const status = await audixa.getStatus(generation_id);
147
147
 
148
- if (status.status === 'Completed') {
148
+ if (status.status === 'COMPLETED') {
149
149
  return status.audio_url!;
150
150
  }
151
151
 
152
- if (status.status === 'Failed') {
153
- throw new Error('TTS generation failed');
152
+ if (status.status === 'FAILED') {
153
+ throw new Error(status.error_message || 'TTS generation failed');
154
154
  }
155
155
 
156
156
  // Wait 1 second before polling again
@@ -163,27 +163,71 @@ Or use the convenience method:
163
163
 
164
164
  ```typescript
165
165
  const audioUrl = await audixa.generateTTS(
166
- { text: 'Your text here', voice: 'en-US-female-1' },
166
+ { text: 'Your text here', voice_id: 'emma' },
167
167
  { pollInterval: 1000, maxWaitTime: 60000 }
168
168
  );
169
169
  ```
170
170
 
171
171
  ### Get Available Voices
172
172
 
173
- Retrieve the list of available voices for a specific model.
173
+ Retrieve the list of available voices.
174
174
 
175
175
  ```typescript
176
- const { voices } = await audixa.getVoices('base');
176
+ const { voices, limit, offset, length } = await audixa.getVoices({
177
+ model: 'base',
178
+ limit: 100,
179
+ offset: 0
180
+ });
177
181
 
178
182
  for (const voice of voices) {
179
183
  console.log(`${voice.name} (${voice.voice_id})`);
184
+ console.log(` Model: ${voice.model}`);
180
185
  console.log(` Gender: ${voice.gender}`);
181
186
  console.log(` Accent: ${voice.accent}`);
182
187
  console.log(` Free: ${voice.free}`);
183
- console.log(` Description: ${voice.description}`);
188
+ console.log(` Custom: ${voice.is_custom}`);
184
189
  }
185
190
  ```
186
191
 
192
+ ### Get Generation History
193
+
194
+ Retrieve your recent generation history.
195
+
196
+ ```typescript
197
+ const history = await audixa.getHistory({
198
+ limit: 20,
199
+ offset: 0,
200
+ status: 'COMPLETED'
201
+ });
202
+
203
+ console.log('History length:', history.length);
204
+ ```
205
+
206
+ ### Custom Endpoints
207
+
208
+ Use a dedicated endpoint slug for enterprise routing. You can set a default slug on the client or provide it per request.
209
+
210
+ ```typescript
211
+ const audixa = new Audixa('your-api-key', {
212
+ customEndpointSlug: 'client1'
213
+ });
214
+
215
+ // Uses /v3/custom/client1/tts
216
+ const result = await audixa.startTTS({
217
+ text: 'Hello from a custom endpoint',
218
+ voice_id: 'emma'
219
+ });
220
+ ```
221
+
222
+ Per-request override:
223
+
224
+ ```typescript
225
+ const result = await audixa.startTTS(
226
+ { text: 'Hello', voice_id: 'emma' },
227
+ { customEndpointSlug: 'client2' }
228
+ );
229
+ ```
230
+
187
231
  ## Error Handling
188
232
 
189
233
  The SDK provides a custom `AudixaError` class for comprehensive error handling:
@@ -196,7 +240,7 @@ const audixa = new Audixa('your-api-key');
196
240
  try {
197
241
  const result = await audixa.startTTS({
198
242
  text: 'Hello world',
199
- voice: 'en-US-female-1'
243
+ voice_id: 'emma'
200
244
  });
201
245
  } catch (error) {
202
246
  if (error instanceof AudixaError) {
@@ -215,7 +259,10 @@ try {
215
259
  console.log('Please check your request parameters');
216
260
  break;
217
261
  case 'FORBIDDEN':
218
- console.log('You do not have access to this voice');
262
+ console.log('You do not have access to this resource');
263
+ break;
264
+ case 'RATE_LIMITED':
265
+ console.log('Too many requests');
219
266
  break;
220
267
  case 'TIMEOUT':
221
268
  console.log('The request timed out');
@@ -237,6 +284,7 @@ try {
237
284
  | `INSUFFICIENT_CREDITS` | 402 | Not enough credits in account |
238
285
  | `FORBIDDEN` | 403 | Access denied to resource |
239
286
  | `NOT_FOUND` | 404 | Resource not found |
287
+ | `RATE_LIMITED` | 429 | Rate limit exceeded |
240
288
  | `TIMEOUT` | - | Request timed out |
241
289
  | `NETWORK_ERROR` | - | Network connectivity issue |
242
290
 
@@ -252,7 +300,7 @@ setTimeout(() => controller.abort(), 5000);
252
300
 
253
301
  try {
254
302
  const result = await audixa.startTTS(
255
- { text: 'Hello world', voice: 'en-US-female-1' },
303
+ { text: 'Hello world', voice_id: 'emma' },
256
304
  { signal: controller.signal }
257
305
  );
258
306
  } catch (error) {
@@ -276,14 +324,21 @@ import Audixa, {
276
324
  StartTTSRequest,
277
325
  StartTTSResponse,
278
326
  TTSStatusResponse,
327
+ TTSResponse,
279
328
  TTSModel,
280
- TTSEmotion,
281
329
  TTSStatus,
330
+ TTSHistoryStatus,
331
+ TTSAudioFormat,
282
332
 
283
333
  // Voice types
284
334
  GetVoicesResponse,
335
+ VoicesResponse,
285
336
  Voice,
286
337
 
338
+ // History types
339
+ HistoryResponse,
340
+ HistoryItem,
341
+
287
342
  // Error types
288
343
  AudixaError,
289
344
  AudixaErrorCode
@@ -295,33 +350,32 @@ import Audixa, {
295
350
  ```typescript
296
351
  // TTS Request
297
352
  interface StartTTSRequest {
298
- text: string; // Required, min 30 chars
299
- voice: string; // Required
300
- model?: 'base' | 'advance';
301
- speed?: number; // 0.5 - 2.0
302
-
303
- // Advance model only
304
- emotion?: 'neutral' | 'happy' | 'sad' | 'angry' | 'surprised';
305
- temperature?: number; // 0.7 - 0.9
306
- top_p?: number; // 0.7 - 0.98
307
- do_sample?: boolean;
353
+ text: string;
354
+ voice_id: string;
355
+ model?: 'base' | 'advanced';
356
+ speed?: number;
357
+ cfg_weight?: number;
358
+ exaggeration?: number;
359
+ audio_format?: 'wav' | 'mp3';
308
360
  }
309
361
 
310
- // TTS Status Response
311
- interface TTSStatusResponse {
312
- status: 'Generating' | 'Completed' | 'Failed';
313
- audio_url: string | null;
314
- generation_id?: string;
362
+ // TTS Response
363
+ interface TTSResponse {
364
+ generation_id: string;
365
+ status: 'IN_QUEUE' | 'GENERATING' | 'COMPLETED' | 'FAILED';
366
+ audio_url?: string | null;
367
+ error_message?: string | null;
315
368
  }
316
369
 
317
370
  // Voice
318
371
  interface Voice {
319
372
  voice_id: string;
320
373
  name: string;
321
- gender: string;
322
- accent: string;
374
+ model: 'base' | 'advanced';
375
+ gender?: string;
376
+ accent?: string;
323
377
  free: boolean;
324
- description: string;
378
+ is_custom: boolean;
325
379
  }
326
380
  ```
327
381
 
@@ -340,3 +394,4 @@ MIT © [anurag-pro](https://github.com/anurag-pro)
340
394
  - [API Documentation](https://docs.audixa.ai)
341
395
  - [GitHub Repository](https://github.com/AudixaAI/audixa-npm-sdk)
342
396
  - [npm Package](https://www.npmjs.com/package/audixa)
397
+ # audixa-npm-package