@ssml-builder-js/azure-tts-client 2.19.0 → 2.19.1

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/dist/index.d.mts DELETED
@@ -1,538 +0,0 @@
1
- import { SsmlTextRange, SsmlSourceTextSegment, SsmlSourceMarker, SsmlDiagnostic, AzureValidationOptions } from '@ssml-builder-js/ssml-core';
2
- import * as SpeechSDK from 'microsoft-cognitiveservices-speech-sdk';
3
-
4
- declare const DEFAULT_OUTPUT_FORMAT = "audio-16khz-128kbitrate-mono-mp3";
5
- declare const OUTPUT_FORMATS: {
6
- "raw-8khz-8bit-mono-mulaw": SpeechSDK.SpeechSynthesisOutputFormat.Raw8Khz8BitMonoMULaw;
7
- "riff-16khz-16kbps-mono-siren": SpeechSDK.SpeechSynthesisOutputFormat.Riff16Khz16KbpsMonoSiren;
8
- "audio-16khz-16kbps-mono-siren": SpeechSDK.SpeechSynthesisOutputFormat.Audio16Khz16KbpsMonoSiren;
9
- "audio-16khz-32kbitrate-mono-mp3": SpeechSDK.SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3;
10
- "audio-16khz-128kbitrate-mono-mp3": SpeechSDK.SpeechSynthesisOutputFormat.Audio16Khz128KBitRateMonoMp3;
11
- "audio-16khz-64kbitrate-mono-mp3": SpeechSDK.SpeechSynthesisOutputFormat.Audio16Khz64KBitRateMonoMp3;
12
- "audio-24khz-48kbitrate-mono-mp3": SpeechSDK.SpeechSynthesisOutputFormat.Audio24Khz48KBitRateMonoMp3;
13
- "audio-24khz-96kbitrate-mono-mp3": SpeechSDK.SpeechSynthesisOutputFormat.Audio24Khz96KBitRateMonoMp3;
14
- "audio-24khz-160kbitrate-mono-mp3": SpeechSDK.SpeechSynthesisOutputFormat.Audio24Khz160KBitRateMonoMp3;
15
- "raw-16khz-16bit-mono-truesilk": SpeechSDK.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoTrueSilk;
16
- "riff-16khz-16bit-mono-pcm": SpeechSDK.SpeechSynthesisOutputFormat.Riff16Khz16BitMonoPcm;
17
- "riff-8khz-16bit-mono-pcm": SpeechSDK.SpeechSynthesisOutputFormat.Riff8Khz16BitMonoPcm;
18
- "riff-24khz-16bit-mono-pcm": SpeechSDK.SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm;
19
- "riff-8khz-8bit-mono-mulaw": SpeechSDK.SpeechSynthesisOutputFormat.Riff8Khz8BitMonoMULaw;
20
- "raw-16khz-16bit-mono-pcm": SpeechSDK.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoPcm;
21
- "raw-24khz-16bit-mono-pcm": SpeechSDK.SpeechSynthesisOutputFormat.Raw24Khz16BitMonoPcm;
22
- "raw-8khz-16bit-mono-pcm": SpeechSDK.SpeechSynthesisOutputFormat.Raw8Khz16BitMonoPcm;
23
- "ogg-16khz-16bit-mono-opus": SpeechSDK.SpeechSynthesisOutputFormat.Ogg16Khz16BitMonoOpus;
24
- "ogg-24khz-16bit-mono-opus": SpeechSDK.SpeechSynthesisOutputFormat.Ogg24Khz16BitMonoOpus;
25
- "raw-48khz-16bit-mono-pcm": SpeechSDK.SpeechSynthesisOutputFormat.Raw48Khz16BitMonoPcm;
26
- "riff-48khz-16bit-mono-pcm": SpeechSDK.SpeechSynthesisOutputFormat.Riff48Khz16BitMonoPcm;
27
- "audio-48khz-96kbitrate-mono-mp3": SpeechSDK.SpeechSynthesisOutputFormat.Audio48Khz96KBitRateMonoMp3;
28
- "audio-48khz-192kbitrate-mono-mp3": SpeechSDK.SpeechSynthesisOutputFormat.Audio48Khz192KBitRateMonoMp3;
29
- "ogg-48khz-16bit-mono-opus": SpeechSDK.SpeechSynthesisOutputFormat.Ogg48Khz16BitMonoOpus;
30
- "webm-16khz-16bit-mono-opus": SpeechSDK.SpeechSynthesisOutputFormat.Webm16Khz16BitMonoOpus;
31
- "webm-24khz-16bit-mono-opus": SpeechSDK.SpeechSynthesisOutputFormat.Webm24Khz16BitMonoOpus;
32
- "webm-24khz-16bit-24kbps-mono-opus": SpeechSDK.SpeechSynthesisOutputFormat.Webm24Khz16Bit24KbpsMonoOpus;
33
- "raw-24khz-16bit-mono-truesilk": SpeechSDK.SpeechSynthesisOutputFormat.Raw24Khz16BitMonoTrueSilk;
34
- "raw-8khz-8bit-mono-alaw": SpeechSDK.SpeechSynthesisOutputFormat.Raw8Khz8BitMonoALaw;
35
- "riff-8khz-8bit-mono-alaw": SpeechSDK.SpeechSynthesisOutputFormat.Riff8Khz8BitMonoALaw;
36
- "audio-16khz-16bit-32kbps-mono-opus": SpeechSDK.SpeechSynthesisOutputFormat.Audio16Khz16Bit32KbpsMonoOpus;
37
- "audio-24khz-16bit-48kbps-mono-opus": SpeechSDK.SpeechSynthesisOutputFormat.Audio24Khz16Bit48KbpsMonoOpus;
38
- "audio-24khz-16bit-24kbps-mono-opus": SpeechSDK.SpeechSynthesisOutputFormat.Audio24Khz16Bit24KbpsMonoOpus;
39
- "raw-22050hz-16bit-mono-pcm": SpeechSDK.SpeechSynthesisOutputFormat.Raw22050Hz16BitMonoPcm;
40
- "riff-22050hz-16bit-mono-pcm": SpeechSDK.SpeechSynthesisOutputFormat.Riff22050Hz16BitMonoPcm;
41
- "raw-44100hz-16bit-mono-pcm": SpeechSDK.SpeechSynthesisOutputFormat.Raw44100Hz16BitMonoPcm;
42
- "riff-44100hz-16bit-mono-pcm": SpeechSDK.SpeechSynthesisOutputFormat.Riff44100Hz16BitMonoPcm;
43
- "amr-wb-16000hz": SpeechSDK.SpeechSynthesisOutputFormat.AmrWb16000Hz;
44
- "g722-16khz-64kbps": SpeechSDK.SpeechSynthesisOutputFormat.G72216Khz64Kbps;
45
- };
46
- type AzureTtsOutputFormat = keyof typeof OUTPUT_FORMATS;
47
- declare function resolveMimeType(outputFormat: string): string;
48
-
49
- type SynthesisErrorKind = "validation-error" | "azure-api-error" | "merge-error" | "audio-format-mismatch" | "unsupported-format-error" | "cancelled" | "timeout" | "incomplete-chunk-set";
50
- type SerializedChunkErrorCode = "VALIDATION_ERROR" | "AZURE_API_ERROR" | "TIMEOUT" | "CANCELLED" | "MERGE_ERROR" | "FORMAT_MISMATCH";
51
- interface SerializedChunkError {
52
- code: SerializedChunkErrorCode;
53
- phase: "url-validation" | "synthesis" | "merge";
54
- message: string;
55
- isOriginalFailure: boolean;
56
- isRetryable: boolean;
57
- httpStatus?: number;
58
- details?: Record<string, unknown>;
59
- }
60
- /** Backward-compatible name used by persisted execution-state consumers. */
61
- type SerializedExecutionError = SerializedChunkError;
62
- declare class AzureTtsError extends Error {
63
- readonly kind: "azure-api-error";
64
- readonly status: number;
65
- readonly statusText: string;
66
- readonly responseBody: string;
67
- readonly requestId: string | null;
68
- readonly retryAfterMs?: number;
69
- constructor(status: number, statusText: string, responseBody: string, requestId: string | null, responseHeaders?: Headers | Readonly<Record<string, string>>);
70
- }
71
- /** Reads Retry-After from an error-like value, returning milliseconds when present. */
72
- declare function getRetryAfterDelayMs(error: unknown): number | undefined;
73
- declare class AzureTtsSdkError extends AzureTtsError {
74
- readonly errorDetails: string;
75
- constructor(errorDetails: string);
76
- }
77
- declare class SynthesisCancelledError extends Error {
78
- readonly kind: "cancelled";
79
- constructor(message?: string);
80
- }
81
- declare class SynthesisTimeoutError extends Error {
82
- readonly kind: "timeout";
83
- constructor(message: string);
84
- }
85
- declare class IncompleteChunkSetError extends Error {
86
- readonly kind: "incomplete-chunk-set";
87
- readonly totalChunks: number;
88
- readonly missingChunkIndices: readonly number[];
89
- constructor(totalChunks: number, missingChunkIndices: readonly number[]);
90
- }
91
- declare class MergeError extends Error {
92
- readonly kind: "merge-error";
93
- readonly cause: unknown;
94
- constructor(message: string, cause?: unknown);
95
- }
96
- /** Thrown when chunk headers describe incompatible audio streams. */
97
- declare class AudioFormatMismatchError extends Error {
98
- readonly kind: "audio-format-mismatch";
99
- readonly inputSpecs: readonly AudioSpecification[];
100
- constructor(message: string, inputSpecs?: readonly AudioSpecification[]);
101
- }
102
- /** Thrown when audio buffers require container re-multiplexing before they can be merged. */
103
- declare class UnsupportedMergeFormatError extends Error {
104
- readonly kind: "unsupported-format-error";
105
- readonly format: string;
106
- constructor(format: string);
107
- }
108
- type AzureTtsSynthesisError = AzureTtsError | MergeError | AudioFormatMismatchError | UnsupportedMergeFormatError | SynthesisCancelledError | SynthesisTimeoutError | IncompleteChunkSetError;
109
- declare function serializeChunkError(error: unknown, phase: SerializedChunkError["phase"], isOriginalFailure: boolean): SerializedChunkError;
110
-
111
- interface TtsConfig {
112
- signal?: AbortSignal;
113
- timeoutMs?: number;
114
- timeouts?: SynthesisTimeouts;
115
- endpoint?: string;
116
- subscriptionKey: string;
117
- region: string;
118
- outputFormat?: string;
119
- customHeaders?: Readonly<Record<string, string>>;
120
- fingerprintSchemaVersion?: string;
121
- /** Original plain-text range represented by this synthesis request. */
122
- sourceTextRange?: {
123
- start: number;
124
- end: number;
125
- };
126
- /** Reports chunk lifecycle events when using chunk synthesis. */
127
- onProgress?: (event: SynthesisProgressEvent) => void;
128
- /** Metadata used to map synchronization events back to the source document. */
129
- chunkIndex?: number;
130
- sourceNodePath?: string[];
131
- /** Exact source text segments used to map individual Azure events. */
132
- sourceTextSegments?: SsmlSourceTextSegment[];
133
- sourceMarkers?: SsmlSourceMarker[];
134
- concurrency?: number;
135
- retryOptions?: RetryOptions;
136
- cancelOnFailure?: boolean;
137
- resumeChunks?: readonly SynthesizedChunk[];
138
- resumeChunkIndices?: readonly number[];
139
- customMerger?: CustomAudioMerger;
140
- outputMimeType?: string;
141
- postMergeValidator?: PostMergeValidator;
142
- resumeValidation?: ResumeValidationMode;
143
- }
144
- type MappingStatus = "exact" | "fallback" | "unmapped";
145
- interface AudioSpecification {
146
- format: string;
147
- mimeType: string;
148
- codec: "pcm" | "mulaw" | "alaw" | "siren" | "mp3" | "opus" | "silk" | "unknown";
149
- sampleRate: number;
150
- channels: number;
151
- bitrate?: number;
152
- bitDepth?: number;
153
- container?: string;
154
- isVbr?: boolean;
155
- isCompressed: boolean;
156
- }
157
- type ResumeValidationMode = "strict" | "disabled";
158
- interface SynthesisTimeouts {
159
- urlValidationMs?: number;
160
- perChunkMs?: number;
161
- chunkWithRetriesMs?: number;
162
- totalJobMs?: number;
163
- }
164
- interface RetryOptions {
165
- maxRetries: number;
166
- initialDelayMs: number;
167
- maxDelayMs: number;
168
- shouldRetry?: (error: unknown, attempt: number) => boolean;
169
- }
170
- type SynthesisChunkStatus = "pending" | "synthesizing" | "success" | "failed";
171
- interface SsmlSynthesisBoundary {
172
- text: string;
173
- audioOffsetMs: number;
174
- durationMs: number;
175
- textRange?: {
176
- start: number;
177
- end: number;
178
- };
179
- /** Chunk that produced this event. */
180
- chunkIndex?: number;
181
- /** Path of the source SSML node, when available. */
182
- sourceNodePath?: string[];
183
- /** Original text range represented by this event. */
184
- originalTextRange?: SsmlTextRange;
185
- /** Audio offset within the originating chunk before merge. */
186
- chunkAudioOffsetMs?: number;
187
- requestId?: string;
188
- mappingStatus: MappingStatus;
189
- }
190
- interface SsmlSynthesisViseme {
191
- visemeId: number;
192
- audioOffsetMs: number;
193
- textRange?: {
194
- start: number;
195
- end: number;
196
- };
197
- chunkIndex?: number;
198
- sourceNodePath?: string[];
199
- originalTextRange?: SsmlTextRange;
200
- chunkAudioOffsetMs?: number;
201
- requestId?: string;
202
- mappingStatus: MappingStatus;
203
- }
204
- interface SsmlSynthesisBookmark {
205
- name: string;
206
- audioOffsetMs: number;
207
- textRange?: {
208
- start: number;
209
- end: number;
210
- };
211
- chunkIndex?: number;
212
- sourceNodePath?: string[];
213
- originalTextRange?: SsmlTextRange;
214
- chunkAudioOffsetMs?: number;
215
- requestId?: string;
216
- mappingStatus: MappingStatus;
217
- }
218
- /** Audio and Azure Speech synchronization events emitted for one SSML request. */
219
- interface SsmlSynthesisResult {
220
- audioData: ArrayBuffer;
221
- durationMs: number;
222
- boundaries?: SsmlSynthesisBoundary[];
223
- /** Alias matching the Azure Speech event name. */
224
- wordBoundary?: SsmlSynthesisBoundary[];
225
- /** Alias for consumers that use Azure's word-boundary terminology. */
226
- wordBoundaries?: SsmlSynthesisBoundary[];
227
- visemes?: SsmlSynthesisViseme[];
228
- bookmarks?: SsmlSynthesisBookmark[];
229
- /** Request identifier returned by Azure Speech, when available. */
230
- requestId?: string;
231
- /** Original plain-text range represented by the result. */
232
- textRange?: {
233
- start: number;
234
- end: number;
235
- };
236
- /** MIME type of a result produced by an explicit merge operation. */
237
- mimeType?: string;
238
- audioSpec?: AudioSpecification;
239
- }
240
- interface MergedSynthesisResult extends SsmlSynthesisResult {
241
- mimeType: string;
242
- }
243
- interface SsmlSynthesisChunk {
244
- ssml: string;
245
- originalTextRange?: {
246
- start: number;
247
- end: number;
248
- };
249
- sourceNodePath?: string[];
250
- sourceTextSegments?: SsmlSourceTextSegment[];
251
- sourceMarkers?: SsmlSourceMarker[];
252
- }
253
- interface SynthesizeChunksOptions {
254
- onProgress?: (event: SynthesisProgressEvent) => void;
255
- outputFormat?: AzureTtsOutputFormat | string;
256
- customHeaders?: Readonly<Record<string, string>>;
257
- fingerprintSchemaVersion?: string;
258
- signal?: AbortSignal;
259
- timeoutMs?: number;
260
- timeouts?: SynthesisTimeouts;
261
- sourceNodePath?: string[];
262
- concurrency?: number;
263
- retryOptions?: RetryOptions;
264
- cancelOnFailure?: boolean;
265
- resumeChunks?: readonly SynthesizedChunk[];
266
- resumeChunkIndices?: readonly number[];
267
- customMerger?: CustomAudioMerger;
268
- outputMimeType?: string;
269
- postMergeValidator?: PostMergeValidator;
270
- resumeValidation?: ResumeValidationMode;
271
- }
272
- interface CustomMergerContext {
273
- format: string;
274
- outputMimeType: string;
275
- inputSpecs: readonly AudioSpecification[];
276
- signal: AbortSignal;
277
- }
278
- type CustomAudioMerger = (buffers: ArrayBuffer[], context: CustomMergerContext) => Promise<ArrayBuffer> | ArrayBuffer;
279
- type PostMergeValidator = (result: MergedSynthesisResult, context: CustomMergerContext) => boolean | undefined | Promise<boolean | undefined>;
280
- interface SynthesizedChunk extends SsmlSynthesisResult {
281
- chunkIndex: number;
282
- /** Fingerprint of the SSML and synthesis settings used to create this chunk. */
283
- fingerprint: string;
284
- }
285
- type ChunkExecutionStatus = "succeeded" | "failed" | "cancelled" | "pending";
286
- interface ChunkExecutionState {
287
- chunkIndex: number;
288
- status: ChunkExecutionStatus;
289
- error?: SerializedChunkError;
290
- isOriginalFailure?: boolean;
291
- canResume: boolean;
292
- result?: SsmlSynthesisResult;
293
- }
294
- interface PartialChunkSynthesisResult {
295
- synthesizedChunks: readonly SynthesizedChunk[];
296
- completedChunks: readonly SynthesizedChunk[];
297
- pendingChunkIndices: readonly number[];
298
- failedChunkIndices: readonly number[];
299
- cancelledChunkIndices: readonly number[];
300
- chunkStates: readonly ChunkExecutionState[];
301
- totalChunks: number;
302
- }
303
- /** Alias for applications that use the shorter result name. */
304
- type PartialSynthesisResult = PartialChunkSynthesisResult;
305
- interface SynthesisProgressEvent {
306
- /** 1-based completed chunk count retained for backward compatibility. */
307
- currentChunk: number;
308
- totalChunks: number;
309
- percent: number;
310
- chunkIndex: number;
311
- originalTextRange?: SsmlTextRange;
312
- status: SynthesisChunkStatus;
313
- durationMs: number;
314
- error?: unknown;
315
- retryAttempt?: number;
316
- nextRetryDelayMs?: number;
317
- isRetrying?: boolean;
318
- }
319
- interface AzureTtsLogger {
320
- debug?: (...args: unknown[]) => void;
321
- info?: (...args: unknown[]) => void;
322
- warn?: (...args: unknown[]) => void;
323
- error?: (...args: unknown[]) => void;
324
- }
325
- interface AzureTtsClientOptions {
326
- signal?: AbortSignal;
327
- timeoutMs?: number;
328
- timeouts?: SynthesisTimeouts;
329
- subscriptionKey: string;
330
- region: string;
331
- endpoint?: string;
332
- outputFormat?: string;
333
- customHeaders?: Readonly<Record<string, string>>;
334
- fingerprintSchemaVersion?: string;
335
- logger?: AzureTtsLogger;
336
- onProgress?: (event: SynthesisProgressEvent) => void;
337
- concurrency?: number;
338
- retryOptions?: RetryOptions;
339
- cancelOnFailure?: boolean;
340
- customMerger?: CustomAudioMerger;
341
- outputMimeType?: string;
342
- postMergeValidator?: PostMergeValidator;
343
- resumeValidation?: ResumeValidationMode;
344
- }
345
-
346
- /** Coordinates one absolute deadline across validation, synthesis, retries, and merging. */
347
- declare class DeadlineController {
348
- #private;
349
- readonly deadlineAtMs: number | undefined;
350
- readonly signal: AbortSignal;
351
- constructor(totalJobMs: number | undefined, parent?: AbortSignal);
352
- get timedOut(): boolean;
353
- get remainingMs(): number;
354
- throwIfExpired(): void;
355
- abort(): void;
356
- dispose(): void;
357
- }
358
-
359
- interface SsmlValidationError {
360
- readonly kind: "validation-error";
361
- readonly message: string;
362
- readonly diagnostics: readonly SsmlDiagnostic[];
363
- }
364
- type SsmlSynthesisError = SsmlValidationError | AzureTtsSynthesisError;
365
- declare class ChunkValidationError extends Error {
366
- readonly kind: "validation-error";
367
- readonly chunkIndex: number;
368
- readonly diagnostics: readonly SsmlDiagnostic[];
369
- constructor(chunkIndex: number, diagnostics: readonly SsmlDiagnostic[]);
370
- }
371
- interface ChunkDiagnostics {
372
- readonly chunkIndex: number;
373
- readonly diagnostics: readonly SsmlDiagnostic[];
374
- }
375
- declare class BatchChunkValidationError extends ChunkValidationError {
376
- readonly chunkDiagnostics: readonly ChunkDiagnostics[];
377
- readonly totalErrorCount: number;
378
- readonly errorCount: number;
379
- readonly totalErrors: number;
380
- constructor(chunkDiagnostics: readonly ChunkDiagnostics[]);
381
- }
382
- type Result<T, E> = {
383
- readonly ok: true;
384
- readonly success: true;
385
- readonly status: "success";
386
- readonly value: T;
387
- } | (E extends {
388
- readonly kind: infer Kind extends SynthesisErrorKind;
389
- } ? {
390
- readonly ok: false;
391
- readonly success: false;
392
- readonly status: Kind;
393
- readonly error: E;
394
- readonly partialResult?: PartialChunkSynthesisResult;
395
- } : {
396
- readonly ok: false;
397
- readonly success: false;
398
- readonly status: SynthesisErrorKind;
399
- readonly error: E;
400
- readonly partialResult?: PartialChunkSynthesisResult;
401
- });
402
- type SynthesisResult<T, E> = Result<T, E>;
403
- type Success<T> = Extract<Result<T, never>, {
404
- readonly ok: true;
405
- }>;
406
- type ValidationErrorResult = Extract<Result<never, SsmlValidationError>, {
407
- readonly status: "validation-error";
408
- }>;
409
- type AzureApiErrorResult = Extract<Result<never, AzureTtsError>, {
410
- readonly status: "azure-api-error";
411
- }>;
412
- type SsmlSynthesisSafeResult = Result<SsmlSynthesisResult, never> | Result<never, SsmlValidationError> | Result<never, SsmlSynthesisError>;
413
- interface SynthesizeSsmlSafeOptions extends AzureValidationOptions {
414
- /** Optional nested form for callers that want to keep validation settings grouped. */
415
- validation?: AzureValidationOptions;
416
- signal?: AbortSignal;
417
- timeouts?: SynthesisTimeouts;
418
- }
419
- interface SynthesizeSsmlChunksSafeOptions extends AzureValidationOptions {
420
- validation?: AzureValidationOptions;
421
- outputFormat?: string;
422
- customHeaders?: Readonly<Record<string, string>>;
423
- fingerprintSchemaVersion?: string;
424
- signal?: AbortSignal;
425
- timeoutMs?: number;
426
- timeouts?: SynthesisTimeouts;
427
- sourceNodePath?: string[];
428
- onProgress?: (event: SynthesisProgressEvent) => void;
429
- concurrency?: number;
430
- retryOptions?: RetryOptions;
431
- cancelOnFailure?: boolean;
432
- resumeChunks?: readonly SynthesizedChunk[];
433
- resumeChunkIndices?: readonly number[];
434
- customMerger?: CustomAudioMerger;
435
- outputMimeType?: string;
436
- postMergeValidator?: PostMergeValidator;
437
- resumeValidation?: ResumeValidationMode;
438
- }
439
- type SsmlSynthesisChunksSafeResult = Result<SsmlSynthesisResult, never> | Result<never, ChunkValidationError> | Result<never, BatchChunkValidationError> | Result<never, SsmlSynthesisError | ChunkValidationError>;
440
- interface SynthesisClient {
441
- synthesizeSsml(ssml: string, options?: Partial<SynthesizeChunksOptions>): Promise<SsmlSynthesisResult>;
442
- synthesizeChunks?(chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeChunksOptions): Promise<SsmlSynthesisResult>;
443
- }
444
- /** Validates SSML before invoking Azure and converts validation/API failures to one result shape. */
445
- declare function synthesizeSsmlSafe(client: Pick<AzureTtsClient, "synthesizeSsml"> | SynthesisClient, ssml: string, options?: SynthesizeSsmlSafeOptions): Promise<SsmlSynthesisSafeResult>;
446
- /** Validates every chunk before synthesis and returns a chunk-addressable result. */
447
- declare function synthesizeSsmlChunksSafe(client: Pick<AzureTtsClient, "synthesizeSsml" | "synthesizeChunks"> | SynthesisClient, chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeSsmlChunksSafeOptions): Promise<SsmlSynthesisChunksSafeResult>;
448
-
449
- declare class AzureTtsClient {
450
- #private;
451
- constructor(options: AzureTtsClientOptions);
452
- synthesize(ssml: string): Promise<ArrayBuffer>;
453
- synthesizeSsml(ssml: string, options?: Partial<TtsConfig>): Promise<SsmlSynthesisResult>;
454
- synthesizeChunks(chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeChunksOptions): Promise<SsmlSynthesisResult>;
455
- synthesizeSsmlSafe(ssml: string, options?: SynthesizeSsmlSafeOptions): Promise<SsmlSynthesisSafeResult>;
456
- synthesizeChunksSafe(chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeSsmlChunksSafeOptions): Promise<SsmlSynthesisChunksSafeResult>;
457
- synthesizeSsmlChunksSafe(chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeSsmlChunksSafeOptions): Promise<SsmlSynthesisChunksSafeResult>;
458
- }
459
-
460
- type MergeAudioFormat = "wav" | "mp3" | "raw";
461
- interface MergeAudioOptions {
462
- format: AzureTtsOutputFormat;
463
- signal?: AbortSignal;
464
- outputMimeType?: string;
465
- }
466
- type InputAudioSpecs = AudioSpecification[];
467
- /**
468
- * Creates a deterministic, runtime-independent fingerprint for a synthesis chunk.
469
- * The complete SSML is included so changes to voice, language, prosody, or text
470
- * invalidate a cached result even when those settings are nested in the markup.
471
- */
472
- interface ChunkFingerprintOptions {
473
- outputFormat?: string;
474
- region?: string;
475
- endpoint?: string;
476
- voice?: string;
477
- lang?: string;
478
- schemaVersion?: string;
479
- fingerprintSchemaVersion?: string;
480
- customHeaders?: Readonly<Record<string, string>>;
481
- }
482
- declare function computeChunkFingerprint(ssml: string, outputFormat?: string, options?: Omit<ChunkFingerprintOptions, "outputFormat">): string;
483
- interface MergeSynthesisOptions extends MergeAudioOptions {
484
- customMerger?: CustomAudioMerger;
485
- postMergeValidator?: PostMergeValidator;
486
- deadline?: DeadlineController;
487
- }
488
- type AsyncMergeSynthesisOptions = MergeSynthesisOptions & {
489
- customMerger: NonNullable<MergeSynthesisOptions["customMerger"]>;
490
- };
491
- /** Extracts the stream specification from a WAV/MP3 header and output-format fallback. */
492
- declare function inspectAudioSpecification(buffer: ArrayBuffer, format: string): AudioSpecification;
493
- /** Returns whether the named output format can be safely concatenated without re-multiplexing. */
494
- declare function resolveMergeAudioFormat(format: string): MergeAudioFormat | undefined;
495
- declare function canMergeAudioFormat(format: string): boolean;
496
- /** Merges audio buffers while preserving the invariants of supported containers. */
497
- declare function mergeAudioBuffers(buffers: readonly ArrayBuffer[], options: MergeAudioOptions): ArrayBuffer;
498
- /** Synthesizes one SSML document, optionally retrying transient failures within the job deadline. */
499
- declare function synthesizeSsml(ssml: string, config: TtsConfig): Promise<SsmlSynthesisResult>;
500
- /** Synthesizes chunks with bounded concurrency, retries transient failures, and merges in chunk order. */
501
- declare function synthesizeSsmlChunks(chunks: readonly (SsmlSynthesisChunk | string)[], config: TtsConfig): Promise<SsmlSynthesisResult>;
502
- declare function mergeSynthesisResults(results: readonly SsmlSynthesisResult[], options: AsyncMergeSynthesisOptions): Promise<MergedSynthesisResult>;
503
- declare function mergeSynthesisResults(results: readonly SsmlSynthesisResult[], options: MergeSynthesisOptions): MergedSynthesisResult | Promise<MergedSynthesisResult>;
504
- declare function mergeSynthesisResults(results: readonly SsmlSynthesisResult[], options: MergeAudioOptions): MergedSynthesisResult;
505
- /** Backward-compatible audio-only synthesis helper. */
506
- declare function synthesizeSpeech(ssml: string, config: TtsConfig): Promise<ArrayBuffer>;
507
-
508
- interface FetchAzureVoiceCatalogOptions {
509
- apiKey: string;
510
- region: string | string[];
511
- }
512
- interface AzureVoiceCatalogVoice {
513
- name: string;
514
- locale: string;
515
- secondaryLocales?: readonly string[];
516
- styles?: readonly string[];
517
- supportedTags?: readonly string[];
518
- unsupportedTags?: readonly string[];
519
- models?: readonly string[];
520
- regions: readonly string[];
521
- status?: "ga" | "preview" | "deprecated";
522
- }
523
- interface FetchedAzureVoiceCatalogMetadata {
524
- voiceCount: number;
525
- generatedAt: string;
526
- apiVersion: string;
527
- regions: readonly string[];
528
- expiresAt?: string;
529
- regionDiffs?: Readonly<Record<string, readonly string[]>>;
530
- }
531
- interface AzureVoiceCatalog {
532
- voices: readonly AzureVoiceCatalogVoice[];
533
- metadata: FetchedAzureVoiceCatalogMetadata;
534
- }
535
- /** Fetches and deduplicates the current Azure Speech voice catalog for one or more regions. */
536
- declare function fetchAzureVoiceCatalog(options: FetchAzureVoiceCatalogOptions): Promise<AzureVoiceCatalog>;
537
-
538
- export { AudioFormatMismatchError, type AudioSpecification, type AzureApiErrorResult, type SsmlValidationError as AzureSsmlValidationError, AzureTtsClient, type AzureTtsClientOptions, AzureTtsError, type AzureTtsLogger, type AzureTtsOutputFormat, AzureTtsSdkError, type AzureTtsSynthesisError, type AzureVoiceCatalog, type AzureVoiceCatalogVoice, BatchChunkValidationError, type ChunkDiagnostics, type ChunkExecutionState, type ChunkExecutionStatus, type ChunkFingerprintOptions, ChunkValidationError, type CustomAudioMerger, type CustomMergerContext, DEFAULT_OUTPUT_FORMAT, DeadlineController, type FetchAzureVoiceCatalogOptions, type FetchedAzureVoiceCatalogMetadata, IncompleteChunkSetError, type InputAudioSpecs, type MappingStatus, type MergeAudioFormat, type MergeAudioOptions, MergeError, type MergeSynthesisOptions, type MergedSynthesisResult, type PartialChunkSynthesisResult, type PartialSynthesisResult, type PostMergeValidator, type Result, type ResumeValidationMode, type RetryOptions, type SerializedChunkError, type SerializedChunkErrorCode, type SerializedExecutionError, type SsmlSynthesisBookmark, type SsmlSynthesisBoundary, type SsmlSynthesisChunk, type SsmlSynthesisChunksSafeResult, type SsmlSynthesisError, type SsmlSynthesisResult, type SsmlSynthesisSafeResult, type SsmlSynthesisViseme, type Success, SynthesisCancelledError, type SynthesisChunkStatus, type SynthesisErrorKind, type SynthesisProgressEvent, type SynthesisResult, SynthesisTimeoutError, type SynthesisTimeouts, type SynthesizeChunksOptions, type SynthesizeSsmlChunksSafeOptions, type SynthesizeSsmlSafeOptions, type SynthesizedChunk, type TtsConfig, UnsupportedMergeFormatError, type ValidationErrorResult, canMergeAudioFormat, computeChunkFingerprint, fetchAzureVoiceCatalog, getRetryAfterDelayMs, inspectAudioSpecification, mergeAudioBuffers, mergeSynthesisResults, resolveMergeAudioFormat, resolveMimeType, serializeChunkError, synthesizeSpeech, synthesizeSsml, synthesizeSsmlChunks, synthesizeSsmlChunksSafe, synthesizeSsmlSafe };