ssml-builder-js 2.16.0 → 2.17.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/dist/elements.mjs CHANGED
@@ -33,12 +33,12 @@ import {
33
33
  registerSsmlCompletionProvider,
34
34
  resolveExpressAsStyles,
35
35
  updateEditableText
36
- } from "./chunk-F2EMU3HM.mjs";
36
+ } from "./chunk-SLZ7PE6W.mjs";
37
37
  import {
38
38
  buildSsml,
39
39
  parseSsml,
40
40
  validateAzureSsml
41
- } from "./chunk-HI74FTKY.mjs";
41
+ } from "./chunk-5AZWURHW.mjs";
42
42
  import "./chunk-6S5ODO6A.mjs";
43
43
 
44
44
  // packages/ssml-editor-react/src/ssmlInsertions.ts
@@ -264,4 +264,15 @@ interface AzureUrlValidationRunnerOptions {
264
264
  timeoutMs?: number;
265
265
  }
266
266
 
267
- export type { AzureValidationOptions as A, SsmlTextRange as S, SsmlSourceTextSegment as a, SsmlSourceMarker as b, SsmlDiagnostic as c, SsmlDocument as d, SsmlElement as e };
267
+ interface AzureVoiceCatalogMetadata {
268
+ apiVersion: string;
269
+ generatedAt: string;
270
+ regions: readonly string[];
271
+ voiceCount: number;
272
+ /** When the bundled snapshot should be refreshed. */
273
+ expiresAt?: string;
274
+ /** Region-specific catalog differences, when known. */
275
+ regionDiffs?: Readonly<Record<string, readonly string[]>>;
276
+ }
277
+
278
+ export type { AzureValidationOptions as A, SsmlTextRange as S, SsmlSourceTextSegment as a, SsmlSourceMarker as b, SsmlDiagnostic as c, SsmlDocument as d, SsmlElement as e, AzureVoiceCatalogMetadata as f };
@@ -264,4 +264,15 @@ interface AzureUrlValidationRunnerOptions {
264
264
  timeoutMs?: number;
265
265
  }
266
266
 
267
- export type { AzureValidationOptions as A, SsmlTextRange as S, SsmlSourceTextSegment as a, SsmlSourceMarker as b, SsmlDiagnostic as c, SsmlDocument as d, SsmlElement as e };
267
+ interface AzureVoiceCatalogMetadata {
268
+ apiVersion: string;
269
+ generatedAt: string;
270
+ regions: readonly string[];
271
+ voiceCount: number;
272
+ /** When the bundled snapshot should be refreshed. */
273
+ expiresAt?: string;
274
+ /** Region-specific catalog differences, when known. */
275
+ regionDiffs?: Readonly<Record<string, readonly string[]>>;
276
+ }
277
+
278
+ export type { AzureValidationOptions as A, SsmlTextRange as S, SsmlSourceTextSegment as a, SsmlSourceMarker as b, SsmlDiagnostic as c, SsmlDocument as d, SsmlElement as e, AzureVoiceCatalogMetadata as f };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { AudioElement, AzureDiagnosticCode, AzureLanguageNormalizationOptions, AzureSsmlValidationOptions, AzureUrlValidationResult, AzureUrlValidationRunnerOptions, AzureUrlValidator, AzureValidationOptions, AzureVoiceCatalogMetadata, AzureVoiceDefinition, AzureVoiceMetadata, BookmarkElement, BreakElement, BuildPartialSsmlOptions, CustomElement, Diagnostic, EmphasisElement, ExpressAsElement, ExtractSsmlTranslatableTextOptions, FromPlainTextToSsmlOptions, LangElement, LexiconElement, MapSsmlTextNodesOptions, MarkElement, MsttsAudioDurationElement, MsttsEmbeddingElement, MsttsSilenceElement, MsttsTtsEmbeddingElement, MsttsVisemeElement, MsttsVoiceConversionElement, NamedElement, ParagraphElement, PhonemeElement, ProsodyElement, SayAsElement, SentenceElement, SplitSsmlOptions, SsmlAttributeValue, SsmlAttributes, SsmlBackgroundAudioNode, SsmlBreakElement, SsmlChunk, SsmlChunkContext, SsmlDiagnostic, SsmlDiagnosticSeverity, SsmlDiagnosticSource, SsmlDialogNode, SsmlDocument, SsmlElement, SsmlElementBase, SsmlEmbeddingNode, SsmlExpressAsElement, SsmlNode, SsmlPartialContext, SsmlPartialProsody, SsmlPartialVoice, SsmlPhonemeElement, SsmlProsodyElement, SsmlSayAsElement, SsmlSourceMap, SsmlSourceMarker, SsmlSourceTextSegment, SsmlStructureIntegrityResult, SsmlStructureMismatch, SsmlText, SsmlTextNodeContext, SsmlTextRange, SsmlTtsEmbeddingNode, SsmlTurnNode, SsmlValidationError, SsmlVoiceConversionNode, SsmlVoiceElement, SubElement, VoiceElement, WordElement, areAzureLanguagesEquivalent, buildPartialSsml, buildSsml, createAzureUrlValidatorRunner, extractSsmlText, extractSsmlTranslatableText, fromPlainTextToSsml, getAzureVoiceCatalogMetadata, getBuiltInVoiceCatalogMetadata, getSsmlSourceMap, isValidAzureAudioDuration, mapSsmlTextNodes, normalizeAzureLanguage, parseSsml, splitSsmlDocument, validateAzureSsml, validateAzureSsmlChunks, validateSsml, validateSsmlStructureIntegrity } from './core.mjs';
2
- import { S as SsmlTextRange, a as SsmlSourceTextSegment, b as SsmlSourceMarker, c as SsmlDiagnostic, A as AzureValidationOptions } from './index.d-DR5Qz43p.mjs';
2
+ import { S as SsmlTextRange, a as SsmlSourceTextSegment, b as SsmlSourceMarker, c as SsmlDiagnostic, A as AzureValidationOptions } from './index.d-tpKoP1jl.mjs';
3
3
  import * as SpeechSDK from 'microsoft-cognitiveservices-speech-sdk';
