@vocalstack/js-sdk 1.0.12

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.
Files changed (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +89 -0
  3. package/dist/RestApi.d.ts +21 -0
  4. package/dist/RestApi.js +93 -0
  5. package/dist/VocalStackApi.d.ts +19 -0
  6. package/dist/VocalStackApi.js +50 -0
  7. package/dist/WebsocketApi.d.ts +38 -0
  8. package/dist/WebsocketApi.js +156 -0
  9. package/dist/apis/Billing.d.ts +59 -0
  10. package/dist/apis/Billing.js +21 -0
  11. package/dist/apis/LiveTranscription.d.ts +58 -0
  12. package/dist/apis/LiveTranscription.js +55 -0
  13. package/dist/apis/Polyglot.d.ts +113 -0
  14. package/dist/apis/Polyglot.js +68 -0
  15. package/dist/apis/Security.d.ts +25 -0
  16. package/dist/apis/Security.js +35 -0
  17. package/dist/apis/Transcriptions.d.ts +61 -0
  18. package/dist/apis/Transcriptions.js +43 -0
  19. package/dist/apis/UrlTranscription.d.ts +59 -0
  20. package/dist/apis/UrlTranscription.js +53 -0
  21. package/dist/apis/index.d.ts +6 -0
  22. package/dist/apis/index.js +22 -0
  23. package/dist/esm/RestApi.d.ts +21 -0
  24. package/dist/esm/RestApi.js +89 -0
  25. package/dist/esm/VocalStackApi.d.ts +19 -0
  26. package/dist/esm/VocalStackApi.js +46 -0
  27. package/dist/esm/WebsocketApi.d.ts +38 -0
  28. package/dist/esm/WebsocketApi.js +146 -0
  29. package/dist/esm/apis/Billing.d.ts +59 -0
  30. package/dist/esm/apis/Billing.js +17 -0
  31. package/dist/esm/apis/LiveTranscription.d.ts +58 -0
  32. package/dist/esm/apis/LiveTranscription.js +51 -0
  33. package/dist/esm/apis/Polyglot.d.ts +113 -0
  34. package/dist/esm/apis/Polyglot.js +64 -0
  35. package/dist/esm/apis/Security.d.ts +25 -0
  36. package/dist/esm/apis/Security.js +31 -0
  37. package/dist/esm/apis/Transcriptions.d.ts +61 -0
  38. package/dist/esm/apis/Transcriptions.js +39 -0
  39. package/dist/esm/apis/UrlTranscription.d.ts +59 -0
  40. package/dist/esm/apis/UrlTranscription.js +49 -0
  41. package/dist/esm/apis/index.d.ts +6 -0
  42. package/dist/esm/apis/index.js +6 -0
  43. package/dist/esm/generics.zod.d.ts +77 -0
  44. package/dist/esm/generics.zod.js +45 -0
  45. package/dist/esm/index.d.ts +2 -0
  46. package/dist/esm/index.js +2 -0
  47. package/dist/generics.zod.d.ts +77 -0
  48. package/dist/generics.zod.js +48 -0
  49. package/dist/index.d.ts +2 -0
  50. package/dist/index.js +18 -0
  51. package/package.json +47 -0
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.LiveTranscription = void 0;
13
+ const zod_1 = require("zod");
14
+ const generics_zod_1 = require("../generics.zod");
15
+ const VocalStackApi_1 = require("../VocalStackApi");
16
+ const zLiveTranscriptionStartRequest = zod_1.z.object({
17
+ livestream_url: zod_1.z.string().optional(),
18
+ language: generics_zod_1.zLanguage.optional(),
19
+ translations: generics_zod_1.zLanguage.array().optional(),
20
+ polyglot_id: zod_1.z.string().optional(),
21
+ timeout_period_s: zod_1.z.number().optional(),
22
+ max_duration_s: zod_1.z.number().optional(),
23
+ });
24
+ class LiveTranscription extends VocalStackApi_1.VocalStackApi {
25
+ connect() {
26
+ return __awaiter(this, arguments, void 0, function* (request = {}) {
27
+ var _a;
28
+ const validation = this.withValidation(zLiveTranscriptionStartRequest, request);
29
+ if (validation.badResponse) {
30
+ throw new Error(validation.badResponse.error);
31
+ }
32
+ const headers = {};
33
+ if (request['livestream_url'] && request['livestream_url'] !== 'undefined') {
34
+ headers['livestream-url'] = request.livestream_url;
35
+ }
36
+ const queryString = this.buildQueryString({
37
+ polyglot_id: request.polyglot_id,
38
+ language: request.language,
39
+ translations: (_a = request.translations) === null || _a === void 0 ? void 0 : _a.join(','),
40
+ timeout_period_s: request.timeout_period_s,
41
+ max_duration_s: request.max_duration_s,
42
+ });
43
+ return this._ws().connectDuplex({
44
+ path: `/async/live/transcribe?${queryString}`,
45
+ headers,
46
+ });
47
+ });
48
+ }
49
+ stopTranscribing(_a) {
50
+ return __awaiter(this, arguments, void 0, function* ({ id }) {
51
+ return this._rest().patch(`/live/transcribe/${id}/stop`);
52
+ });
53
+ }
54
+ }
55
+ exports.LiveTranscription = LiveTranscription;
@@ -0,0 +1,113 @@
1
+ import { z } from 'zod';
2
+ import { Language, Timeline, Uuid } from '../generics.zod';
3
+ import { ApiResponse } from '../RestApi';
4
+ import { VocalStackApi } from '../VocalStackApi';
5
+ import { WebsocketConnection } from '../WebsocketApi';
6
+ import { SummaryTranscriptions } from './Transcriptions';
7
+ export declare const zPolyglotSession: z.ZodObject<{
8
+ name: z.ZodString;
9
+ link: z.ZodString;
10
+ password: z.ZodOptional<z.ZodString>;
11
+ language: z.ZodOptional<z.ZodEnum<["af", "am", "an", "ar", "as", "az", "be", "bg", "bn", "br", "bs", "ca", "cs", "cy", "da", "de", "dz", "el", "en", "eo", "es", "et", "eu", "fa", "fi", "fo", "fr", "ga", "gl", "gu", "he", "hi", "hr", "ht", "hu", "hy", "id", "is", "it", "ja", "jv", "ka", "kk", "km", "kn", "ko", "ku", "ky", "la", "lb", "lo", "lt", "lv", "mg", "mk", "ml", "mn", "mr", "ms", "mt", "nb", "ne", "nl", "nn", "no", "oc", "or", "pa", "pl", "ps", "pt", "qu", "ro", "ru", "rw", "se", "si", "sk", "sl", "sq", "sr", "sv", "sw", "ta", "te", "th", "tl", "tr", "ug", "uk", "ur", "vi", "vo", "wa", "xh", "zh", "zu"]>>;
12
+ max_duration_s: z.ZodOptional<z.ZodNumber>;
13
+ timeout_period_s: z.ZodOptional<z.ZodNumber>;
14
+ livestream_url: z.ZodOptional<z.ZodString>;
15
+ }, "strip", z.ZodTypeAny, {
16
+ link: string;
17
+ name: string;
18
+ language?: "id" | "cy" | "br" | "hr" | "th" | "tr" | "mn" | "ms" | "or" | "af" | "am" | "an" | "ar" | "as" | "az" | "be" | "bg" | "bn" | "bs" | "ca" | "cs" | "da" | "de" | "dz" | "el" | "en" | "eo" | "es" | "et" | "eu" | "fa" | "fi" | "fo" | "fr" | "ga" | "gl" | "gu" | "he" | "hi" | "ht" | "hu" | "hy" | "is" | "it" | "ja" | "jv" | "ka" | "kk" | "km" | "kn" | "ko" | "ku" | "ky" | "la" | "lb" | "lo" | "lt" | "lv" | "mg" | "mk" | "ml" | "mr" | "mt" | "nb" | "ne" | "nl" | "nn" | "no" | "oc" | "pa" | "pl" | "ps" | "pt" | "qu" | "ro" | "ru" | "rw" | "se" | "si" | "sk" | "sl" | "sq" | "sr" | "sv" | "sw" | "ta" | "te" | "tl" | "ug" | "uk" | "ur" | "vi" | "vo" | "wa" | "xh" | "zh" | "zu" | undefined;
19
+ livestream_url?: string | undefined;
20
+ timeout_period_s?: number | undefined;
21
+ max_duration_s?: number | undefined;
22
+ password?: string | undefined;
23
+ }, {
24
+ link: string;
25
+ name: string;
26
+ language?: "id" | "cy" | "br" | "hr" | "th" | "tr" | "mn" | "ms" | "or" | "af" | "am" | "an" | "ar" | "as" | "az" | "be" | "bg" | "bn" | "bs" | "ca" | "cs" | "da" | "de" | "dz" | "el" | "en" | "eo" | "es" | "et" | "eu" | "fa" | "fi" | "fo" | "fr" | "ga" | "gl" | "gu" | "he" | "hi" | "ht" | "hu" | "hy" | "is" | "it" | "ja" | "jv" | "ka" | "kk" | "km" | "kn" | "ko" | "ku" | "ky" | "la" | "lb" | "lo" | "lt" | "lv" | "mg" | "mk" | "ml" | "mr" | "mt" | "nb" | "ne" | "nl" | "nn" | "no" | "oc" | "pa" | "pl" | "ps" | "pt" | "qu" | "ro" | "ru" | "rw" | "se" | "si" | "sk" | "sl" | "sq" | "sr" | "sv" | "sw" | "ta" | "te" | "tl" | "ug" | "uk" | "ur" | "vi" | "vo" | "wa" | "xh" | "zh" | "zu" | undefined;
27
+ livestream_url?: string | undefined;
28
+ timeout_period_s?: number | undefined;
29
+ max_duration_s?: number | undefined;
30
+ password?: string | undefined;
31
+ }>;
32
+ export type PolyglotSessionRequest = {
33
+ id?: string;
34
+ password?: string;
35
+ name: string;
36
+ link: string;
37
+ language: Language | null;
38
+ max_duration_s: number | null;
39
+ timeout_period_s: number | null;
40
+ livestream_url: string | null;
41
+ };
42
+ export type PolyglotSession = {
43
+ id: string;
44
+ name: string;
45
+ link: string;
46
+ fullUrl: string;
47
+ is_public: boolean;
48
+ requests: SummaryTranscriptions;
49
+ language: Language | null;
50
+ max_duration_s: number | null;
51
+ timeout_period_s: number | null;
52
+ livestream_url: string | null;
53
+ };
54
+ export type PolyglotCreatedSession = {
55
+ id: string;
56
+ link: string;
57
+ };
58
+ export type PolyglotUpdatedSession = {
59
+ id: string;
60
+ link: string;
61
+ };
62
+ export type PolyglotGetSessionResponse = ApiResponse<PolyglotSession>;
63
+ export type PolyglotGetAllSessionsResponse = ApiResponse<PolyglotSession[]>;
64
+ export type PolyglotDeleteSessionResponse = ApiResponse<null>;
65
+ export type PolyglotCreateSessionResponse = ApiResponse<PolyglotCreatedSession>;
66
+ export type PolyglotUpdateSessionResponse = ApiResponse<PolyglotUpdatedSession>;
67
+ export type PolyglotPresenterRequest = {
68
+ link: string;
69
+ password?: string;
70
+ };
71
+ export type PolyglotPresenterResponse = {
72
+ status: string;
73
+ data: {
74
+ session: PolyglotPresenterSession;
75
+ activeTranscription: PolyglotPresenterTranscription;
76
+ };
77
+ http_code?: number;
78
+ error?: string;
79
+ };
80
+ export type PolyglotPresenterConnection = WebsocketConnection<PolyglotPresenterResponse>;
81
+ export type PolyglotPresenterSession = {
82
+ id: Uuid;
83
+ name: string;
84
+ link: string;
85
+ fullUrl: string;
86
+ is_public: boolean;
87
+ requests: PolyglotPresenterTranscription[];
88
+ };
89
+ export type PolyglotPresenterTranscription = {
90
+ id: Uuid;
91
+ polyglot_id: Uuid | null;
92
+ start: string;
93
+ end: string | null;
94
+ status: 'waiting' | 'processing' | 'done' | 'error';
95
+ operation: 'transcription-live';
96
+ flags?: {
97
+ started: boolean;
98
+ } | null;
99
+ timeline?: Timeline;
100
+ keywords?: string | null;
101
+ };
102
+ export declare class Polyglot extends VocalStackApi {
103
+ getSession({ id }: {
104
+ id: string;
105
+ }): Promise<PolyglotGetSessionResponse>;
106
+ getAllSessions(): Promise<PolyglotGetAllSessionsResponse>;
107
+ deleteSession({ id }: {
108
+ id: string;
109
+ }): Promise<PolyglotDeleteSessionResponse>;
110
+ createSession(session: PolyglotSessionRequest): Promise<PolyglotCreateSessionResponse>;
111
+ updateSession(session: PolyglotSessionRequest): Promise<PolyglotUpdateSessionResponse>;
112
+ getLiveSessionStream({ link, password }: PolyglotPresenterRequest): Promise<PolyglotPresenterConnection>;
113
+ }
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Polyglot = exports.zPolyglotSession = void 0;
13
+ const zod_1 = require("zod");
14
+ const generics_zod_1 = require("../generics.zod");
15
+ const VocalStackApi_1 = require("../VocalStackApi");
16
+ exports.zPolyglotSession = zod_1.z.object({
17
+ name: zod_1.z.string(),
18
+ link: zod_1.z.string(),
19
+ password: zod_1.z.string().optional(),
20
+ language: generics_zod_1.zLanguage.optional(),
21
+ max_duration_s: zod_1.z.number().optional(),
22
+ timeout_period_s: zod_1.z.number().optional(),
23
+ livestream_url: zod_1.z.string().optional(),
24
+ });
25
+ class Polyglot extends VocalStackApi_1.VocalStackApi {
26
+ getSession(_a) {
27
+ return __awaiter(this, arguments, void 0, function* ({ id }) {
28
+ return this._rest().get(`/polyglot/${id}`);
29
+ });
30
+ }
31
+ getAllSessions() {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ return this._rest().get('/polyglot');
34
+ });
35
+ }
36
+ deleteSession(_a) {
37
+ return __awaiter(this, arguments, void 0, function* ({ id }) {
38
+ return this._rest().delete(`/polyglot/${id}`);
39
+ });
40
+ }
41
+ createSession(session) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ const validation = this.withValidation(exports.zPolyglotSession, session);
44
+ return (validation.badResponse ||
45
+ this._rest().post('/polyglot', {
46
+ json: validation.data,
47
+ }));
48
+ });
49
+ }
50
+ updateSession(session) {
51
+ return __awaiter(this, void 0, void 0, function* () {
52
+ const validation = this.withValidation(exports.zPolyglotSession, session);
53
+ return (validation.badResponse ||
54
+ this._rest().put(`/polyglot/${session.id}`, {
55
+ json: validation.data,
56
+ }));
57
+ });
58
+ }
59
+ getLiveSessionStream(_a) {
60
+ return __awaiter(this, arguments, void 0, function* ({ link, password }) {
61
+ return this._ws().connect({
62
+ path: `/async/polyglot/${link}`,
63
+ headers: { password: !password ? '' : password },
64
+ });
65
+ });
66
+ }
67
+ }
68
+ exports.Polyglot = Polyglot;
@@ -0,0 +1,25 @@
1
+ import { z } from 'zod';
2
+ import { VocalStackApi } from '../VocalStackApi';
3
+ import { ApiResponse } from '../RestApi';
4
+ declare const zGenerateTokenRequest: z.ZodObject<{
5
+ access: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"readonly">, z.ZodLiteral<"readwrite">]>>;
6
+ lifetime_s: z.ZodOptional<z.ZodNumber>;
7
+ one_time: z.ZodOptional<z.ZodBoolean>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ access?: "readonly" | "readwrite" | undefined;
10
+ lifetime_s?: number | undefined;
11
+ one_time?: boolean | undefined;
12
+ }, {
13
+ access?: "readonly" | "readwrite" | undefined;
14
+ lifetime_s?: number | undefined;
15
+ one_time?: boolean | undefined;
16
+ }>;
17
+ type GenerateTokenRequest = z.infer<typeof zGenerateTokenRequest>;
18
+ export type GenerateTokenResponse = {
19
+ status: 'done' | 'error';
20
+ data: string;
21
+ };
22
+ export declare class Security extends VocalStackApi {
23
+ generateToken(request?: GenerateTokenRequest): Promise<ApiResponse<GenerateTokenResponse>>;
24
+ }
25
+ export {};
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Security = void 0;
13
+ const zod_1 = require("zod");
14
+ const VocalStackApi_1 = require("../VocalStackApi");
15
+ const zGenerateTokenRequest = zod_1.z.object({
16
+ access: zod_1.z.union([zod_1.z.literal('readonly'), zod_1.z.literal('readwrite')]).optional(),
17
+ lifetime_s: zod_1.z.optional(zod_1.z.number().gt(0).lte(120)),
18
+ one_time: zod_1.z.optional(zod_1.z.boolean()),
19
+ });
20
+ class Security extends VocalStackApi_1.VocalStackApi {
21
+ generateToken(request) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ if (typeof window !== 'undefined') {
24
+ return Promise.resolve({
25
+ success: false,
26
+ error: 'Cannot generate token in a browser window. Please use a server environment.',
27
+ status: 'error',
28
+ data: null,
29
+ });
30
+ }
31
+ return this._rest().get(`/security/generate-token?${this.buildQueryString(request || {})}`);
32
+ });
33
+ }
34
+ }
35
+ exports.Security = Security;
@@ -0,0 +1,61 @@
1
+ import { Language, Timeline, Uuid } from '../generics.zod';
2
+ import { VocalStackApi } from '../VocalStackApi';
3
+ import { ApiResponse } from '../RestApi';
4
+ import { WebsocketConnection } from '../WebsocketApi';
5
+ export type { Timeline };
6
+ export type Operation = 'transcription-prerecorded' | 'transcription-live';
7
+ export type Status = 'waiting' | 'processing' | 'done' | 'stopping' | 'error';
8
+ export type FinishedTranscription = {
9
+ id: Uuid;
10
+ status: Status;
11
+ operation: Operation;
12
+ start: string;
13
+ end?: string;
14
+ keywords?: string | null;
15
+ timeline: Timeline;
16
+ paragraphs?: string[] | null;
17
+ summary?: string | null;
18
+ url?: string;
19
+ duration: number;
20
+ };
21
+ export type SummaryTranscription = {
22
+ id: string;
23
+ operation: Operation;
24
+ status: Status;
25
+ duration?: number;
26
+ start: string;
27
+ end: string | null;
28
+ polyglot_id: string;
29
+ url?: string;
30
+ keywords: string | null;
31
+ };
32
+ export type SummaryTranscriptions = SummaryTranscription[];
33
+ export type FinishedTranscriptionRequest = {
34
+ id: string;
35
+ };
36
+ export type FinishedTranscriptionResponse = ApiResponse<FinishedTranscription>;
37
+ export type AllTranscriptionsResponse = ApiResponse<SummaryTranscriptions>;
38
+ export type AddTranscriptionTranslationRequest = {
39
+ id: string;
40
+ language: Language;
41
+ };
42
+ export type AddTranslationResponse = ApiResponse<{
43
+ timeline: Timeline;
44
+ }>;
45
+ export type RemoveTranscriptionTranslationRequest = {
46
+ id: string;
47
+ language: Language;
48
+ };
49
+ export type RemoveTranslationResponse = ApiResponse<null>;
50
+ export type AddTranscriptionTranslationAsyncResponse = {
51
+ status: Status;
52
+ data: FinishedTranscription | null;
53
+ };
54
+ export type AddTranscriptionTranslationConnection = WebsocketConnection<AddTranscriptionTranslationAsyncResponse>;
55
+ export declare class Transcriptions extends VocalStackApi {
56
+ getTranscription({ id }: FinishedTranscriptionRequest): Promise<FinishedTranscriptionResponse>;
57
+ getAllTranscriptions(): Promise<AllTranscriptionsResponse>;
58
+ addTranslation({ id, language }: AddTranscriptionTranslationRequest): Promise<AddTranslationResponse>;
59
+ removeTranslation(req: RemoveTranscriptionTranslationRequest): Promise<RemoveTranslationResponse>;
60
+ addTranslationAsync(req: AddTranscriptionTranslationRequest): Promise<AddTranscriptionTranslationConnection>;
61
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Transcriptions = void 0;
13
+ const VocalStackApi_1 = require("../VocalStackApi");
14
+ class Transcriptions extends VocalStackApi_1.VocalStackApi {
15
+ getTranscription(_a) {
16
+ return __awaiter(this, arguments, void 0, function* ({ id }) {
17
+ return this._rest().get(`/transcriptions/${id}`);
18
+ });
19
+ }
20
+ getAllTranscriptions() {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ return this._rest().get('/transcriptions');
23
+ });
24
+ }
25
+ addTranslation(_a) {
26
+ return __awaiter(this, arguments, void 0, function* ({ id, language }) {
27
+ return this._rest().post(`/transcription/${id}/language/${language}`);
28
+ });
29
+ }
30
+ removeTranslation(req) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ return this._rest().delete(`/transcription/${req.id}/language/${req.language}`);
33
+ });
34
+ }
35
+ addTranslationAsync(req) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ return this._ws().connect({
38
+ path: `/async/transcription/${req.id}/language/${req.language}`,
39
+ });
40
+ });
41
+ }
42
+ }
43
+ exports.Transcriptions = Transcriptions;
@@ -0,0 +1,59 @@
1
+ import { z } from 'zod';
2
+ import { Timeline, Uuid } from '../generics.zod';
3
+ import { VocalStackApi } from '../VocalStackApi';
4
+ import { WebsocketConnection } from '../WebsocketApi';
5
+ import { ApiResponse } from '../RestApi';
6
+ import { Status } from './Transcriptions';
7
+ declare const zUrlTranscriptionStartRequest: z.ZodObject<{
8
+ url: z.ZodString;
9
+ duration_s: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
10
+ max_duration_s: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
11
+ language: z.ZodOptional<z.ZodEnum<["af", "am", "an", "ar", "as", "az", "be", "bg", "bn", "br", "bs", "ca", "cs", "cy", "da", "de", "dz", "el", "en", "eo", "es", "et", "eu", "fa", "fi", "fo", "fr", "ga", "gl", "gu", "he", "hi", "hr", "ht", "hu", "hy", "id", "is", "it", "ja", "jv", "ka", "kk", "km", "kn", "ko", "ku", "ky", "la", "lb", "lo", "lt", "lv", "mg", "mk", "ml", "mn", "mr", "ms", "mt", "nb", "ne", "nl", "nn", "no", "oc", "or", "pa", "pl", "ps", "pt", "qu", "ro", "ru", "rw", "se", "si", "sk", "sl", "sq", "sr", "sv", "sw", "ta", "te", "th", "tl", "tr", "ug", "uk", "ur", "vi", "vo", "wa", "xh", "zh", "zu"]>>;
12
+ }, "strip", z.ZodTypeAny, {
13
+ url: string;
14
+ language?: "id" | "cy" | "br" | "hr" | "th" | "tr" | "mn" | "ms" | "or" | "af" | "am" | "an" | "ar" | "as" | "az" | "be" | "bg" | "bn" | "bs" | "ca" | "cs" | "da" | "de" | "dz" | "el" | "en" | "eo" | "es" | "et" | "eu" | "fa" | "fi" | "fo" | "fr" | "ga" | "gl" | "gu" | "he" | "hi" | "ht" | "hu" | "hy" | "is" | "it" | "ja" | "jv" | "ka" | "kk" | "km" | "kn" | "ko" | "ku" | "ky" | "la" | "lb" | "lo" | "lt" | "lv" | "mg" | "mk" | "ml" | "mr" | "mt" | "nb" | "ne" | "nl" | "nn" | "no" | "oc" | "pa" | "pl" | "ps" | "pt" | "qu" | "ro" | "ru" | "rw" | "se" | "si" | "sk" | "sl" | "sq" | "sr" | "sv" | "sw" | "ta" | "te" | "tl" | "ug" | "uk" | "ur" | "vi" | "vo" | "wa" | "xh" | "zh" | "zu" | undefined;
15
+ max_duration_s?: number | undefined;
16
+ duration_s?: number | undefined;
17
+ }, {
18
+ url: string;
19
+ language?: "id" | "cy" | "br" | "hr" | "th" | "tr" | "mn" | "ms" | "or" | "af" | "am" | "an" | "ar" | "as" | "az" | "be" | "bg" | "bn" | "bs" | "ca" | "cs" | "da" | "de" | "dz" | "el" | "en" | "eo" | "es" | "et" | "eu" | "fa" | "fi" | "fo" | "fr" | "ga" | "gl" | "gu" | "he" | "hi" | "ht" | "hu" | "hy" | "is" | "it" | "ja" | "jv" | "ka" | "kk" | "km" | "kn" | "ko" | "ku" | "ky" | "la" | "lb" | "lo" | "lt" | "lv" | "mg" | "mk" | "ml" | "mr" | "mt" | "nb" | "ne" | "nl" | "nn" | "no" | "oc" | "pa" | "pl" | "ps" | "pt" | "qu" | "ro" | "ru" | "rw" | "se" | "si" | "sk" | "sl" | "sq" | "sr" | "sv" | "sw" | "ta" | "te" | "tl" | "ug" | "uk" | "ur" | "vi" | "vo" | "wa" | "xh" | "zh" | "zu" | undefined;
20
+ max_duration_s?: number | undefined;
21
+ duration_s?: number | undefined;
22
+ }>;
23
+ export type UrlTranscriptionStartRequest = z.infer<typeof zUrlTranscriptionStartRequest>;
24
+ export type UrlTranscriptionStreamData = ArrayBufferLike;
25
+ export type UrlTranscriptionResponse = {
26
+ status: Status;
27
+ data: UrlTranscriptionResponseData | null;
28
+ http_code?: number;
29
+ };
30
+ export type UrlTranscriptionResponseData = {
31
+ id: Uuid;
32
+ status: Status;
33
+ operation: 'transcription-prerecorded';
34
+ start: string;
35
+ end: string | null;
36
+ flags?: {
37
+ started: boolean;
38
+ } | null;
39
+ keywords?: string | null;
40
+ timeline?: Timeline;
41
+ paragraphs?: string[] | null;
42
+ summary?: string | null;
43
+ progress: number;
44
+ };
45
+ export type UrlTranscriptionStopRequest = {
46
+ id: string;
47
+ };
48
+ export type UrlTranscriptionConnection = WebsocketConnection<UrlTranscriptionResponse>;
49
+ export type UrlTranscriptionRestResponse = ApiResponse<{
50
+ id: Uuid;
51
+ status: 'processing' | 'error';
52
+ http_code?: number;
53
+ }>;
54
+ export declare class UrlTranscription extends VocalStackApi {
55
+ connect(request: UrlTranscriptionStartRequest): Promise<UrlTranscriptionConnection>;
56
+ transcribe(request: UrlTranscriptionStartRequest): Promise<UrlTranscriptionRestResponse>;
57
+ private getQuery;
58
+ }
59
+ export {};
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.UrlTranscription = void 0;
13
+ const zod_1 = require("zod");
14
+ const generics_zod_1 = require("../generics.zod");
15
+ const VocalStackApi_1 = require("../VocalStackApi");
16
+ const zUrlTranscriptionStartRequest = zod_1.z.object({
17
+ url: zod_1.z.string(),
18
+ duration_s: generics_zod_1.zDuration.optional(),
19
+ max_duration_s: generics_zod_1.zDuration.optional(),
20
+ language: generics_zod_1.zLanguage.optional(),
21
+ });
22
+ class UrlTranscription extends VocalStackApi_1.VocalStackApi {
23
+ connect(request) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ const queryString = this.getQuery(request);
26
+ return this._ws().connect({
27
+ path: `/async/transcribe/url?${queryString}`,
28
+ mustStart: true,
29
+ headers: {},
30
+ });
31
+ });
32
+ }
33
+ transcribe(request) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ const queryString = this.getQuery(request);
36
+ return this._rest().post(`/async/transcribe/url?${queryString}`);
37
+ });
38
+ }
39
+ getQuery(request) {
40
+ const validation = this.withValidation(zUrlTranscriptionStartRequest, request);
41
+ if (validation.badResponse) {
42
+ throw new Error(validation.badResponse.error);
43
+ }
44
+ const queryString = this.buildQueryString({
45
+ language: request.language || 'auto',
46
+ url: encodeURIComponent(request.url),
47
+ duration_s: request.duration_s,
48
+ max_duration_s: request.max_duration_s,
49
+ });
50
+ return queryString;
51
+ }
52
+ }
53
+ exports.UrlTranscription = UrlTranscription;
@@ -0,0 +1,6 @@
1
+ export * from './Transcriptions';
2
+ export * from './LiveTranscription';
3
+ export * from './UrlTranscription';
4
+ export * from './Polyglot';
5
+ export * from './Security';
6
+ export * from './Billing';
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Transcriptions"), exports);
18
+ __exportStar(require("./LiveTranscription"), exports);
19
+ __exportStar(require("./UrlTranscription"), exports);
20
+ __exportStar(require("./Polyglot"), exports);
21
+ __exportStar(require("./Security"), exports);
22
+ __exportStar(require("./Billing"), exports);
@@ -0,0 +1,21 @@
1
+ export type ApiResponse<T> = {
2
+ status: 'waiting' | 'processing' | 'done' | 'error';
3
+ data?: null | T;
4
+ success: boolean;
5
+ error?: string;
6
+ };
7
+ export type RequestOptions = RequestInit & {
8
+ json?: Record<string, unknown>;
9
+ };
10
+ export declare class RestApi {
11
+ private apiServer;
12
+ private headers;
13
+ constructor(apiServer: string, headers: Record<string, string>);
14
+ get<T>(path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
15
+ post<T>(path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
16
+ put<T>(path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
17
+ patch<T>(path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
18
+ delete<T>(path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
19
+ private apiCall;
20
+ private respond;
21
+ }