@dimer47/gladia-sdk 1.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.fr.md +342 -0
- package/README.md +342 -0
- package/dist/index.cjs +575 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +690 -0
- package/dist/index.d.ts +690 -0
- package/dist/index.js +533 -0
- package/dist/index.js.map +1 -0
- package/package.json +58 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,690 @@
|
|
|
1
|
+
type JobStatus = 'queued' | 'processing' | 'done' | 'error';
|
|
2
|
+
interface PaginationParams {
|
|
3
|
+
offset?: number;
|
|
4
|
+
limit?: number;
|
|
5
|
+
date?: string;
|
|
6
|
+
before_date?: string;
|
|
7
|
+
after_date?: string;
|
|
8
|
+
status?: JobStatus[];
|
|
9
|
+
custom_metadata?: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
interface PaginatedResponse<T> {
|
|
12
|
+
first: string;
|
|
13
|
+
current: string;
|
|
14
|
+
next?: string | null;
|
|
15
|
+
items: T[];
|
|
16
|
+
}
|
|
17
|
+
interface FileResponse {
|
|
18
|
+
id?: string;
|
|
19
|
+
filename?: string | null;
|
|
20
|
+
source?: string | null;
|
|
21
|
+
audio_duration?: number | null;
|
|
22
|
+
number_of_channels?: number | null;
|
|
23
|
+
}
|
|
24
|
+
interface GladiaClientConfig {
|
|
25
|
+
apiKey: string;
|
|
26
|
+
baseUrl?: string;
|
|
27
|
+
/** Custom WebSocket constructor (for Node < 21, pass `ws`) */
|
|
28
|
+
WebSocket?: unknown;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface HttpClientConfig {
|
|
32
|
+
apiKey: string;
|
|
33
|
+
baseUrl: string;
|
|
34
|
+
}
|
|
35
|
+
declare class HttpClient {
|
|
36
|
+
private readonly apiKey;
|
|
37
|
+
private readonly baseUrl;
|
|
38
|
+
constructor(config: HttpClientConfig);
|
|
39
|
+
get<T>(path: string, query?: Record<string, unknown>, signal?: AbortSignal): Promise<T>;
|
|
40
|
+
post<T>(path: string, body?: unknown, signal?: AbortSignal): Promise<T>;
|
|
41
|
+
postForm<T>(path: string, formData: FormData, signal?: AbortSignal): Promise<T>;
|
|
42
|
+
delete(path: string, signal?: AbortSignal): Promise<void>;
|
|
43
|
+
getBlob(path: string, signal?: AbortSignal): Promise<Blob>;
|
|
44
|
+
private buildUrl;
|
|
45
|
+
private headers;
|
|
46
|
+
private request;
|
|
47
|
+
private throwApiError;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface AudioMetadata {
|
|
51
|
+
id: string;
|
|
52
|
+
filename: string;
|
|
53
|
+
source: string;
|
|
54
|
+
extension: string;
|
|
55
|
+
size: number;
|
|
56
|
+
audio_duration: number;
|
|
57
|
+
number_of_channels: number;
|
|
58
|
+
}
|
|
59
|
+
interface UploadResponse {
|
|
60
|
+
audio_url: string;
|
|
61
|
+
audio_metadata: AudioMetadata;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
declare class UploadResource {
|
|
65
|
+
private readonly http;
|
|
66
|
+
constructor(http: HttpClient);
|
|
67
|
+
/**
|
|
68
|
+
* Upload a file (Blob, File, or Buffer) to Gladia.
|
|
69
|
+
*/
|
|
70
|
+
fromFile(file: Blob, filename?: string, signal?: AbortSignal): Promise<UploadResponse>;
|
|
71
|
+
/**
|
|
72
|
+
* Upload from a remote URL.
|
|
73
|
+
*/
|
|
74
|
+
fromUrl(audioUrl: string, signal?: AbortSignal): Promise<UploadResponse>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
interface LanguageConfig {
|
|
78
|
+
languages?: string[];
|
|
79
|
+
code_switching?: boolean;
|
|
80
|
+
}
|
|
81
|
+
interface CustomVocabularyEntry {
|
|
82
|
+
value: string;
|
|
83
|
+
intensity?: number;
|
|
84
|
+
pronunciations?: string[];
|
|
85
|
+
language?: string;
|
|
86
|
+
}
|
|
87
|
+
interface CustomVocabularyConfig {
|
|
88
|
+
vocabulary?: (string | CustomVocabularyEntry)[];
|
|
89
|
+
default_intensity?: number;
|
|
90
|
+
}
|
|
91
|
+
interface DiarizationConfig {
|
|
92
|
+
number_of_speakers?: number;
|
|
93
|
+
min_speakers?: number;
|
|
94
|
+
max_speakers?: number;
|
|
95
|
+
}
|
|
96
|
+
type SubtitleFormat = 'srt' | 'vtt';
|
|
97
|
+
type SubtitleStyle = 'default' | 'compliance';
|
|
98
|
+
interface SubtitlesConfig {
|
|
99
|
+
formats?: SubtitleFormat[];
|
|
100
|
+
minimum_duration?: number;
|
|
101
|
+
maximum_duration?: number;
|
|
102
|
+
maximum_characters_per_row?: number;
|
|
103
|
+
maximum_rows_per_caption?: number;
|
|
104
|
+
style?: SubtitleStyle;
|
|
105
|
+
}
|
|
106
|
+
type TranslationModel = 'base' | 'enhanced';
|
|
107
|
+
interface TranslationConfig {
|
|
108
|
+
target_languages: string[];
|
|
109
|
+
model?: TranslationModel;
|
|
110
|
+
match_original_utterances?: boolean;
|
|
111
|
+
lipsync?: boolean;
|
|
112
|
+
context_adaptation?: boolean;
|
|
113
|
+
informal?: boolean;
|
|
114
|
+
context?: string;
|
|
115
|
+
}
|
|
116
|
+
type SummarizationType = 'general' | 'bullet_points' | 'concise';
|
|
117
|
+
interface SummarizationConfig {
|
|
118
|
+
type?: SummarizationType;
|
|
119
|
+
}
|
|
120
|
+
interface CustomSpellingConfig {
|
|
121
|
+
spelling_dictionary: Record<string, string[]>;
|
|
122
|
+
}
|
|
123
|
+
interface StructuredDataExtractionConfig {
|
|
124
|
+
classes: string[];
|
|
125
|
+
}
|
|
126
|
+
interface AudioToLlmConfig {
|
|
127
|
+
prompts: string[];
|
|
128
|
+
}
|
|
129
|
+
type PiiProcessedTextType = 'MASK' | 'MARKER';
|
|
130
|
+
interface PiiRedactionConfig {
|
|
131
|
+
entity_types?: string[];
|
|
132
|
+
processed_text_type?: PiiProcessedTextType;
|
|
133
|
+
}
|
|
134
|
+
type CallbackMethod = 'POST' | 'PUT';
|
|
135
|
+
interface CallbackConfig {
|
|
136
|
+
url: string;
|
|
137
|
+
method?: CallbackMethod;
|
|
138
|
+
}
|
|
139
|
+
interface PreProcessingConfig {
|
|
140
|
+
audio_enhancer?: boolean;
|
|
141
|
+
speech_threshold?: number;
|
|
142
|
+
}
|
|
143
|
+
interface RealtimeProcessingConfig {
|
|
144
|
+
custom_vocabulary?: boolean;
|
|
145
|
+
custom_vocabulary_config?: CustomVocabularyConfig;
|
|
146
|
+
custom_spelling?: boolean;
|
|
147
|
+
custom_spelling_config?: CustomSpellingConfig;
|
|
148
|
+
translation?: boolean;
|
|
149
|
+
translation_config?: TranslationConfig;
|
|
150
|
+
named_entity_recognition?: boolean;
|
|
151
|
+
sentiment_analysis?: boolean;
|
|
152
|
+
}
|
|
153
|
+
interface PostProcessingConfig {
|
|
154
|
+
summarization?: boolean;
|
|
155
|
+
summarization_config?: SummarizationConfig;
|
|
156
|
+
chapterization?: boolean;
|
|
157
|
+
}
|
|
158
|
+
interface MessagesConfig {
|
|
159
|
+
receive_partial_transcripts?: boolean;
|
|
160
|
+
receive_final_transcripts?: boolean;
|
|
161
|
+
receive_speech_events?: boolean;
|
|
162
|
+
receive_pre_processing_events?: boolean;
|
|
163
|
+
receive_realtime_processing_events?: boolean;
|
|
164
|
+
receive_post_processing_events?: boolean;
|
|
165
|
+
receive_acknowledgments?: boolean;
|
|
166
|
+
receive_errors?: boolean;
|
|
167
|
+
receive_lifecycle_events?: boolean;
|
|
168
|
+
}
|
|
169
|
+
interface LiveCallbackConfig {
|
|
170
|
+
url: string;
|
|
171
|
+
receive_partial_transcripts?: boolean;
|
|
172
|
+
receive_final_transcripts?: boolean;
|
|
173
|
+
receive_speech_events?: boolean;
|
|
174
|
+
receive_pre_processing_events?: boolean;
|
|
175
|
+
receive_realtime_processing_events?: boolean;
|
|
176
|
+
receive_post_processing_events?: boolean;
|
|
177
|
+
receive_acknowledgments?: boolean;
|
|
178
|
+
receive_errors?: boolean;
|
|
179
|
+
receive_lifecycle_events?: boolean;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
interface Word {
|
|
183
|
+
word: string;
|
|
184
|
+
start: number;
|
|
185
|
+
end: number;
|
|
186
|
+
confidence: number;
|
|
187
|
+
}
|
|
188
|
+
interface Utterance {
|
|
189
|
+
start: number;
|
|
190
|
+
end: number;
|
|
191
|
+
confidence: number;
|
|
192
|
+
channel: number;
|
|
193
|
+
speaker?: number | null;
|
|
194
|
+
words: Word[];
|
|
195
|
+
text: string;
|
|
196
|
+
language: string;
|
|
197
|
+
}
|
|
198
|
+
interface SubtitleFile {
|
|
199
|
+
format: SubtitleFormat;
|
|
200
|
+
subtitles: string;
|
|
201
|
+
}
|
|
202
|
+
interface TranscriptionDTO {
|
|
203
|
+
full_transcript: string;
|
|
204
|
+
languages: string[];
|
|
205
|
+
utterances: Utterance[];
|
|
206
|
+
sentences?: Record<string, unknown>[] | null;
|
|
207
|
+
subtitles?: SubtitleFile[] | null;
|
|
208
|
+
}
|
|
209
|
+
interface TranscriptionMetadata {
|
|
210
|
+
audio_duration: number;
|
|
211
|
+
number_of_distinct_channels: number;
|
|
212
|
+
billing_time: number;
|
|
213
|
+
transcription_time: number;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
interface AddonError {
|
|
217
|
+
status_code: number;
|
|
218
|
+
exception: string;
|
|
219
|
+
message: string;
|
|
220
|
+
}
|
|
221
|
+
interface AddonGenericDTO {
|
|
222
|
+
success: boolean;
|
|
223
|
+
is_empty: boolean;
|
|
224
|
+
exec_time: number;
|
|
225
|
+
error?: AddonError;
|
|
226
|
+
results?: unknown;
|
|
227
|
+
}
|
|
228
|
+
interface TranslationResultEntry {
|
|
229
|
+
error?: AddonError;
|
|
230
|
+
full_transcript: string;
|
|
231
|
+
languages: string[];
|
|
232
|
+
sentences?: Record<string, unknown>[] | null;
|
|
233
|
+
subtitles?: SubtitleFile[] | null;
|
|
234
|
+
words: Word[];
|
|
235
|
+
utterances: Utterance[];
|
|
236
|
+
}
|
|
237
|
+
interface AddonTranslationDTO {
|
|
238
|
+
success: boolean;
|
|
239
|
+
is_empty: boolean;
|
|
240
|
+
exec_time: number;
|
|
241
|
+
error?: AddonError;
|
|
242
|
+
results?: TranslationResultEntry[] | null;
|
|
243
|
+
}
|
|
244
|
+
interface AddonSummarizationDTO {
|
|
245
|
+
success: boolean;
|
|
246
|
+
is_empty: boolean;
|
|
247
|
+
exec_time: number;
|
|
248
|
+
error?: AddonError;
|
|
249
|
+
results?: string | null;
|
|
250
|
+
}
|
|
251
|
+
type Sentiment = 'positive' | 'negative' | 'neutral' | 'mixed' | 'unknown';
|
|
252
|
+
interface SentimentAnalysisEntry {
|
|
253
|
+
text?: string;
|
|
254
|
+
sentiment?: Sentiment;
|
|
255
|
+
emotion?: string;
|
|
256
|
+
start?: number;
|
|
257
|
+
end?: number;
|
|
258
|
+
channel?: number;
|
|
259
|
+
speaker?: number;
|
|
260
|
+
}
|
|
261
|
+
interface AddonSentimentAnalysisDTO {
|
|
262
|
+
success: boolean;
|
|
263
|
+
is_empty: boolean;
|
|
264
|
+
exec_time: number;
|
|
265
|
+
error?: AddonError;
|
|
266
|
+
results?: SentimentAnalysisEntry[] | null;
|
|
267
|
+
}
|
|
268
|
+
interface NerEntity {
|
|
269
|
+
entity_type?: string;
|
|
270
|
+
text?: string;
|
|
271
|
+
start?: number;
|
|
272
|
+
end?: number;
|
|
273
|
+
}
|
|
274
|
+
interface AddonNerDTO {
|
|
275
|
+
success: boolean;
|
|
276
|
+
is_empty: boolean;
|
|
277
|
+
exec_time: number;
|
|
278
|
+
error?: AddonError;
|
|
279
|
+
results?: NerEntity[] | null;
|
|
280
|
+
}
|
|
281
|
+
interface Chapter {
|
|
282
|
+
summary?: string;
|
|
283
|
+
headline?: string;
|
|
284
|
+
gist?: string;
|
|
285
|
+
keywords?: string[];
|
|
286
|
+
start?: number;
|
|
287
|
+
end?: number;
|
|
288
|
+
}
|
|
289
|
+
interface AddonChapterizationDTO {
|
|
290
|
+
success: boolean;
|
|
291
|
+
is_empty: boolean;
|
|
292
|
+
exec_time: number;
|
|
293
|
+
error?: AddonError;
|
|
294
|
+
results?: Chapter[] | null;
|
|
295
|
+
}
|
|
296
|
+
interface AudioToLlmResultEntry {
|
|
297
|
+
success?: boolean;
|
|
298
|
+
is_empty?: boolean;
|
|
299
|
+
results?: {
|
|
300
|
+
prompt?: string;
|
|
301
|
+
response?: string;
|
|
302
|
+
};
|
|
303
|
+
exec_time?: number;
|
|
304
|
+
error?: AddonError;
|
|
305
|
+
}
|
|
306
|
+
interface AddonAudioToLlmDTO {
|
|
307
|
+
success: boolean;
|
|
308
|
+
is_empty: boolean;
|
|
309
|
+
exec_time: number;
|
|
310
|
+
error?: AddonError;
|
|
311
|
+
results?: AudioToLlmResultEntry[] | null;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
interface PreRecordedRequest {
|
|
315
|
+
audio_url: string;
|
|
316
|
+
language_config?: LanguageConfig;
|
|
317
|
+
custom_vocabulary?: boolean;
|
|
318
|
+
custom_vocabulary_config?: CustomVocabularyConfig;
|
|
319
|
+
sentences?: boolean;
|
|
320
|
+
punctuation_enhanced?: boolean;
|
|
321
|
+
diarization?: boolean;
|
|
322
|
+
diarization_config?: DiarizationConfig;
|
|
323
|
+
subtitles?: boolean;
|
|
324
|
+
subtitles_config?: SubtitlesConfig;
|
|
325
|
+
translation?: boolean;
|
|
326
|
+
translation_config?: TranslationConfig;
|
|
327
|
+
summarization?: boolean;
|
|
328
|
+
summarization_config?: SummarizationConfig;
|
|
329
|
+
sentiment_analysis?: boolean;
|
|
330
|
+
moderation?: boolean;
|
|
331
|
+
named_entity_recognition?: boolean;
|
|
332
|
+
chapterization?: boolean;
|
|
333
|
+
name_consistency?: boolean;
|
|
334
|
+
custom_spelling?: boolean;
|
|
335
|
+
custom_spelling_config?: CustomSpellingConfig;
|
|
336
|
+
structured_data_extraction?: boolean;
|
|
337
|
+
structured_data_extraction_config?: StructuredDataExtractionConfig;
|
|
338
|
+
audio_to_llm?: boolean;
|
|
339
|
+
audio_to_llm_config?: AudioToLlmConfig;
|
|
340
|
+
display_mode?: boolean;
|
|
341
|
+
pii_redaction?: boolean;
|
|
342
|
+
pii_redaction_config?: PiiRedactionConfig;
|
|
343
|
+
callback?: boolean;
|
|
344
|
+
callback_config?: CallbackConfig;
|
|
345
|
+
custom_metadata?: Record<string, unknown>;
|
|
346
|
+
}
|
|
347
|
+
interface PreRecordedCreatedResponse {
|
|
348
|
+
id: string;
|
|
349
|
+
result_url: string;
|
|
350
|
+
}
|
|
351
|
+
interface TranscriptionResult {
|
|
352
|
+
metadata?: TranscriptionMetadata;
|
|
353
|
+
transcription?: TranscriptionDTO;
|
|
354
|
+
translation?: AddonTranslationDTO | null;
|
|
355
|
+
summarization?: AddonSummarizationDTO | null;
|
|
356
|
+
moderation?: AddonGenericDTO | null;
|
|
357
|
+
named_entity_recognition?: AddonNerDTO | null;
|
|
358
|
+
sentiment_analysis?: AddonSentimentAnalysisDTO | null;
|
|
359
|
+
chapterization?: AddonChapterizationDTO | null;
|
|
360
|
+
diarization?: AddonGenericDTO | null;
|
|
361
|
+
name_consistency?: AddonGenericDTO | null;
|
|
362
|
+
speaker_reidentification?: AddonGenericDTO | null;
|
|
363
|
+
structured_data_extraction?: AddonGenericDTO | null;
|
|
364
|
+
audio_to_llm?: AddonAudioToLlmDTO | null;
|
|
365
|
+
display_mode?: AddonGenericDTO | null;
|
|
366
|
+
}
|
|
367
|
+
interface PreRecordedResponse {
|
|
368
|
+
id: string;
|
|
369
|
+
request_id: string;
|
|
370
|
+
version: number;
|
|
371
|
+
status: JobStatus;
|
|
372
|
+
created_at: string;
|
|
373
|
+
completed_at?: string | null;
|
|
374
|
+
custom_metadata?: Record<string, unknown>;
|
|
375
|
+
error_code?: number | null;
|
|
376
|
+
post_session_metadata: Record<string, unknown>;
|
|
377
|
+
kind: 'pre-recorded';
|
|
378
|
+
file?: FileResponse | null;
|
|
379
|
+
request_params?: Record<string, unknown> | null;
|
|
380
|
+
result?: TranscriptionResult | null;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
interface TranscribeOptions extends PreRecordedRequest {
|
|
384
|
+
/** Called on each poll with the current response */
|
|
385
|
+
onPoll?: (response: PreRecordedResponse) => void;
|
|
386
|
+
/** Maximum polling time in ms */
|
|
387
|
+
pollTimeout?: number;
|
|
388
|
+
signal?: AbortSignal;
|
|
389
|
+
}
|
|
390
|
+
declare class PreRecordedResource {
|
|
391
|
+
private readonly http;
|
|
392
|
+
constructor(http: HttpClient);
|
|
393
|
+
/**
|
|
394
|
+
* Create a pre-recorded transcription job.
|
|
395
|
+
*/
|
|
396
|
+
create(request: PreRecordedRequest, signal?: AbortSignal): Promise<PreRecordedCreatedResponse>;
|
|
397
|
+
/**
|
|
398
|
+
* Get a pre-recorded transcription by ID.
|
|
399
|
+
*/
|
|
400
|
+
get(id: string, signal?: AbortSignal): Promise<PreRecordedResponse>;
|
|
401
|
+
/**
|
|
402
|
+
* List pre-recorded transcriptions with pagination.
|
|
403
|
+
*/
|
|
404
|
+
list(params?: PaginationParams, signal?: AbortSignal): Promise<PaginatedResponse<PreRecordedResponse>>;
|
|
405
|
+
/**
|
|
406
|
+
* Delete a pre-recorded transcription.
|
|
407
|
+
*/
|
|
408
|
+
delete(id: string, signal?: AbortSignal): Promise<void>;
|
|
409
|
+
/**
|
|
410
|
+
* Download the original audio file for a transcription.
|
|
411
|
+
*/
|
|
412
|
+
getFile(id: string, signal?: AbortSignal): Promise<Blob>;
|
|
413
|
+
/**
|
|
414
|
+
* High-level helper: create a job and poll until completion.
|
|
415
|
+
*/
|
|
416
|
+
transcribe(options: TranscribeOptions): Promise<PreRecordedResponse>;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
type LiveEncoding = 'wav/pcm' | 'wav/alaw' | 'wav/ulaw';
|
|
420
|
+
type LiveBitDepth = 8 | 16 | 24 | 32;
|
|
421
|
+
type LiveSampleRate = 8000 | 16000 | 32000 | 44100 | 48000;
|
|
422
|
+
type LiveModel = 'solaria-1';
|
|
423
|
+
type LiveRegion = 'us-west' | 'eu-west';
|
|
424
|
+
interface LiveRequest {
|
|
425
|
+
encoding?: LiveEncoding;
|
|
426
|
+
bit_depth?: LiveBitDepth;
|
|
427
|
+
sample_rate?: LiveSampleRate;
|
|
428
|
+
channels?: number;
|
|
429
|
+
model?: LiveModel;
|
|
430
|
+
endpointing?: number;
|
|
431
|
+
maximum_duration_without_endpointing?: number;
|
|
432
|
+
language_config?: LanguageConfig;
|
|
433
|
+
pre_processing?: PreProcessingConfig;
|
|
434
|
+
realtime_processing?: RealtimeProcessingConfig;
|
|
435
|
+
post_processing?: PostProcessingConfig;
|
|
436
|
+
messages_config?: MessagesConfig;
|
|
437
|
+
callback?: boolean;
|
|
438
|
+
callback_config?: LiveCallbackConfig;
|
|
439
|
+
custom_metadata?: Record<string, unknown>;
|
|
440
|
+
}
|
|
441
|
+
interface LiveCreatedResponse {
|
|
442
|
+
id: string;
|
|
443
|
+
created_at: string;
|
|
444
|
+
url: string;
|
|
445
|
+
}
|
|
446
|
+
interface LiveRequestParams {
|
|
447
|
+
encoding?: LiveEncoding;
|
|
448
|
+
bit_depth?: LiveBitDepth;
|
|
449
|
+
sample_rate?: LiveSampleRate;
|
|
450
|
+
channels?: number;
|
|
451
|
+
model?: LiveModel;
|
|
452
|
+
endpointing?: number;
|
|
453
|
+
maximum_duration_without_endpointing?: number;
|
|
454
|
+
language_config?: LanguageConfig;
|
|
455
|
+
pre_processing?: PreProcessingConfig;
|
|
456
|
+
realtime_processing?: RealtimeProcessingConfig;
|
|
457
|
+
post_processing?: PostProcessingConfig;
|
|
458
|
+
messages_config?: MessagesConfig;
|
|
459
|
+
callback?: boolean;
|
|
460
|
+
callback_config?: LiveCallbackConfig;
|
|
461
|
+
}
|
|
462
|
+
interface LiveTranscriptionResult {
|
|
463
|
+
metadata?: TranscriptionMetadata;
|
|
464
|
+
transcription?: TranscriptionDTO;
|
|
465
|
+
translation?: AddonTranslationDTO | null;
|
|
466
|
+
summarization?: AddonSummarizationDTO | null;
|
|
467
|
+
named_entity_recognition?: AddonNerDTO | null;
|
|
468
|
+
sentiment_analysis?: AddonSentimentAnalysisDTO | null;
|
|
469
|
+
chapterization?: AddonChapterizationDTO | null;
|
|
470
|
+
messages?: Record<string, unknown>[];
|
|
471
|
+
}
|
|
472
|
+
interface LiveResponse {
|
|
473
|
+
id: string;
|
|
474
|
+
request_id: string;
|
|
475
|
+
version: number;
|
|
476
|
+
status: JobStatus;
|
|
477
|
+
created_at: string;
|
|
478
|
+
completed_at?: string | null;
|
|
479
|
+
custom_metadata?: Record<string, unknown>;
|
|
480
|
+
error_code?: number | null;
|
|
481
|
+
post_session_metadata: Record<string, unknown>;
|
|
482
|
+
kind: 'live';
|
|
483
|
+
file?: FileResponse | null;
|
|
484
|
+
request_params?: LiveRequestParams | null;
|
|
485
|
+
result?: LiveTranscriptionResult | null;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
interface LiveBaseMessage {
|
|
489
|
+
type: string;
|
|
490
|
+
[key: string]: unknown;
|
|
491
|
+
}
|
|
492
|
+
interface LiveTranscriptMessage {
|
|
493
|
+
type: 'transcript';
|
|
494
|
+
transcription: {
|
|
495
|
+
type: 'partial' | 'final';
|
|
496
|
+
text: string;
|
|
497
|
+
language: string;
|
|
498
|
+
time_begin: number;
|
|
499
|
+
time_end: number;
|
|
500
|
+
utterance: Utterance;
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
interface LiveSpeechBeginMessage {
|
|
504
|
+
type: 'speech-begin';
|
|
505
|
+
}
|
|
506
|
+
interface LiveSpeechEndMessage {
|
|
507
|
+
type: 'speech-end';
|
|
508
|
+
}
|
|
509
|
+
interface LivePreProcessingMessage {
|
|
510
|
+
type: 'pre-processing';
|
|
511
|
+
[key: string]: unknown;
|
|
512
|
+
}
|
|
513
|
+
interface LiveRealtimeProcessingMessage {
|
|
514
|
+
type: 'realtime-processing';
|
|
515
|
+
[key: string]: unknown;
|
|
516
|
+
}
|
|
517
|
+
interface LivePostProcessingMessage {
|
|
518
|
+
type: 'post-processing';
|
|
519
|
+
[key: string]: unknown;
|
|
520
|
+
}
|
|
521
|
+
interface LiveReadyMessage {
|
|
522
|
+
type: 'ready';
|
|
523
|
+
}
|
|
524
|
+
interface LiveDoneMessage {
|
|
525
|
+
type: 'done';
|
|
526
|
+
}
|
|
527
|
+
interface LiveAcknowledgmentMessage {
|
|
528
|
+
type: 'acknowledgment';
|
|
529
|
+
[key: string]: unknown;
|
|
530
|
+
}
|
|
531
|
+
interface LiveErrorMessage {
|
|
532
|
+
type: 'error';
|
|
533
|
+
code?: number;
|
|
534
|
+
message?: string;
|
|
535
|
+
[key: string]: unknown;
|
|
536
|
+
}
|
|
537
|
+
interface LiveEventMap {
|
|
538
|
+
'transcript:partial': LiveTranscriptMessage;
|
|
539
|
+
'transcript:final': LiveTranscriptMessage;
|
|
540
|
+
'speech-begin': LiveSpeechBeginMessage;
|
|
541
|
+
'speech-end': LiveSpeechEndMessage;
|
|
542
|
+
'pre-processing': LivePreProcessingMessage;
|
|
543
|
+
'realtime-processing': LiveRealtimeProcessingMessage;
|
|
544
|
+
'post-processing': LivePostProcessingMessage;
|
|
545
|
+
ready: LiveReadyMessage;
|
|
546
|
+
done: LiveDoneMessage;
|
|
547
|
+
acknowledgment: LiveAcknowledgmentMessage;
|
|
548
|
+
error: LiveErrorMessage;
|
|
549
|
+
message: LiveBaseMessage;
|
|
550
|
+
}
|
|
551
|
+
type LiveEventName = keyof LiveEventMap;
|
|
552
|
+
|
|
553
|
+
type Listener<T> = (data: T) => void;
|
|
554
|
+
declare class LiveSession {
|
|
555
|
+
private ws;
|
|
556
|
+
private listeners;
|
|
557
|
+
private _closed;
|
|
558
|
+
private _donePromiseResolve?;
|
|
559
|
+
private _donePromise;
|
|
560
|
+
constructor(url: string, WebSocketCtor?: unknown);
|
|
561
|
+
/**
|
|
562
|
+
* Register a typed event listener.
|
|
563
|
+
*/
|
|
564
|
+
on<K extends LiveEventName>(event: K, listener: Listener<LiveEventMap[K]>): this;
|
|
565
|
+
/**
|
|
566
|
+
* Remove a typed event listener.
|
|
567
|
+
*/
|
|
568
|
+
off<K extends LiveEventName>(event: K, listener: Listener<LiveEventMap[K]>): this;
|
|
569
|
+
/**
|
|
570
|
+
* Send raw audio data (ArrayBuffer, Uint8Array, or Blob).
|
|
571
|
+
*/
|
|
572
|
+
sendAudio(data: ArrayBuffer | Uint8Array | Blob): void;
|
|
573
|
+
/**
|
|
574
|
+
* Signal end of audio and wait for the server to finish processing.
|
|
575
|
+
* Returns a promise that resolves when the "done" message is received or the socket closes.
|
|
576
|
+
*/
|
|
577
|
+
stop(): Promise<void>;
|
|
578
|
+
/**
|
|
579
|
+
* Returns true if the WebSocket is closed.
|
|
580
|
+
*/
|
|
581
|
+
get closed(): boolean;
|
|
582
|
+
private handleMessage;
|
|
583
|
+
private emit;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
interface LiveStreamOptions extends LiveRequest {
|
|
587
|
+
region?: LiveRegion;
|
|
588
|
+
/** Custom WebSocket constructor (for Node < 21, pass `ws`) */
|
|
589
|
+
WebSocket?: unknown;
|
|
590
|
+
signal?: AbortSignal;
|
|
591
|
+
}
|
|
592
|
+
declare class LiveResource {
|
|
593
|
+
private readonly http;
|
|
594
|
+
private readonly WebSocketCtor?;
|
|
595
|
+
constructor(http: HttpClient, WebSocketCtor?: unknown);
|
|
596
|
+
/**
|
|
597
|
+
* Initialize a live transcription session (returns metadata + WebSocket URL).
|
|
598
|
+
*/
|
|
599
|
+
init(request?: LiveRequest, options?: {
|
|
600
|
+
region?: LiveRegion;
|
|
601
|
+
signal?: AbortSignal;
|
|
602
|
+
}): Promise<LiveCreatedResponse>;
|
|
603
|
+
/**
|
|
604
|
+
* Get a live session by ID.
|
|
605
|
+
*/
|
|
606
|
+
get(id: string, signal?: AbortSignal): Promise<LiveResponse>;
|
|
607
|
+
/**
|
|
608
|
+
* List live sessions with pagination.
|
|
609
|
+
*/
|
|
610
|
+
list(params?: PaginationParams, signal?: AbortSignal): Promise<PaginatedResponse<LiveResponse>>;
|
|
611
|
+
/**
|
|
612
|
+
* Delete a live session.
|
|
613
|
+
*/
|
|
614
|
+
delete(id: string, signal?: AbortSignal): Promise<void>;
|
|
615
|
+
/**
|
|
616
|
+
* Download the audio recording of a live session.
|
|
617
|
+
*/
|
|
618
|
+
getFile(id: string, signal?: AbortSignal): Promise<Blob>;
|
|
619
|
+
/**
|
|
620
|
+
* High-level helper: init a session and return a connected LiveSession.
|
|
621
|
+
*/
|
|
622
|
+
stream(options?: LiveStreamOptions): Promise<LiveSession>;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
declare class GladiaClient {
|
|
626
|
+
readonly upload: UploadResource;
|
|
627
|
+
readonly preRecorded: PreRecordedResource;
|
|
628
|
+
readonly live: LiveResource;
|
|
629
|
+
constructor(config: GladiaClientConfig);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
declare class GladiaError extends Error {
|
|
633
|
+
constructor(message: string);
|
|
634
|
+
}
|
|
635
|
+
interface ApiErrorBody {
|
|
636
|
+
timestamp?: string;
|
|
637
|
+
path?: string;
|
|
638
|
+
request_id?: string;
|
|
639
|
+
statusCode?: number;
|
|
640
|
+
message?: string;
|
|
641
|
+
validation_errors?: string[];
|
|
642
|
+
}
|
|
643
|
+
declare class GladiaApiError extends GladiaError {
|
|
644
|
+
readonly status: number;
|
|
645
|
+
readonly body: ApiErrorBody;
|
|
646
|
+
constructor(status: number, body: ApiErrorBody);
|
|
647
|
+
}
|
|
648
|
+
declare class BadRequestError extends GladiaApiError {
|
|
649
|
+
readonly validationErrors: string[];
|
|
650
|
+
constructor(body: ApiErrorBody);
|
|
651
|
+
}
|
|
652
|
+
declare class UnauthorizedError extends GladiaApiError {
|
|
653
|
+
constructor(body: ApiErrorBody);
|
|
654
|
+
}
|
|
655
|
+
declare class ForbiddenError extends GladiaApiError {
|
|
656
|
+
constructor(body: ApiErrorBody);
|
|
657
|
+
}
|
|
658
|
+
declare class NotFoundError extends GladiaApiError {
|
|
659
|
+
constructor(body: ApiErrorBody);
|
|
660
|
+
}
|
|
661
|
+
declare class UnprocessableEntityError extends GladiaApiError {
|
|
662
|
+
constructor(body: ApiErrorBody);
|
|
663
|
+
}
|
|
664
|
+
declare class GladiaTimeoutError extends GladiaError {
|
|
665
|
+
constructor(message?: string);
|
|
666
|
+
}
|
|
667
|
+
declare class GladiaWebSocketError extends GladiaError {
|
|
668
|
+
readonly code?: number;
|
|
669
|
+
readonly reason?: string;
|
|
670
|
+
constructor(message: string, code?: number, reason?: string);
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
interface PollOptions<T> {
|
|
674
|
+
fn: () => Promise<T>;
|
|
675
|
+
isDone: (result: T) => boolean;
|
|
676
|
+
onPoll?: (result: T) => void;
|
|
677
|
+
/** Initial interval in ms (default: 1000) */
|
|
678
|
+
interval?: number;
|
|
679
|
+
/** Multiplier for exponential backoff (default: 1.5) */
|
|
680
|
+
backoffMultiplier?: number;
|
|
681
|
+
/** Maximum interval in ms (default: 10000) */
|
|
682
|
+
maxInterval?: number;
|
|
683
|
+
/** Maximum total time in ms (default: none) */
|
|
684
|
+
timeout?: number;
|
|
685
|
+
signal?: AbortSignal;
|
|
686
|
+
}
|
|
687
|
+
declare function poll<T>(options: PollOptions<T>): Promise<T>;
|
|
688
|
+
declare function isTerminalStatus(status: JobStatus): boolean;
|
|
689
|
+
|
|
690
|
+
export { type AddonAudioToLlmDTO, type AddonChapterizationDTO, type AddonError, type AddonGenericDTO, type AddonNerDTO, type AddonSentimentAnalysisDTO, type AddonSummarizationDTO, type AddonTranslationDTO, type ApiErrorBody, type AudioMetadata, type AudioToLlmConfig, type AudioToLlmResultEntry, BadRequestError, type CallbackConfig, type CallbackMethod, type Chapter, type CustomSpellingConfig, type CustomVocabularyConfig, type CustomVocabularyEntry, type DiarizationConfig, type FileResponse, ForbiddenError, GladiaApiError, GladiaClient, type GladiaClientConfig, GladiaError, GladiaTimeoutError, GladiaWebSocketError, type JobStatus, type LanguageConfig, type LiveAcknowledgmentMessage, type LiveBaseMessage, type LiveBitDepth, type LiveCallbackConfig, type LiveCreatedResponse, type LiveDoneMessage, type LiveEncoding, type LiveErrorMessage, type LiveEventMap, type LiveEventName, type LiveModel, type LivePostProcessingMessage, type LivePreProcessingMessage, type LiveReadyMessage, type LiveRealtimeProcessingMessage, type LiveRegion, type LiveRequest, type LiveRequestParams, LiveResource, type LiveResponse, type LiveSampleRate, LiveSession, type LiveSpeechBeginMessage, type LiveSpeechEndMessage, type LiveStreamOptions, type LiveTranscriptMessage, type LiveTranscriptionResult, type MessagesConfig, type NerEntity, NotFoundError, type PaginatedResponse, type PaginationParams, type PiiProcessedTextType, type PiiRedactionConfig, type PollOptions, type PostProcessingConfig, type PreProcessingConfig, type PreRecordedCreatedResponse, type PreRecordedRequest, PreRecordedResource, type PreRecordedResponse, type RealtimeProcessingConfig, type Sentiment, type SentimentAnalysisEntry, type StructuredDataExtractionConfig, type SubtitleFile, type SubtitleFormat, type SubtitleStyle, type SubtitlesConfig, type SummarizationConfig, type SummarizationType, type TranscribeOptions, type TranscriptionDTO, type TranscriptionMetadata, type TranscriptionResult, type TranslationConfig, type TranslationModel, type TranslationResultEntry, UnauthorizedError, UnprocessableEntityError, UploadResource, type UploadResponse, type Utterance, type Word, isTerminalStatus, poll };
|