@breeze.blue/sdk 0.12.0 → 0.14.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 +15 -0
- package/README.md +20 -1
- package/dist/audio.d.ts +1 -0
- package/dist/audio.js +2 -0
- package/dist/client.d.ts +15 -3
- package/dist/client.js +19 -3
- package/dist/types.d.ts +26 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.14.0
|
|
4
|
+
|
|
5
|
+
- Added `account.currentApiKey()` for checking the authenticating key's status
|
|
6
|
+
and current Key Budget counters before starting work.
|
|
7
|
+
|
|
8
|
+
## 0.13.0
|
|
9
|
+
|
|
10
|
+
- `voices.random(...)` accepts optional `languageCode` and `voiceType`
|
|
11
|
+
(`"default"` or `"personal"`) filters that narrow the random pool.
|
|
12
|
+
- Added `voices.streamDesignPreview(...)`, which returns a live
|
|
13
|
+
`AudioResponse` with `generatedVoiceId`; the Node `stream()` helper consumes
|
|
14
|
+
its response body directly.
|
|
15
|
+
- Clarified that `voices.streamPreview(...)` downloads an already completed
|
|
16
|
+
preview.
|
|
17
|
+
|
|
3
18
|
## 0.12.0
|
|
4
19
|
|
|
5
20
|
- Voice listings preserve the `created_at_unix desc` default and support the
|
package/README.md
CHANGED
|
@@ -425,6 +425,8 @@ const settings = await client.voices.getSettings(firstVoiceId);
|
|
|
425
425
|
|
|
426
426
|
const randomVoice = await client.voices.random();
|
|
427
427
|
console.log(randomVoice.voiceId, randomVoice.name);
|
|
428
|
+
// Narrow the random pool by language and/or voice source.
|
|
429
|
+
const randomCatalogVoice = await client.voices.random({ languageCode: "zh", voiceType: "default" });
|
|
428
430
|
|
|
429
431
|
// Discover the current code-only Voice Metadata contract before building a form.
|
|
430
432
|
const metadataOptions = await client.voices.metadataOptions();
|
|
@@ -463,9 +465,24 @@ const design = await client.voices.createDesignPreview({
|
|
|
463
465
|
generatedVoiceId = design.previews[0].generatedVoiceId;
|
|
464
466
|
```
|
|
465
467
|
|
|
468
|
+
For the fastest first audio, generate one design preview as a live 24 kHz mono
|
|
469
|
+
PCM response. The Node `stream()` helper consumes the response body directly;
|
|
470
|
+
a clean end means `generatedVoiceId` is ready to save:
|
|
471
|
+
|
|
472
|
+
```ts
|
|
473
|
+
import { stream } from "@breeze.blue/sdk/node";
|
|
474
|
+
|
|
475
|
+
const livePreview = await client.voices.streamDesignPreview({
|
|
476
|
+
voiceDescription: "Warm documentary narrator with clear articulation.",
|
|
477
|
+
text: "This is a short preview script.",
|
|
478
|
+
});
|
|
479
|
+
await stream(livePreview);
|
|
480
|
+
generatedVoiceId = livePreview.generatedVoiceId!;
|
|
481
|
+
```
|
|
482
|
+
|
|
466
483
|
`files` is also accepted with exactly one item.
|
|
467
484
|
|
|
468
|
-
|
|
485
|
+
Download a completed preview so the user can audition it, then save the one they
|
|
469
486
|
pick:
|
|
470
487
|
|
|
471
488
|
```ts
|
|
@@ -513,6 +530,8 @@ language-to-accent cascade at runtime.
|
|
|
513
530
|
```ts
|
|
514
531
|
const models = await client.models.list();
|
|
515
532
|
const balance = await client.account.balance();
|
|
533
|
+
const currentKey = (await client.account.currentApiKey()).apiKey;
|
|
534
|
+
console.log(currentKey.status, currentKey.creditRemaining);
|
|
516
535
|
const usage = await client.account.usage({ days: 7 });
|
|
517
536
|
const keyUsage = await client.account.usage({
|
|
518
537
|
apiKeyId: "key_01hprod",
|
package/dist/audio.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export declare class AudioResponse {
|
|
|
34
34
|
readonly response: Response;
|
|
35
35
|
readonly contentType: string;
|
|
36
36
|
readonly historyItemId: string | null;
|
|
37
|
+
readonly generatedVoiceId: string | null;
|
|
37
38
|
readonly filename: string | null;
|
|
38
39
|
constructor(response: Response, options?: AudioResponseOptions);
|
|
39
40
|
get headers(): Headers;
|
package/dist/audio.js
CHANGED
|
@@ -2,12 +2,14 @@ export class AudioResponse {
|
|
|
2
2
|
response;
|
|
3
3
|
contentType;
|
|
4
4
|
historyItemId;
|
|
5
|
+
generatedVoiceId;
|
|
5
6
|
filename;
|
|
6
7
|
#buffer = null;
|
|
7
8
|
constructor(response, options = {}) {
|
|
8
9
|
this.response = response;
|
|
9
10
|
this.contentType = response.headers.get("content-type")?.split(";", 1)[0].trim() || "application/octet-stream";
|
|
10
11
|
this.historyItemId = response.headers.get("history-item-id");
|
|
12
|
+
this.generatedVoiceId = response.headers.get("generated-voice-id");
|
|
11
13
|
this.filename = options.filename ?? filenameFromContentDisposition(response.headers.get("content-disposition"));
|
|
12
14
|
}
|
|
13
15
|
get headers() {
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AudioResponse } from "./audio.js";
|
|
2
|
-
import type { AudioRequestOptions, BreezeBlueWebSocket, AsyncTextToSpeechJob, Balance, BreezeBlueClientOptions, GenericStatus, GenerationJob, HistoryItem, HistoryList, HistoryListParams, Model, RequestOptions, RealtimeTextToSpeechConnectOptions, RealtimeTextToSpeechEvent, RealtimeTextToSpeechManagedConnectOptions, RealtimeTextToSpeechMessage, RealtimeTextToSpeechSession, RealtimeTextToSpeechSessionRequest, SavedVoice, SaveVoiceRequest, StreamTextToSpeechOptions, TextToSpeechRequest, TtsEnhanceRequest, TtsEnhanceResponse, Usage, UsageParams, Voice, VoiceClonePreview, VoiceClonePreviewRequest, VoiceDesignRequest, VoiceDesignResponse, VoiceEditRequest, VoiceList, VoiceMetadataOptions, VoiceSearchParams, VoiceSettings } from "./types.js";
|
|
2
|
+
import type { AudioRequestOptions, BreezeBlueWebSocket, AsyncTextToSpeechJob, Balance, BreezeBlueClientOptions, CurrentApiKeyResponse, GenericStatus, GenerationJob, HistoryItem, HistoryList, HistoryListParams, Model, RequestOptions, RealtimeTextToSpeechConnectOptions, RealtimeTextToSpeechEvent, RealtimeTextToSpeechManagedConnectOptions, RealtimeTextToSpeechMessage, RealtimeTextToSpeechSession, RealtimeTextToSpeechSessionRequest, SavedVoice, SaveVoiceRequest, StreamTextToSpeechOptions, TextToSpeechRequest, TtsEnhanceRequest, TtsEnhanceResponse, Usage, UsageParams, Voice, VoiceClonePreview, VoiceClonePreviewRequest, VoiceDesignRequest, VoiceDesignResponse, VoiceDesignStreamRequest, VoiceEditRequest, VoiceList, VoiceMetadataOptions, VoiceRandomParams, VoiceSearchParams, VoiceSettings } from "./types.js";
|
|
3
3
|
export declare class BreezeBlueClient {
|
|
4
4
|
readonly apiKey: string | undefined;
|
|
5
5
|
readonly baseUrl: string;
|
|
@@ -213,7 +213,12 @@ declare class VoicesResource {
|
|
|
213
213
|
*/
|
|
214
214
|
search(params?: VoiceSearchParams, options?: RequestOptions): Promise<VoiceList>;
|
|
215
215
|
get(voiceId: string, options?: RequestOptions): Promise<Voice>;
|
|
216
|
-
|
|
216
|
+
/**
|
|
217
|
+
* Pick one random voice visible to the account. Pass `languageCode` and/or
|
|
218
|
+
* `voiceType` to narrow the pool; with no filters the pool is personal
|
|
219
|
+
* voices plus the public catalog.
|
|
220
|
+
*/
|
|
221
|
+
random(params?: VoiceRandomParams, options?: RequestOptions): Promise<Voice>;
|
|
217
222
|
/** Return stable Voice Metadata codes and language-accent constraints. */
|
|
218
223
|
metadataOptions(options?: RequestOptions): Promise<VoiceMetadataOptions>;
|
|
219
224
|
edit(voiceId: string, request: VoiceEditRequest, options?: RequestOptions): Promise<GenericStatus>;
|
|
@@ -235,7 +240,12 @@ declare class VoicesResource {
|
|
|
235
240
|
* {@link savePreview}.
|
|
236
241
|
*/
|
|
237
242
|
createDesignPreview(request: VoiceDesignRequest, options?: AudioRequestOptions): Promise<VoiceDesignResponse>;
|
|
238
|
-
/**
|
|
243
|
+
/**
|
|
244
|
+
* Generate exactly one voice design preview as live 24 kHz mono PCM.
|
|
245
|
+
* A clean end means `generatedVoiceId` is ready for {@link savePreview}.
|
|
246
|
+
*/
|
|
247
|
+
streamDesignPreview(request: VoiceDesignStreamRequest, options?: RequestOptions): Promise<AudioResponse>;
|
|
248
|
+
/** Download the completed audio of a clone or design preview. */
|
|
239
249
|
streamPreview(generatedVoiceId: string, options?: AudioRequestOptions): Promise<AudioResponse>;
|
|
240
250
|
/** Persist a clone or design preview as a real voice asset. */
|
|
241
251
|
savePreview(request: SaveVoiceRequest, options?: RequestOptions): Promise<SavedVoice>;
|
|
@@ -257,6 +267,8 @@ declare class AccountResource {
|
|
|
257
267
|
private readonly client;
|
|
258
268
|
constructor(client: BreezeBlueClient);
|
|
259
269
|
balance(options?: RequestOptions): Promise<Balance>;
|
|
270
|
+
/** Return the authenticating API key and its current Key Budget counters. */
|
|
271
|
+
currentApiKey(options?: RequestOptions): Promise<CurrentApiKeyResponse>;
|
|
260
272
|
usage(params?: UsageParams, options?: RequestOptions): Promise<Usage>;
|
|
261
273
|
}
|
|
262
274
|
export {};
|
package/dist/client.js
CHANGED
|
@@ -1506,8 +1506,13 @@ class VoicesResource {
|
|
|
1506
1506
|
const result = await this.client.requestJson("GET", `/v1/voices/${encodeURIComponent(voiceId)}`, undefined, undefined, options);
|
|
1507
1507
|
return stripHiddenVoiceFields(result);
|
|
1508
1508
|
}
|
|
1509
|
-
|
|
1510
|
-
|
|
1509
|
+
/**
|
|
1510
|
+
* Pick one random voice visible to the account. Pass `languageCode` and/or
|
|
1511
|
+
* `voiceType` to narrow the pool; with no filters the pool is personal
|
|
1512
|
+
* voices plus the public catalog.
|
|
1513
|
+
*/
|
|
1514
|
+
async random(params = {}, options) {
|
|
1515
|
+
const result = await this.client.requestJson("GET", "/v1/voices/random", params, undefined, options);
|
|
1511
1516
|
return stripHiddenVoiceFields(result);
|
|
1512
1517
|
}
|
|
1513
1518
|
/** Return stable Voice Metadata codes and language-accent constraints. */
|
|
@@ -1556,7 +1561,14 @@ class VoicesResource {
|
|
|
1556
1561
|
createDesignPreview(request, options = {}) {
|
|
1557
1562
|
return this.client.requestJson("POST", "/v1/voice-previews/design", { outputFormat: options.outputFormat }, request, options);
|
|
1558
1563
|
}
|
|
1559
|
-
/**
|
|
1564
|
+
/**
|
|
1565
|
+
* Generate exactly one voice design preview as live 24 kHz mono PCM.
|
|
1566
|
+
* A clean end means `generatedVoiceId` is ready for {@link savePreview}.
|
|
1567
|
+
*/
|
|
1568
|
+
streamDesignPreview(request, options) {
|
|
1569
|
+
return this.client.requestAudio("POST", "/v1/voice-previews/design/stream", undefined, request, options);
|
|
1570
|
+
}
|
|
1571
|
+
/** Download the completed audio of a clone or design preview. */
|
|
1560
1572
|
streamPreview(generatedVoiceId, options = {}) {
|
|
1561
1573
|
return this.client.requestAudio("GET", `/v1/voice-previews/${encodeURIComponent(generatedVoiceId)}/stream`, { outputFormat: options.outputFormat }, undefined, options);
|
|
1562
1574
|
}
|
|
@@ -1613,6 +1625,10 @@ class AccountResource {
|
|
|
1613
1625
|
balance(options) {
|
|
1614
1626
|
return this.client.requestJson("GET", "/v1/balance", undefined, undefined, options);
|
|
1615
1627
|
}
|
|
1628
|
+
/** Return the authenticating API key and its current Key Budget counters. */
|
|
1629
|
+
currentApiKey(options) {
|
|
1630
|
+
return this.client.requestJson("GET", "/v1/api-keys/current", undefined, undefined, options);
|
|
1631
|
+
}
|
|
1616
1632
|
usage(params = {}, options) {
|
|
1617
1633
|
return this.client.requestJson("GET", "/v1/usage", params, undefined, options);
|
|
1618
1634
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -351,6 +351,12 @@ export interface VoiceMetadataOptions {
|
|
|
351
351
|
toneMaxItems: number;
|
|
352
352
|
accentCodesByLanguage: Record<VoiceLanguageCode, VoiceAccent[]>;
|
|
353
353
|
}
|
|
354
|
+
export interface VoiceRandomParams {
|
|
355
|
+
/** Only pick from voices whose saved audio language matches this code. */
|
|
356
|
+
languageCode?: VoiceLanguageCode;
|
|
357
|
+
/** Voice source filter. Omit to pick from personal voices and the public catalog. */
|
|
358
|
+
voiceType?: "default" | "personal" | string;
|
|
359
|
+
}
|
|
354
360
|
export interface VoiceSearchParams {
|
|
355
361
|
search?: string;
|
|
356
362
|
languageCode?: VoiceLanguageCode;
|
|
@@ -418,6 +424,13 @@ export interface VoiceDesignRequest {
|
|
|
418
424
|
guidanceScale?: number | null;
|
|
419
425
|
previewCount?: number;
|
|
420
426
|
}
|
|
427
|
+
export interface VoiceDesignStreamRequest {
|
|
428
|
+
voiceDescription: string;
|
|
429
|
+
text?: string;
|
|
430
|
+
modelId?: string;
|
|
431
|
+
languageCode?: VoiceLanguageCode;
|
|
432
|
+
guidanceScale?: number | null;
|
|
433
|
+
}
|
|
421
434
|
export interface VoiceDesignPreview {
|
|
422
435
|
generatedVoiceId: string;
|
|
423
436
|
audioBase64: string;
|
|
@@ -495,6 +508,19 @@ export interface Balance {
|
|
|
495
508
|
topups: BalanceTopup[];
|
|
496
509
|
[key: string]: unknown;
|
|
497
510
|
}
|
|
511
|
+
export interface CurrentApiKey {
|
|
512
|
+
id: string;
|
|
513
|
+
name: string;
|
|
514
|
+
prefix: string;
|
|
515
|
+
status: string;
|
|
516
|
+
creditLimit?: number | null;
|
|
517
|
+
creditUsed?: number;
|
|
518
|
+
creditReserved?: number;
|
|
519
|
+
creditRemaining?: number | null;
|
|
520
|
+
}
|
|
521
|
+
export interface CurrentApiKeyResponse {
|
|
522
|
+
apiKey: CurrentApiKey;
|
|
523
|
+
}
|
|
498
524
|
export interface UsageSummary {
|
|
499
525
|
requestCount: number;
|
|
500
526
|
totalTextCharacters: number;
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.14.0";
|
|
2
2
|
export declare const SDK_NAME = "@breeze.blue/sdk";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.
|
|
1
|
+
export const SDK_VERSION = "0.14.0";
|
|
2
2
|
export const SDK_NAME = "@breeze.blue/sdk";
|