4
4
 
5
5
  declare const DEFAULT_OUTPUT_FORMAT = "audio-16khz-128kbitrate-mono-mp3";
@@ -50,6 +50,7 @@ declare function resolveMimeType(outputFormat: string): string;
50
50
  interface TtsConfig {
51
51
  signal?: AbortSignal;
52
52
  timeoutMs?: number;
53
+ timeouts?: SynthesisTimeouts;
53
54
  endpoint?: string;
54
55
  subscriptionKey: string;
55
56
  region: string;
@@ -69,6 +70,12 @@ interface TtsConfig {
69
70
  sourceMarkers?: SsmlSourceMarker[];
70
71
  concurrency?: number;
71
72
  retryOptions?: RetryOptions;
73
+ cancelOnFailure?: boolean;
74
+ resumeChunks?: readonly SynthesizedChunk[];
75
+ resumeChunkIndices?: readonly number[];
76
+ customMerger?: CustomAudioMerger;
77
+ outputMimeType?: string;
78
+ postMergeValidator?: PostMergeValidator;
72
79
  }
73
80
  type MappingStatus = "exact" | "fallback" | "unmapped";
74
81
  interface AudioSpecification {
@@ -78,12 +85,22 @@ interface AudioSpecification {
78
85
  sampleRate: number;
79
86
  channels: number;
80
87
  bitrate?: number;
88
+ bitDepth?: number;
89
+ container?: string;
90
+ isVbr?: boolean;
81
91
  isCompressed: boolean;
82
92
  }
93
+ interface SynthesisTimeouts {
94
+ urlValidationMs?: number;
95
+ perChunkMs?: number;
96
+ chunkWithRetriesMs?: number;
97
+ totalJobMs?: number;
98
+ }
83
99
  interface RetryOptions {
84
100
  maxRetries: number;
85
101
  initialDelayMs: number;
86
102
  maxDelayMs: number;
103
+ shouldRetry?: (error: unknown, attempt: number) => boolean;
87
104
  }
88
105
  type SynthesisChunkStatus = "pending" | "synthesizing" | "success" | "failed";
89
106
  interface SsmlSynthesisBoundary {
@@ -173,10 +190,37 @@ interface SynthesizeChunksOptions {
173
190
  outputFormat?: AzureTtsOutputFormat | string;
174
191
  signal?: AbortSignal;
175
192
  timeoutMs?: number;
193
+ timeouts?: SynthesisTimeouts;
176
194
  sourceNodePath?: string[];
177
195
  concurrency?: number;
178
196
  retryOptions?: RetryOptions;
197
+ cancelOnFailure?: boolean;
198
+ resumeChunks?: readonly SynthesizedChunk[];
199
+ resumeChunkIndices?: readonly number[];
200
+ customMerger?: CustomAudioMerger;
201
+ outputMimeType?: string;
202
+ postMergeValidator?: PostMergeValidator;
203
+ }
204
+ interface CustomMergerContext {
205
+ format: string;
206
+ outputMimeType: string;
207
+ inputSpecs: readonly AudioSpecification[];
208
+ signal: AbortSignal;
209
+ }
210
+ type CustomAudioMerger = (buffers: ArrayBuffer[], context: CustomMergerContext) => Promise<ArrayBuffer> | ArrayBuffer;
211
+ type PostMergeValidator = (result: MergedSynthesisResult, context: CustomMergerContext) => boolean | undefined | Promise<boolean | undefined>;
212
+ interface SynthesizedChunk extends SsmlSynthesisResult {
213
+ chunkIndex: number;
214
+ }
215
+ interface PartialChunkSynthesisResult {
216
+ synthesizedChunks: readonly SynthesizedChunk[];
217
+ completedChunks: readonly SynthesizedChunk[];
218
+ pendingChunkIndices: readonly number[];
219
+ failedChunkIndices: readonly number[];
220
+ totalChunks: number;
179
221
  }
222
+ /** Alias for applications that use the shorter result name. */
223
+ type PartialSynthesisResult = PartialChunkSynthesisResult;
180
224
  interface SynthesisProgressEvent {
181
225
  /** 1-based completed chunk count retained for backward compatibility. */
182
226
  currentChunk: number;
@@ -200,6 +244,7 @@ interface AzureTtsLogger {
200
244
  interface AzureTtsClientOptions {
201
245
  signal?: AbortSignal;
202
246
  timeoutMs?: number;
247
+ timeouts?: SynthesisTimeouts;
203
248
  subscriptionKey: string;
204
249
  region: string;
205
250
  endpoint?: string;
@@ -217,8 +262,11 @@ declare class AzureTtsError extends Error {
217
262
  readonly statusText: string;
218
263
  readonly responseBody: string;
219
264
  readonly requestId: string | null;
220
- constructor(status: number, statusText: string, responseBody: string, requestId: string | null);
265
+ readonly retryAfterMs?: number;
266
+ constructor(status: number, statusText: string, responseBody: string, requestId: string | null, responseHeaders?: Headers | Readonly<Record<string, string>>);
221
267
  }
268
+ /** Reads Retry-After from an error-like value, returning milliseconds when present. */
269
+ declare function getRetryAfterDelayMs(error: unknown): number | undefined;
222
270
  declare class AzureTtsSdkError extends AzureTtsError {
223
271
  readonly errorDetails: string;
224
272
  constructor(errorDetails: string);
@@ -262,6 +310,17 @@ declare class ChunkValidationError extends Error {
262
310
  readonly diagnostics: readonly SsmlDiagnostic[];
263
311
  constructor(chunkIndex: number, diagnostics: readonly SsmlDiagnostic[]);
264
312
  }
313
+ interface ChunkDiagnostics {
314
+ readonly chunkIndex: number;
315
+ readonly diagnostics: readonly SsmlDiagnostic[];
316
+ }
317
+ declare class BatchChunkValidationError extends ChunkValidationError {
318
+ readonly chunkDiagnostics: readonly ChunkDiagnostics[];
319
+ readonly totalErrorCount: number;
320
+ readonly errorCount: number;
321
+ readonly totalErrors: number;
322
+ constructor(chunkDiagnostics: readonly ChunkDiagnostics[]);
323
+ }
265
324
  type Result<T, E> = {
266
325
  readonly ok: true;
267
326
  readonly success: true;
@@ -274,11 +333,13 @@ type Result<T, E> = {
274
333
  readonly success: false;
275
334
  readonly status: Kind;
276
335
  readonly error: E;
336
+ readonly partialResult?: PartialChunkSynthesisResult;
277
337
  } : {
278
338
  readonly ok: false;
279
339
  readonly success: false;
280
340
  readonly status: SynthesisErrorKind;
281
341
  readonly error: E;
342
+ readonly partialResult?: PartialChunkSynthesisResult;
282
343
  });
283
344
  type SynthesisResult<T, E> = Result<T, E>;
284
345
  type Success<T> = Extract<Result<T, never>, {
@@ -295,18 +356,26 @@ interface SynthesizeSsmlSafeOptions extends AzureValidationOptions {
295
356
  /** Optional nested form for callers that want to keep validation settings grouped. */
296
357
  validation?: AzureValidationOptions;
297
358
  signal?: AbortSignal;
359
+ timeouts?: SynthesisTimeouts;
298
360
  }
299
361
  interface SynthesizeSsmlChunksSafeOptions extends AzureValidationOptions {
300
362
  validation?: AzureValidationOptions;
301
363
  outputFormat?: string;
302
364
  signal?: AbortSignal;
303
365
  timeoutMs?: number;
366
+ timeouts?: SynthesisTimeouts;
304
367
  sourceNodePath?: string[];
305
368
  onProgress?: (event: SynthesisProgressEvent) => void;
306
369
  concurrency?: number;
307
370
  retryOptions?: RetryOptions;
371
+ cancelOnFailure?: boolean;
372
+ resumeChunks?: readonly SynthesizedChunk[];
373
+ resumeChunkIndices?: readonly number[];
374
+ customMerger?: CustomAudioMerger;
375
+ outputMimeType?: string;
376
+ postMergeValidator?: PostMergeValidator;
308
377
  }
309
- type SsmlSynthesisChunksSafeResult = Result<SsmlSynthesisResult, never> | Result<never, ChunkValidationError> | Result<never, SsmlSynthesisError | ChunkValidationError>;
378
+ type SsmlSynthesisChunksSafeResult = Result<SsmlSynthesisResult, never> | Result<never, ChunkValidationError> | Result<never, BatchChunkValidationError> | Result<never, SsmlSynthesisError | ChunkValidationError>;
310
379
  interface SynthesisClient {
311
380
  synthesizeSsml(ssml: string, options?: Partial<SynthesizeChunksOptions>): Promise<SsmlSynthesisResult>;
312
381
  synthesizeChunks?(chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeChunksOptions): Promise<SsmlSynthesisResult>;
@@ -334,14 +403,9 @@ interface MergeAudioOptions {
334
403
  outputMimeType?: string;
335
404
  }
336
405
  type InputAudioSpecs = AudioSpecification[];
337
- interface CustomMergerContext {
338
- format: string;
339
- outputMimeType: string;
340
- inputSpecs: InputAudioSpecs;
341
- signal: AbortSignal;
342
- }
343
406
  interface MergeSynthesisOptions extends MergeAudioOptions {
344
- customMerger?: (buffers: ArrayBuffer[], context: CustomMergerContext) => Promise<ArrayBuffer> | ArrayBuffer;
407
+ customMerger?: CustomAudioMerger;
408
+ postMergeValidator?: PostMergeValidator;
345
409
  }
346
410
  type AsyncMergeSynthesisOptions = MergeSynthesisOptions & {
347
411
  customMerger: NonNullable<MergeSynthesisOptions["customMerger"]>;
@@ -357,6 +421,7 @@ declare function synthesizeSsml(ssml: string, config: TtsConfig): Promise<SsmlSy
357
421
  /** Synthesizes chunks with bounded concurrency, retries transient failures, and merges in chunk order. */
358
422
  declare function synthesizeSsmlChunks(chunks: readonly (SsmlSynthesisChunk | string)[], config: TtsConfig): Promise<SsmlSynthesisResult>;
359
423
  declare function mergeSynthesisResults(results: readonly SsmlSynthesisResult[], options: AsyncMergeSynthesisOptions): Promise<MergedSynthesisResult>;
424
+ declare function mergeSynthesisResults(results: readonly SsmlSynthesisResult[], options: MergeSynthesisOptions): MergedSynthesisResult | Promise<MergedSynthesisResult>;
360
425
  declare function mergeSynthesisResults(results: readonly SsmlSynthesisResult[], options: MergeAudioOptions): MergedSynthesisResult;
361
426
  /** Backward-compatible audio-only synthesis helper. */
362
427
  declare function synthesizeSpeech(ssml: string, config: TtsConfig): Promise<ArrayBuffer>;
@@ -381,6 +446,8 @@ interface FetchedAzureVoiceCatalogMetadata {
381
446
  generatedAt: string;
382
447
  apiVersion: string;
383
448
  regions: readonly string[];
449
+ expiresAt?: string;
450
+ regionDiffs?: Readonly<Record<string, readonly string[]>>;
384
451
  }
385
452
  interface AzureVoiceCatalog {
386
453
  voices: readonly AzureVoiceCatalogVoice[];
@@ -389,4 +456,4 @@ interface AzureVoiceCatalog {
389
456
  /** Fetches and deduplicates the current Azure Speech voice catalog for one or more regions. */
390
457
  declare function fetchAzureVoiceCatalog(options: FetchAzureVoiceCatalogOptions): Promise<AzureVoiceCatalog>;
391
458
 
392
- 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, ChunkValidationError, type CustomMergerContext, DEFAULT_OUTPUT_FORMAT, type FetchAzureVoiceCatalogOptions, type FetchedAzureVoiceCatalogMetadata, type InputAudioSpecs, type MappingStatus, type MergeAudioFormat, type MergeAudioOptions, MergeError, type MergeSynthesisOptions, type MergedSynthesisResult, type Result, type RetryOptions, 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 SynthesizeChunksOptions, type SynthesizeSsmlChunksSafeOptions, type SynthesizeSsmlSafeOptions, type TtsConfig, UnsupportedMergeFormatError, type ValidationErrorResult, canMergeAudioFormat, fetchAzureVoiceCatalog, inspectAudioSpecification, mergeAudioBuffers, mergeSynthesisResults, resolveMergeAudioFormat, resolveMimeType, synthesizeSpeech, synthesizeSsml, synthesizeSsmlChunks, synthesizeSsmlChunksSafe, synthesizeSsmlSafe };
459
+ 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, ChunkValidationError, type CustomAudioMerger, type CustomMergerContext, DEFAULT_OUTPUT_FORMAT, type FetchAzureVoiceCatalogOptions, type FetchedAzureVoiceCatalogMetadata, type InputAudioSpecs, type MappingStatus, type MergeAudioFormat, type MergeAudioOptions, MergeError, type MergeSynthesisOptions, type MergedSynthesisResult, type PartialChunkSynthesisResult, type PartialSynthesisResult, type PostMergeValidator, type Result, type RetryOptions, 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, fetchAzureVoiceCatalog, getRetryAfterDelayMs, inspectAudioSpecification, mergeAudioBuffers, mergeSynthesisResults, resolveMergeAudioFormat, resolveMimeType, synthesizeSpeech, synthesizeSsml, synthesizeSsmlChunks, synthesizeSsmlChunksSafe, synthesizeSsmlSafe };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { AudioElement, AzureDiagnosticCode, AzureLanguageNormalizationOptions, AzureSsmlValidationOptions, AzureUrlValidationResult, AzureUrlValidationRunnerOptions, AzureUrlValidator, AzureValidationOptions, AzureVoiceCatalogMetadata, AzureVoiceDefinition, AzureVoiceMetadata, BookmarkElement, BreakElement, BuildPartialSsmlOptions, CustomElement, Diagnostic, EmphasisElement, ExpressAsElement, ExtractSsmlTranslatableTextOptions, FromPlainTextToSsmlOptions, LangElement, LexiconElement, MapSsmlTextNodesOptions, MarkElement, MsttsAudioDurationElement, MsttsEmbeddingElement, MsttsSilenceElement, MsttsTtsEmbeddingElement, MsttsVisemeElement, MsttsVoiceConversionElement, NamedElement, ParagraphElement, PhonemeElement, ProsodyElement, SayAsElement, SentenceElement, SplitSsmlOptions, SsmlAttributeValue, SsmlAttributes, SsmlBackgroundAudioNode, SsmlBreakElement, SsmlChunk, SsmlChunkContext, SsmlDiagnostic, SsmlDiagnosticSeverity, SsmlDiagnosticSource, SsmlDialogNode, SsmlDocument, SsmlElement, SsmlElementBase, SsmlEmbeddingNode, SsmlExpressAsElement, SsmlNode, SsmlPartialContext, SsmlPartialProsody, SsmlPartialVoice, SsmlPhonemeElement, SsmlProsodyElement, SsmlSayAsElement, SsmlSourceMap, SsmlSourceMarker, SsmlSourceTextSegment, SsmlStructureIntegrityResult, SsmlStructureMismatch, SsmlText, SsmlTextNodeContext, SsmlTextRange, SsmlTtsEmbeddingNode, SsmlTurnNode, SsmlValidationError, SsmlVoiceConversionNode, SsmlVoiceElement, SubElement, VoiceElement, WordElement, areAzureLanguagesEquivalent, buildPartialSsml, buildSsml, createAzureUrlValidatorRunner, extractSsmlText, extractSsmlTranslatableText, fromPlainTextToSsml, getAzureVoiceCatalogMetadata, getBuiltInVoiceCatalogMetadata, getSsmlSourceMap, isValidAzureAudioDuration, mapSsmlTextNodes, normalizeAzureLanguage, parseSsml, splitSsmlDocument, validateAzureSsml, validateAzureSsmlChunks, validateSsml, validateSsmlStructureIntegrity } from './core.js';
2
- import { S as SsmlTextRange, a as SsmlSourceTextSegment, b as SsmlSourceMarker, c as SsmlDiagnostic, A as AzureValidationOptions } from './index.d-DR5Qz43p.js';
2
+ import { S as SsmlTextRange, a as SsmlSourceTextSegment, b as SsmlSourceMarker, c as SsmlDiagnostic, A as AzureValidationOptions } from './index.d-tpKoP1jl.js';
3
3
  import * as SpeechSDK from 'microsoft-cognitiveservices-speech-sdk';
4
4
 
5
5
  declare const DEFAULT_OUTPUT_FORMAT = "audio-16khz-128kbitrate-mono-mp3";
@@ -50,6 +50,7 @@ declare function resolveMimeType(outputFormat: string): string;
50
50
  interface TtsConfig {
51
51
  signal?: AbortSignal;
52
52
  timeoutMs?: number;
53
+ timeouts?: SynthesisTimeouts;
53
54
  endpoint?: string;
54
55
  subscriptionKey: string;
55
56
  region: string;
@@ -69,6 +70,12 @@ interface TtsConfig {
69
70
  sourceMarkers?: SsmlSourceMarker[];
70
71
  concurrency?: number;
71
72
  retryOptions?: RetryOptions;
73
+ cancelOnFailure?: boolean;
74
+ resumeChunks?: readonly SynthesizedChunk[];
75
+ resumeChunkIndices?: readonly number[];
76
+ customMerger?: CustomAudioMerger;
77
+ outputMimeType?: string;
78
+ postMergeValidator?: PostMergeValidator;
72
79
  }
73
80
  type MappingStatus = "exact" | "fallback" | "unmapped";
74
81
  interface AudioSpecification {
@@ -78,12 +85,22 @@ interface AudioSpecification {
78
85
  sampleRate: number;
79
86
  channels: number;
80
87
  bitrate?: number;
88
+ bitDepth?: number;
89
+ container?: string;
90
+ isVbr?: boolean;
81
91
  isCompressed: boolean;
82
92
  }
93
+ interface SynthesisTimeouts {
94
+ urlValidationMs?: number;
95
+ perChunkMs?: number;
96
+ chunkWithRetriesMs?: number;
97
+ totalJobMs?: number;
98
+ }
83
99
  interface RetryOptions {
84
100
  maxRetries: number;
85
101
  initialDelayMs: number;
86
102
  maxDelayMs: number;
103
+ shouldRetry?: (error: unknown, attempt: number) => boolean;
87
104
  }
88
105
  type SynthesisChunkStatus = "pending" | "synthesizing" | "success" | "failed";
89
106
  interface SsmlSynthesisBoundary {
@@ -173,10 +190,37 @@ interface SynthesizeChunksOptions {
173
190
  outputFormat?: AzureTtsOutputFormat | string;
174
191
  signal?: AbortSignal;
175
192
  timeoutMs?: number;
193
+ timeouts?: SynthesisTimeouts;
176
194
  sourceNodePath?: string[];
177
195
  concurrency?: number;
178
196
  retryOptions?: RetryOptions;
197
+ cancelOnFailure?: boolean;
198
+ resumeChunks?: readonly SynthesizedChunk[];
199
+ resumeChunkIndices?: readonly number[];
200
+ customMerger?: CustomAudioMerger;
201
+ outputMimeType?: string;
202
+ postMergeValidator?: PostMergeValidator;
203
+ }
204
+ interface CustomMergerContext {
205
+ format: string;
206
+ outputMimeType: string;
207
+ inputSpecs: readonly AudioSpecification[];
208
+ signal: AbortSignal;
209
+ }
210
+ type CustomAudioMerger = (buffers: ArrayBuffer[], context: CustomMergerContext) => Promise<ArrayBuffer> | ArrayBuffer;
211
+ type PostMergeValidator = (result: MergedSynthesisResult, context: CustomMergerContext) => boolean | undefined | Promise<boolean | undefined>;
212
+ interface SynthesizedChunk extends SsmlSynthesisResult {
213
+ chunkIndex: number;
214
+ }
215
+ interface PartialChunkSynthesisResult {
216
+ synthesizedChunks: readonly SynthesizedChunk[];
217
+ completedChunks: readonly SynthesizedChunk[];
218
+ pendingChunkIndices: readonly number[];
219
+ failedChunkIndices: readonly number[];
220
+ totalChunks: number;
179
221
  }
222
+ /** Alias for applications that use the shorter result name. */
223
+ type PartialSynthesisResult = PartialChunkSynthesisResult;
180
224
  interface SynthesisProgressEvent {
181
225
  /** 1-based completed chunk count retained for backward compatibility. */
182
226
  currentChunk: number;
@@ -200,6 +244,7 @@ interface AzureTtsLogger {
200
244
  interface AzureTtsClientOptions {
201
245
  signal?: AbortSignal;
202
246
  timeoutMs?: number;
247
+ timeouts?: SynthesisTimeouts;
203
248
  subscriptionKey: string;
204
249
  region: string;
205
250
  endpoint?: string;
@@ -217,8 +262,11 @@ declare class AzureTtsError extends Error {
217
262
  readonly statusText: string;
218
263
  readonly responseBody: string;
219
264
  readonly requestId: string | null;
220
- constructor(status: number, statusText: string, responseBody: string, requestId: string | null);
265
+ readonly retryAfterMs?: number;
266
+ constructor(status: number, statusText: string, responseBody: string, requestId: string | null, responseHeaders?: Headers | Readonly<Record<string, string>>);
221
267
  }
268
+ /** Reads Retry-After from an error-like value, returning milliseconds when present. */
269
+ declare function getRetryAfterDelayMs(error: unknown): number | undefined;
222
270
  declare class AzureTtsSdkError extends AzureTtsError {
223
271
  readonly errorDetails: string;
224
272
  constructor(errorDetails: string);
@@ -262,6 +310,17 @@ declare class ChunkValidationError extends Error {
262
310
  readonly diagnostics: readonly SsmlDiagnostic[];
263
311
  constructor(chunkIndex: number, diagnostics: readonly SsmlDiagnostic[]);
264
312
  }
313
+ interface ChunkDiagnostics {
314
+ readonly chunkIndex: number;
315
+ readonly diagnostics: readonly SsmlDiagnostic[];
316
+ }
317
+ declare class BatchChunkValidationError extends ChunkValidationError {
318
+ readonly chunkDiagnostics: readonly ChunkDiagnostics[];
319
+ readonly totalErrorCount: number;
320
+ readonly errorCount: number;
321
+ readonly totalErrors: number;
322
+ constructor(chunkDiagnostics: readonly ChunkDiagnostics[]);
323
+ }
265
324
  type Result<T, E> = {
266
325
  readonly ok: true;
267
326
  readonly success: true;
@@ -274,11 +333,13 @@ type Result<T, E> = {
274
333
  readonly success: false;
275
334
  readonly status: Kind;
276
335
  readonly error: E;
336
+ readonly partialResult?: PartialChunkSynthesisResult;
277
337
  } : {
278
338
  readonly ok: false;
279
339
  readonly success: false;
280
340
  readonly status: SynthesisErrorKind;
281
341
  readonly error: E;
342
+ readonly partialResult?: PartialChunkSynthesisResult;
282
343
  });
283
344
  type SynthesisResult<T, E> = Result<T, E>;
284
345
  type Success<T> = Extract<Result<T, never>, {
@@ -295,18 +356,26 @@ interface SynthesizeSsmlSafeOptions extends AzureValidationOptions {
295
356
  /** Optional nested form for callers that want to keep validation settings grouped. */
296
357
  validation?: AzureValidationOptions;
297
358
  signal?: AbortSignal;
359
+ timeouts?: SynthesisTimeouts;
298
360
  }
299
361
  interface SynthesizeSsmlChunksSafeOptions extends AzureValidationOptions {
300
362
  validation?: AzureValidationOptions;
301
363
  outputFormat?: string;
302
364
  signal?: AbortSignal;
303
365
  timeoutMs?: number;
366
+ timeouts?: SynthesisTimeouts;
304
367
  sourceNodePath?: string[];
305
368
  onProgress?: (event: SynthesisProgressEvent) => void;
306
369
  concurrency?: number;
307
370
  retryOptions?: RetryOptions;
371
+ cancelOnFailure?: boolean;
372
+ resumeChunks?: readonly SynthesizedChunk[];
373
+ resumeChunkIndices?: readonly number[];
374
+ customMerger?: CustomAudioMerger;
375
+ outputMimeType?: string;
376
+ postMergeValidator?: PostMergeValidator;
308
377
  }
309
- type SsmlSynthesisChunksSafeResult = Result<SsmlSynthesisResult, never> | Result<never, ChunkValidationError> | Result<never, SsmlSynthesisError | ChunkValidationError>;
378
+ type SsmlSynthesisChunksSafeResult = Result<SsmlSynthesisResult, never> | Result<never, ChunkValidationError> | Result<never, BatchChunkValidationError> | Result<never, SsmlSynthesisError | ChunkValidationError>;
310
379
  interface SynthesisClient {
311
380
  synthesizeSsml(ssml: string, options?: Partial<SynthesizeChunksOptions>): Promise<SsmlSynthesisResult>;
312
381
  synthesizeChunks?(chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeChunksOptions): Promise<SsmlSynthesisResult>;
@@ -334,14 +403,9 @@ interface MergeAudioOptions {
334
403
  outputMimeType?: string;
335
404
  }
336
405
  type InputAudioSpecs = AudioSpecification[];
337
- interface CustomMergerContext {
338
- format: string;
339
- outputMimeType: string;
340
- inputSpecs: InputAudioSpecs;
341
- signal: AbortSignal;
342
- }
343
406
  interface MergeSynthesisOptions extends MergeAudioOptions {
344
- customMerger?: (buffers: ArrayBuffer[], context: CustomMergerContext) => Promise<ArrayBuffer> | ArrayBuffer;
407
+ customMerger?: CustomAudioMerger;
408
+ postMergeValidator?: PostMergeValidator;
345
409
  }
346
410
  type AsyncMergeSynthesisOptions = MergeSynthesisOptions & {
347
411
  customMerger: NonNullable<MergeSynthesisOptions["customMerger"]>;
@@ -357,6 +421,7 @@ declare function synthesizeSsml(ssml: string, config: TtsConfig): Promise<SsmlSy
357
421
  /** Synthesizes chunks with bounded concurrency, retries transient failures, and merges in chunk order. */
358
422
  declare function synthesizeSsmlChunks(chunks: readonly (SsmlSynthesisChunk | string)[], config: TtsConfig): Promise<SsmlSynthesisResult>;
359
423
  declare function mergeSynthesisResults(results: readonly SsmlSynthesisResult[], options: AsyncMergeSynthesisOptions): Promise<MergedSynthesisResult>;
424
+ declare function mergeSynthesisResults(results: readonly SsmlSynthesisResult[], options: MergeSynthesisOptions): MergedSynthesisResult | Promise<MergedSynthesisResult>;
360
425
  declare function mergeSynthesisResults(results: readonly SsmlSynthesisResult[], options: MergeAudioOptions): MergedSynthesisResult;
361
426
  /** Backward-compatible audio-only synthesis helper. */
362
427
  declare function synthesizeSpeech(ssml: string, config: TtsConfig): Promise<ArrayBuffer>;
@@ -381,6 +446,8 @@ interface FetchedAzureVoiceCatalogMetadata {
381
446
  generatedAt: string;
382
447
  apiVersion: string;
383
448
  regions: readonly string[];
449
+ expiresAt?: string;
450
+ regionDiffs?: Readonly<Record<string, readonly string[]>>;
384
451
  }
385
452
  interface AzureVoiceCatalog {
386
453
  voices: readonly AzureVoiceCatalogVoice[];
@@ -389,4 +456,4 @@ interface AzureVoiceCatalog {
389
456
  /** Fetches and deduplicates the current Azure Speech voice catalog for one or more regions. */
390
457
  declare function fetchAzureVoiceCatalog(options: FetchAzureVoiceCatalogOptions): Promise<AzureVoiceCatalog>;
391
458
 
392
- 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, ChunkValidationError, type CustomMergerContext, DEFAULT_OUTPUT_FORMAT, type FetchAzureVoiceCatalogOptions, type FetchedAzureVoiceCatalogMetadata, type InputAudioSpecs, type MappingStatus, type MergeAudioFormat, type MergeAudioOptions, MergeError, type MergeSynthesisOptions, type MergedSynthesisResult, type Result, type RetryOptions, 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 SynthesizeChunksOptions, type SynthesizeSsmlChunksSafeOptions, type SynthesizeSsmlSafeOptions, type TtsConfig, UnsupportedMergeFormatError, type ValidationErrorResult, canMergeAudioFormat, fetchAzureVoiceCatalog, inspectAudioSpecification, mergeAudioBuffers, mergeSynthesisResults, resolveMergeAudioFormat, resolveMimeType, synthesizeSpeech, synthesizeSsml, synthesizeSsmlChunks, synthesizeSsmlChunksSafe, synthesizeSsmlSafe };
459
+ 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, ChunkValidationError, type CustomAudioMerger, type CustomMergerContext, DEFAULT_OUTPUT_FORMAT, type FetchAzureVoiceCatalogOptions, type FetchedAzureVoiceCatalogMetadata, type InputAudioSpecs, type MappingStatus, type MergeAudioFormat, type MergeAudioOptions, MergeError, type MergeSynthesisOptions, type MergedSynthesisResult, type PartialChunkSynthesisResult, type PartialSynthesisResult, type PostMergeValidator, type Result, type RetryOptions, 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, fetchAzureVoiceCatalog, getRetryAfterDelayMs, inspectAudioSpecification, mergeAudioBuffers, mergeSynthesisResults, resolveMergeAudioFormat, resolveMimeType, synthesizeSpeech, synthesizeSsml, synthesizeSsmlChunks, synthesizeSsmlChunksSafe, synthesizeSsmlSafe };