@vocalstack/js-sdk 2.0.0-alpha.3 → 2.0.0-alpha.4

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
@@ -53,7 +53,7 @@ npm install @vocalstack/js-sdk
53
53
  | recording | one take inside a broadcast or a transcription | `vs.recordings` |
54
54
  | job | a file or link recording's transcription work | `vs.jobs` |
55
55
 
56
- The other groups: `vs.corrections`, `vs.shareLinks`, `vs.voices`,
56
+ The other groups: `vs.corrections`, `vs.shareLinks`, `vs.speakers`, `vs.voices`,
57
57
  `vs.search`, `vs.me`, `vs.languages`, `vs.rtmp`, `vs.events`, `vs.meta`.
58
58
  Method names follow the document's `operationId`s (`broadcasts.startRecording`
59
59
  is `POST /v1/broadcasts/{id}/recordings`); lists return arrays.
@@ -127,7 +127,7 @@ Browser microphone capture ships as `@vocalstack/js-sdk/mic`
127
127
  ## Binary answers
128
128
 
129
129
  `recordings.export`, `recordings.clip`, `recordings.voiceClip`, `jobs.preview`,
130
- `voices.preview`, `voices.clonePreview` and `voices.sample` return the
130
+ `voices.preview`, `speakers.voicePreview` and `speakers.sample` return the
131
131
  `Response` itself: `.text()`, `.arrayBuffer()` or stream it.
132
132
  `recordings.audioUrl` returns the signed media URL.
133
133
 
package/SKILL.md CHANGED
@@ -223,7 +223,7 @@ try {
223
223
  - The other groups: `vs.transcriptions` (`list`, `get`, `update`, `archive`,
224
224
  `restore`, `purge`, `listShareLinks`, `createShareLink`), `vs.recordings`
225
225
  (`get`, `summarize`, `summary`, `translation`, `audioUrl`, `subscribe` for a
226
- live transcript feed), `vs.corrections`, `vs.shareLinks`, `vs.voices`,
226
+ live transcript feed), `vs.corrections`, `vs.shareLinks`, `vs.speakers`, `vs.voices`,
227
227
  `vs.broadcasts`, `vs.me` (`get`, `usage`), `vs.languages`,
228
228
  `vs.rtmp`, `vs.events`, `vs.meta`. Each method is named after its operation
229
229
  in the OpenAPI document (`transcriptions.create` is `POST /v1/transcriptions`).
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { type ClientOptions } from './http.js';
2
2
  import { Realtime } from './realtime.js';
3
- import { Billing, Broadcasts, Connect, Corrections, Events, Jobs, Languages, MeApi, Meta, Recordings, Rtmp, Search, ShareLinks, Tags, Transcriptions, Voices } from './resources.js';
3
+ import { Billing, Broadcasts, Connect, Corrections, Events, Jobs, Languages, MeApi, Meta, Recordings, Rtmp, Search, ShareLinks, Speakers, Tags, Transcriptions, Voices } from './resources.js';
4
4
  export type { ClientOptions, CallOptions, ReadAs, Query } from './http.js';
5
5
  export { DEFAULT_BASE_URL } from './http.js';
6
6
  export { VocalStackError } from './errors.js';
@@ -13,7 +13,7 @@ export type { ConnectOptions, TranscribeOptions, RealtimeTranscript } from './re
13
13
  export { Subscription } from './subscription.js';
14
14
  export type { SubscribeOptions, SubscriptionEvent } from './subscription.js';
15
15
  export type { WsLike } from './ws.js';
16
- export { Broadcasts, Connect, Corrections, Events, Jobs, Languages, MeApi, Meta, Recordings, Rtmp, Search, ShareLinks, Tags, Transcriptions, Voices, playableFormat, } from './resources.js';
16
+ export { Broadcasts, Connect, Corrections, Events, Jobs, Languages, MeApi, Meta, Recordings, Rtmp, Search, ShareLinks, Speakers, Tags, Transcriptions, Voices, playableFormat, } from './resources.js';
17
17
  export type { AudioKind, MediaAuth, MediaFormat, RenderVoice, VoicesChoice } from './resources.js';
18
18
  export type { ConnectToken, ConnectTokenInput, CreateTranscriptionInput, LifecycleFilter, Me, PageOptions, RecordingPageOptions, SearchOptions, TranscriptionFilters, Upload, UsageChargesOptions, UsageOptions } from './resources.js';
19
19
  export type * from '@vocalstack/contract';
@@ -28,6 +28,7 @@ export declare class VocalStack {
28
28
  readonly corrections: Corrections;
29
29
  readonly shareLinks: ShareLinks;
30
30
  readonly tags: Tags;
31
+ readonly speakers: Speakers;
31
32
  readonly voices: Voices;
32
33
  readonly search: Search;
33
34
  readonly me: MeApi;
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { Transport } from './http.js';
2
2
  import { Realtime } from './realtime.js';
3
- import { Billing, Broadcasts, Connect, Corrections, Events, Jobs, Languages, MeApi, Meta, Recordings, Rtmp, Search, ShareLinks, Tags, Transcriptions, Voices, } from './resources.js';
3
+ import { Billing, Broadcasts, Connect, Corrections, Events, Jobs, Languages, MeApi, Meta, Recordings, Rtmp, Search, ShareLinks, Speakers, Tags, Transcriptions, Voices, } from './resources.js';
4
4
  export { DEFAULT_BASE_URL } from './http.js';
5
5
  export { VocalStackError } from './errors.js';
6
6
  export { RealtimeSession } from './realtime.js';
7
7
  export { Realtime, applySentence } from './realtime.js';
8
8
  export { Subscription } from './subscription.js';
9
- export { Broadcasts, Connect, Corrections, Events, Jobs, Languages, MeApi, Meta, Recordings, Rtmp, Search, ShareLinks, Tags, Transcriptions, Voices, playableFormat, } from './resources.js';
9
+ export { Broadcasts, Connect, Corrections, Events, Jobs, Languages, MeApi, Meta, Recordings, Rtmp, Search, ShareLinks, Speakers, Tags, Transcriptions, Voices, playableFormat, } from './resources.js';
10
10
  export class VocalStack {
11
11
  baseUrl;
12
12
  realtime;
@@ -17,6 +17,7 @@ export class VocalStack {
17
17
  corrections;
18
18
  shareLinks;
19
19
  tags;
20
+ speakers;
20
21
  voices;
21
22
  search;
22
23
  me;
@@ -37,6 +38,7 @@ export class VocalStack {
37
38
  this.corrections = new Corrections(t);
38
39
  this.shareLinks = new ShareLinks(t);
39
40
  this.tags = new Tags(t);
41
+ this.speakers = new Speakers(t);
40
42
  this.voices = new Voices(t);
41
43
  this.search = new Search(t);
42
44
  this.me = new MeApi(t);
@@ -1,4 +1,4 @@
1
- import type { AppStreamKey, AudioSourceCheck, AutoTopUpSettings, AutoTopUpView, BillingDetails, BillingView, CheckPromoCode, CheckoutView, CreateCheckout, LowBalanceAlertSettings, LowBalanceAlertView, PaymentDocument, PaymentMethodList, PaymentPage, PortalLink, PromoCodeView, SetInterval, SubscriptionView, YearlyOptIn, UsageChargePage, UsageReport, Broadcast, Correction, CorrectionBatch, CorrectionPage, CreateAppStreamKey, CreateAudioSource, CreateLiveTranscription, CreateBroadcast, CreateShareLink, CreateTag, CreateTranscription, CreateVoiceFromSpeaker, CreatedAppStreamKey, ChargePage, ExportFormat, ClientApp, ClientPolicy, Health, LanguageLists, LedgerPage, LinkProbe, PatchVoice, PlanList, PublishGrant, Recording, RecordingEvent, RecordingEvents, RecordingPage, RetranscribeLine, RtmpStatus, SearchResults, VectorResults, SettingsPatch, ShareLink, SharedTranscript, StartRecording, StartJob, SummaryStatus, Tag, TagTranscriptions, Transcription, TranscriptionJob, TranscriptionPage, TranscriptSnapshot, UpdateBroadcast, UpdateTag, UpdateTranscription, UpdateShareLink, UploadRecording, Voice, VoiceCatalogue, VoiceTrack, ManyResult } from '@vocalstack/contract';
1
+ import type { AppStreamKey, AudioSourceCheck, AutoTopUpSettings, AutoTopUpView, BillingDetails, BillingView, CheckPromoCode, CheckoutView, CreateCheckout, LowBalanceAlertSettings, LowBalanceAlertView, PaymentDocument, PaymentMethodList, PaymentPage, PortalLink, PromoCodeView, SetInterval, SubscriptionView, YearlyOptIn, UsageChargePage, UsageReport, Broadcast, Correction, CorrectionBatch, CorrectionPage, CreateAppStreamKey, CreateAudioSource, CreateLiveTranscription, CreateBroadcast, CreateShareLink, CreateTag, CreateTranscription, CreateSpeaker, CreateSpeakerFromAppearance, CreatedAppStreamKey, ChargePage, ExportFormat, ClientApp, ClientPolicy, Health, LanguageLists, LedgerPage, LinkProbe, PatchSpeaker, PlanList, PublishGrant, Recording, RecordingEvent, RecordingEvents, RecordingPage, RetranscribeLine, RtmpStatus, SearchResults, VectorResults, SettingsPatch, ShareLink, SharedTranscript, StartRecording, StartJob, SummaryStatus, Tag, TagTranscriptions, Transcription, TranscriptionJob, TranscriptionPage, TranscriptSnapshot, UpdateBroadcast, UpdateTag, UpdateTranscription, UpdateShareLink, UploadRecording, Speaker, VoiceCatalogue, VoiceTrack, ManyResult } from '@vocalstack/contract';
2
2
  import { Transport, type CallOptions, type ReadAs } from './http.js';
3
3
  import { RealtimeSession, type ConnectOptions } from './realtime.js';
4
4
  import { Subscription, type SubscribeOptions } from './subscription.js';
@@ -72,6 +72,7 @@ export declare class Transcriptions extends ParentResource<Transcription, Update
72
72
  probe(url: string): Promise<LinkProbe>;
73
73
  attachBroadcast(id: string, broadcastId: string): Promise<Transcription>;
74
74
  detachBroadcast(id: string, broadcastId: string): Promise<Transcription>;
75
+ nameAppearance(id: string, appearance: number, name: string | null): Promise<void>;
75
76
  }
76
77
  export declare class Recordings {
77
78
  #private;
@@ -146,7 +147,6 @@ export declare class Recordings {
146
147
  token: string;
147
148
  expiresAt: string;
148
149
  }>;
149
- nameSpeaker(id: string, speaker: number, name: string | null): Promise<void>;
150
150
  events(id: string, opts?: {
151
151
  after?: number;
152
152
  limit?: number;
@@ -213,33 +213,39 @@ export declare class Tags {
213
213
  delete(id: string): Promise<void>;
214
214
  tagTranscriptions(id: string, req: TagTranscriptions): Promise<Tag>;
215
215
  }
216
- export declare class Voices {
216
+ export declare class Speakers {
217
217
  #private;
218
218
  constructor(t: Transport);
219
219
  list(opts?: {
220
220
  lifecycle?: 'active' | 'archived';
221
- }): Promise<Voice[]>;
222
- get(id: string): Promise<Voice>;
223
- archive(id: string): Promise<Voice>;
224
- restore(id: string): Promise<Voice>;
221
+ }): Promise<Speaker[]>;
222
+ get(id: string): Promise<Speaker>;
223
+ archive(id: string): Promise<Speaker>;
224
+ restore(id: string): Promise<Speaker>;
225
225
  archiveMany(ids: string[]): Promise<ManyResult>;
226
226
  restoreMany(ids: string[]): Promise<ManyResult>;
227
227
  deleteMany(ids: string[]): Promise<ManyResult>;
228
- create(req: {
229
- name: string;
228
+ create(req: CreateSpeaker & {
230
229
  sample?: Upload;
231
- sampleUrl?: string;
232
230
  fileName?: string;
233
- gender?: 'male' | 'female';
234
- color?: string;
235
- draft?: boolean;
236
- }, call?: CallOptions): Promise<Voice>;
237
- createFromSpeaker(req: Omit<CreateVoiceFromSpeaker, 'consent'>, call?: CallOptions): Promise<Voice>;
231
+ }, call?: CallOptions): Promise<Speaker>;
232
+ createFromAppearance(req: CreateSpeakerFromAppearance, call?: CallOptions): Promise<Speaker>;
238
233
  setConsent(id: string, consent: 'granted' | 'refused', opts?: {
239
234
  name?: string;
240
- }): Promise<Voice>;
241
- update(id: string, patch: PatchVoice): Promise<Voice>;
235
+ }): Promise<Speaker>;
236
+ update(id: string, patch: PatchSpeaker): Promise<Speaker>;
242
237
  delete(id: string): Promise<void>;
238
+ voicePreview(id: string, opts?: {
239
+ lang?: string;
240
+ format?: 'ogg' | 'caf';
241
+ recording?: string;
242
+ asOwner?: boolean;
243
+ } & ReadAs): Promise<Response>;
244
+ sample(id: string): Promise<Response>;
245
+ }
246
+ export declare class Voices {
247
+ #private;
248
+ constructor(t: Transport);
243
249
  available(lang: string, opts?: {
244
250
  recording?: string;
245
251
  asOwner?: boolean;
@@ -247,13 +253,6 @@ export declare class Voices {
247
253
  preview(voice: string, lang: string, opts?: {
248
254
  format?: 'ogg' | 'caf';
249
255
  }): Promise<Response>;
250
- clonePreview(id: string, opts?: {
251
- lang?: string;
252
- format?: 'ogg' | 'caf';
253
- recording?: string;
254
- asOwner?: boolean;
255
- } & ReadAs): Promise<Response>;
256
- sample(id: string): Promise<Response>;
257
256
  }
258
257
  export interface SearchOptions extends Omit<TranscriptionFilters, 'lifecycle' | 'q' | 'broadcast'> {
259
258
  broadcasts?: string[];
package/dist/resources.js CHANGED
@@ -152,6 +152,9 @@ export class Transcriptions extends ParentResource {
152
152
  detachBroadcast(id, broadcastId) {
153
153
  return this.t.json('DELETE', this.p(id, `/broadcasts/${seg(broadcastId)}`));
154
154
  }
155
+ async nameAppearance(id, appearance, name) {
156
+ await this.t.json('PUT', this.p(id, `/appearances/${seg(appearance)}`), { body: { name } });
157
+ }
155
158
  }
156
159
  export class Recordings {
157
160
  #t;
@@ -278,9 +281,6 @@ export class Recordings {
278
281
  mediaToken(id) {
279
282
  return this.#t.json('GET', this.#p(id, '/media-token'));
280
283
  }
281
- async nameSpeaker(id, speaker, name) {
282
- await this.#t.json('PUT', this.#p(id, `/speakers/${seg(speaker)}`), { body: { name } });
283
- }
284
284
  events(id, opts = {}) {
285
285
  return allPages(async (cursor) => {
286
286
  const r = await this.eventsPage(id, cursor ? { cursor, limit: opts.limit } : { after: opts.after, limit: opts.limit });
@@ -417,54 +417,70 @@ export class Tags {
417
417
  return this.#t.json('POST', `/v1/tags/${seg(id)}/transcriptions`, { body: req });
418
418
  }
419
419
  }
420
- export class Voices {
420
+ export class Speakers {
421
421
  #t;
422
422
  constructor(t) {
423
423
  this.#t = t;
424
424
  }
425
425
  async list(opts = {}) {
426
- const r = await this.#t.json('GET', '/v1/voices', { query: { lifecycle: opts.lifecycle } });
427
- return r.voices ?? [];
426
+ const r = await this.#t.json('GET', '/v1/speakers', { query: { lifecycle: opts.lifecycle } });
427
+ return r.speakers ?? [];
428
428
  }
429
429
  get(id) {
430
- return this.#t.json('GET', `/v1/voices/${seg(id)}`);
430
+ return this.#t.json('GET', `/v1/speakers/${seg(id)}`);
431
431
  }
432
432
  archive(id) {
433
- return this.#t.json('POST', `/v1/voices/${seg(id)}/archive`);
433
+ return this.#t.json('POST', `/v1/speakers/${seg(id)}/archive`);
434
434
  }
435
435
  restore(id) {
436
- return this.#t.json('POST', `/v1/voices/${seg(id)}/restore`);
436
+ return this.#t.json('POST', `/v1/speakers/${seg(id)}/restore`);
437
437
  }
438
438
  archiveMany(ids) {
439
- return this.#t.json('POST', '/v1/voices/archive', { body: { ids } });
439
+ return this.#t.json('POST', '/v1/speakers/archive', { body: { ids } });
440
440
  }
441
441
  restoreMany(ids) {
442
- return this.#t.json('POST', '/v1/voices/restore', { body: { ids } });
442
+ return this.#t.json('POST', '/v1/speakers/restore', { body: { ids } });
443
443
  }
444
444
  deleteMany(ids) {
445
- return this.#t.json('POST', '/v1/voices/delete', { body: { ids } });
445
+ return this.#t.json('POST', '/v1/speakers/delete', { body: { ids } });
446
446
  }
447
447
  async create(req, call = {}) {
448
448
  const { sample, fileName, ...meta } = req;
449
449
  const form = new FormData();
450
- form.append('meta', JSON.stringify({ consent: !meta.draft, ...meta }));
450
+ form.append('meta', JSON.stringify(meta));
451
451
  if (sample !== undefined) {
452
452
  const { blob, name } = await toBlob(sample);
453
453
  form.append('sample', blob, fileName ?? name ?? 'sample.webm');
454
454
  }
455
- return this.#t.json('POST', '/v1/voices', { body: form, ...call });
455
+ return this.#t.json('POST', '/v1/speakers', { body: form, ...call });
456
456
  }
457
- createFromSpeaker(req, call = {}) {
458
- return this.#t.json('POST', '/v1/voices/from-speaker', { body: { consent: true, ...req }, ...call });
457
+ createFromAppearance(req, call = {}) {
458
+ return this.#t.json('POST', '/v1/speakers/from-appearance', { body: req, ...call });
459
459
  }
460
460
  setConsent(id, consent, opts = {}) {
461
- return this.#t.json('POST', `/v1/voices/${seg(id)}/consent`, { body: { consent, ...opts } });
461
+ return this.#t.json('POST', `/v1/speakers/${seg(id)}/consent`, { body: { consent, ...opts } });
462
462
  }
463
463
  update(id, patch) {
464
- return this.#t.json('PATCH', `/v1/voices/${seg(id)}`, { body: patch });
464
+ return this.#t.json('PATCH', `/v1/speakers/${seg(id)}`, { body: patch });
465
465
  }
466
466
  async delete(id) {
467
- await this.#t.json('DELETE', `/v1/voices/${seg(id)}`);
467
+ await this.#t.json('DELETE', `/v1/speakers/${seg(id)}`);
468
+ }
469
+ voicePreview(id, opts = {}) {
470
+ return this.#t.raw('GET', `/v1/speakers/${seg(id)}/preview`, {
471
+ headers: { accept: '*/*' },
472
+ query: { ...listenerQuery(opts), lang: opts.lang, format: opts.format, recording: opts.recording },
473
+ anonymous: opts.asOwner === false,
474
+ });
475
+ }
476
+ sample(id) {
477
+ return this.#t.raw('GET', `/v1/speakers/${seg(id)}/sample`, { headers: { accept: '*/*' } });
478
+ }
479
+ }
480
+ export class Voices {
481
+ #t;
482
+ constructor(t) {
483
+ this.#t = t;
468
484
  }
469
485
  available(lang, opts = {}) {
470
486
  return this.#t.json('GET', '/v1/voices/available', {
@@ -475,16 +491,6 @@ export class Voices {
475
491
  preview(voice, lang, opts = {}) {
476
492
  return this.#t.raw('GET', '/v1/voices/preview', { headers: { accept: '*/*' }, query: { voice, lang, format: opts.format } });
477
493
  }
478
- clonePreview(id, opts = {}) {
479
- return this.#t.raw('GET', `/v1/voices/${seg(id)}/preview`, {
480
- headers: { accept: '*/*' },
481
- query: { ...listenerQuery(opts), lang: opts.lang, format: opts.format, recording: opts.recording },
482
- anonymous: opts.asOwner === false,
483
- });
484
- }
485
- sample(id) {
486
- return this.#t.raw('GET', `/v1/voices/${seg(id)}/sample`, { headers: { accept: '*/*' } });
487
- }
488
494
  }
489
495
  export class Search {
490
496
  #t;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vocalstack/js-sdk",
3
- "version": "2.0.0-alpha.3",
3
+ "version": "2.0.0-alpha.4",
4
4
  "description": "VocalStack speech API SDK for Node and browsers: one client (VocalStack) grouped by resource, typed from the generated contract, with realtime WebSocket streaming.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -29,7 +29,7 @@
29
29
  "test": "node --test test/*.test.mjs"
30
30
  },
31
31
  "dependencies": {
32
- "@vocalstack/contract": "1.0.0-alpha.3",
32
+ "@vocalstack/contract": "1.0.0-alpha.4",
33
33
  "ws": "^8.18.0"
34
34
  },
35
35
  "devDependencies": {
@@ -223,7 +223,7 @@ try {
223
223
  - The other groups: `vs.transcriptions` (`list`, `get`, `update`, `archive`,
224
224
  `restore`, `purge`, `listShareLinks`, `createShareLink`), `vs.recordings`
225
225
  (`get`, `summarize`, `summary`, `translation`, `audioUrl`, `subscribe` for a
226
- live transcript feed), `vs.corrections`, `vs.shareLinks`, `vs.voices`,
226
+ live transcript feed), `vs.corrections`, `vs.shareLinks`, `vs.speakers`, `vs.voices`,
227
227
  `vs.broadcasts`, `vs.me` (`get`, `usage`), `vs.languages`,
228
228
  `vs.rtmp`, `vs.events`, `vs.meta`. Each method is named after its operation
229
229
  in the OpenAPI document (`transcriptions.create` is `POST /v1/transcriptions`).