@ssml-builder-js/azure-tts-client 2.17.0 → 2.18.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/CHANGELOG.md +10 -0
- package/dist/index.d.mts +169 -140
- package/dist/index.d.ts +169 -140
- package/dist/index.js +250 -56
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +249 -56
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/client.ts +21 -5
- package/src/index.ts +4 -0
- package/src/outputFormats.ts +3 -0
- package/src/safe.ts +79 -10
- package/src/synthesis.ts +214 -41
- package/src/types.ts +27 -1
- package/test/v218-pipeline.test.ts +91 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @ssml-builder-js/azure-tts-client
|
|
2
2
|
|
|
3
|
+
## 2.18.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add fingerprint-validated resume chunks, detailed chunk execution states, unified job timeout and Retry-After limits, injectable client defaults, and strict RAW audio specification validation.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- @ssml-builder-js/ssml-core@2.18.0
|
|
12
|
+
|
|
3
13
|
## 2.17.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SsmlDiagnostic, AzureValidationOptions, SsmlTextRange, SsmlSourceTextSegment, SsmlSourceMarker } from '@ssml-builder-js/ssml-core';
|
|
2
2
|
import * as SpeechSDK from 'microsoft-cognitiveservices-speech-sdk';
|
|
3
3
|
|
|
4
4
|
declare const DEFAULT_OUTPUT_FORMAT = "audio-16khz-128kbitrate-mono-mp3";
|
|
@@ -46,6 +46,148 @@ declare const OUTPUT_FORMATS: {
|
|
|
46
46
|
type AzureTtsOutputFormat = keyof typeof OUTPUT_FORMATS;
|
|
47
47
|
declare function resolveMimeType(outputFormat: string): string;
|
|
48
48
|
|
|
49
|
+
type SynthesisErrorKind = "validation-error" | "azure-api-error" | "merge-error" | "audio-format-mismatch" | "unsupported-format-error" | "cancelled" | "timeout";
|
|
50
|
+
declare class AzureTtsError extends Error {
|
|
51
|
+
readonly kind: "azure-api-error";
|
|
52
|
+
readonly status: number;
|
|
53
|
+
readonly statusText: string;
|
|
54
|
+
readonly responseBody: string;
|
|
55
|
+
readonly requestId: string | null;
|
|
56
|
+
readonly retryAfterMs?: number;
|
|
57
|
+
constructor(status: number, statusText: string, responseBody: string, requestId: string | null, responseHeaders?: Headers | Readonly<Record<string, string>>);
|
|
58
|
+
}
|
|
59
|
+
/** Reads Retry-After from an error-like value, returning milliseconds when present. */
|
|
60
|
+
declare function getRetryAfterDelayMs(error: unknown): number | undefined;
|
|
61
|
+
declare class AzureTtsSdkError extends AzureTtsError {
|
|
62
|
+
readonly errorDetails: string;
|
|
63
|
+
constructor(errorDetails: string);
|
|
64
|
+
}
|
|
65
|
+
declare class SynthesisCancelledError extends Error {
|
|
66
|
+
readonly kind: "cancelled";
|
|
67
|
+
constructor(message?: string);
|
|
68
|
+
}
|
|
69
|
+
declare class SynthesisTimeoutError extends Error {
|
|
70
|
+
readonly kind: "timeout";
|
|
71
|
+
constructor(message: string);
|
|
72
|
+
}
|
|
73
|
+
declare class MergeError extends Error {
|
|
74
|
+
readonly kind: "merge-error";
|
|
75
|
+
readonly cause: unknown;
|
|
76
|
+
constructor(message: string, cause?: unknown);
|
|
77
|
+
}
|
|
78
|
+
/** Thrown when chunk headers describe incompatible audio streams. */
|
|
79
|
+
declare class AudioFormatMismatchError extends Error {
|
|
80
|
+
readonly kind: "audio-format-mismatch";
|
|
81
|
+
readonly inputSpecs: readonly AudioSpecification[];
|
|
82
|
+
constructor(message: string, inputSpecs?: readonly AudioSpecification[]);
|
|
83
|
+
}
|
|
84
|
+
/** Thrown when audio buffers require container re-multiplexing before they can be merged. */
|
|
85
|
+
declare class UnsupportedMergeFormatError extends Error {
|
|
86
|
+
readonly kind: "unsupported-format-error";
|
|
87
|
+
readonly format: string;
|
|
88
|
+
constructor(format: string);
|
|
89
|
+
}
|
|
90
|
+
type AzureTtsSynthesisError = AzureTtsError | MergeError | AudioFormatMismatchError | UnsupportedMergeFormatError | SynthesisCancelledError | SynthesisTimeoutError;
|
|
91
|
+
|
|
92
|
+
declare class AzureTtsClient {
|
|
93
|
+
#private;
|
|
94
|
+
constructor(options: AzureTtsClientOptions);
|
|
95
|
+
synthesize(ssml: string): Promise<ArrayBuffer>;
|
|
96
|
+
synthesizeSsml(ssml: string, options?: Partial<TtsConfig>): Promise<SsmlSynthesisResult>;
|
|
97
|
+
synthesizeChunks(chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeChunksOptions): Promise<SsmlSynthesisResult>;
|
|
98
|
+
synthesizeSsmlSafe(ssml: string, options?: SynthesizeSsmlSafeOptions): Promise<SsmlSynthesisSafeResult>;
|
|
99
|
+
synthesizeChunksSafe(chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeSsmlChunksSafeOptions): Promise<SsmlSynthesisChunksSafeResult>;
|
|
100
|
+
synthesizeSsmlChunksSafe(chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeSsmlChunksSafeOptions): Promise<SsmlSynthesisChunksSafeResult>;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
interface SsmlValidationError {
|
|
104
|
+
readonly kind: "validation-error";
|
|
105
|
+
readonly message: string;
|
|
106
|
+
readonly diagnostics: readonly SsmlDiagnostic[];
|
|
107
|
+
}
|
|
108
|
+
type SsmlSynthesisError = SsmlValidationError | AzureTtsSynthesisError;
|
|
109
|
+
declare class ChunkValidationError extends Error {
|
|
110
|
+
readonly kind: "validation-error";
|
|
111
|
+
readonly chunkIndex: number;
|
|
112
|
+
readonly diagnostics: readonly SsmlDiagnostic[];
|
|
113
|
+
constructor(chunkIndex: number, diagnostics: readonly SsmlDiagnostic[]);
|
|
114
|
+
}
|
|
115
|
+
interface ChunkDiagnostics {
|
|
116
|
+
readonly chunkIndex: number;
|
|
117
|
+
readonly diagnostics: readonly SsmlDiagnostic[];
|
|
118
|
+
}
|
|
119
|
+
declare class BatchChunkValidationError extends ChunkValidationError {
|
|
120
|
+
readonly chunkDiagnostics: readonly ChunkDiagnostics[];
|
|
121
|
+
readonly totalErrorCount: number;
|
|
122
|
+
readonly errorCount: number;
|
|
123
|
+
readonly totalErrors: number;
|
|
124
|
+
constructor(chunkDiagnostics: readonly ChunkDiagnostics[]);
|
|
125
|
+
}
|
|
126
|
+
type Result<T, E> = {
|
|
127
|
+
readonly ok: true;
|
|
128
|
+
readonly success: true;
|
|
129
|
+
readonly status: "success";
|
|
130
|
+
readonly value: T;
|
|
131
|
+
} | (E extends {
|
|
132
|
+
readonly kind: infer Kind extends SynthesisErrorKind;
|
|
133
|
+
} ? {
|
|
134
|
+
readonly ok: false;
|
|
135
|
+
readonly success: false;
|
|
136
|
+
readonly status: Kind;
|
|
137
|
+
readonly error: E;
|
|
138
|
+
readonly partialResult?: PartialChunkSynthesisResult;
|
|
139
|
+
} : {
|
|
140
|
+
readonly ok: false;
|
|
141
|
+
readonly success: false;
|
|
142
|
+
readonly status: SynthesisErrorKind;
|
|
143
|
+
readonly error: E;
|
|
144
|
+
readonly partialResult?: PartialChunkSynthesisResult;
|
|
145
|
+
});
|
|
146
|
+
type SynthesisResult<T, E> = Result<T, E>;
|
|
147
|
+
type Success<T> = Extract<Result<T, never>, {
|
|
148
|
+
readonly ok: true;
|
|
149
|
+
}>;
|
|
150
|
+
type ValidationErrorResult = Extract<Result<never, SsmlValidationError>, {
|
|
151
|
+
readonly status: "validation-error";
|
|
152
|
+
}>;
|
|
153
|
+
type AzureApiErrorResult = Extract<Result<never, AzureTtsError>, {
|
|
154
|
+
readonly status: "azure-api-error";
|
|
155
|
+
}>;
|
|
156
|
+
type SsmlSynthesisSafeResult = Result<SsmlSynthesisResult, never> | Result<never, SsmlValidationError> | Result<never, SsmlSynthesisError>;
|
|
157
|
+
interface SynthesizeSsmlSafeOptions extends AzureValidationOptions {
|
|
158
|
+
/** Optional nested form for callers that want to keep validation settings grouped. */
|
|
159
|
+
validation?: AzureValidationOptions;
|
|
160
|
+
signal?: AbortSignal;
|
|
161
|
+
timeouts?: SynthesisTimeouts;
|
|
162
|
+
}
|
|
163
|
+
interface SynthesizeSsmlChunksSafeOptions extends AzureValidationOptions {
|
|
164
|
+
validation?: AzureValidationOptions;
|
|
165
|
+
outputFormat?: string;
|
|
166
|
+
signal?: AbortSignal;
|
|
167
|
+
timeoutMs?: number;
|
|
168
|
+
timeouts?: SynthesisTimeouts;
|
|
169
|
+
sourceNodePath?: string[];
|
|
170
|
+
onProgress?: (event: SynthesisProgressEvent) => void;
|
|
171
|
+
concurrency?: number;
|
|
172
|
+
retryOptions?: RetryOptions;
|
|
173
|
+
cancelOnFailure?: boolean;
|
|
174
|
+
resumeChunks?: readonly SynthesizedChunk[];
|
|
175
|
+
resumeChunkIndices?: readonly number[];
|
|
176
|
+
customMerger?: CustomAudioMerger;
|
|
177
|
+
outputMimeType?: string;
|
|
178
|
+
postMergeValidator?: PostMergeValidator;
|
|
179
|
+
resumeValidation?: ResumeValidationMode;
|
|
180
|
+
}
|
|
181
|
+
type SsmlSynthesisChunksSafeResult = Result<SsmlSynthesisResult, never> | Result<never, ChunkValidationError> | Result<never, BatchChunkValidationError> | Result<never, SsmlSynthesisError | ChunkValidationError>;
|
|
182
|
+
interface SynthesisClient {
|
|
183
|
+
synthesizeSsml(ssml: string, options?: Partial<SynthesizeChunksOptions>): Promise<SsmlSynthesisResult>;
|
|
184
|
+
synthesizeChunks?(chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeChunksOptions): Promise<SsmlSynthesisResult>;
|
|
185
|
+
}
|
|
186
|
+
/** Validates SSML before invoking Azure and converts validation/API failures to one result shape. */
|
|
187
|
+
declare function synthesizeSsmlSafe(client: Pick<AzureTtsClient, "synthesizeSsml"> | SynthesisClient, ssml: string, options?: SynthesizeSsmlSafeOptions): Promise<SsmlSynthesisSafeResult>;
|
|
188
|
+
/** Validates every chunk before synthesis and returns a chunk-addressable result. */
|
|
189
|
+
declare function synthesizeSsmlChunksSafe(client: Pick<AzureTtsClient, "synthesizeSsml" | "synthesizeChunks"> | SynthesisClient, chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeSsmlChunksSafeOptions): Promise<SsmlSynthesisChunksSafeResult>;
|
|
190
|
+
|
|
49
191
|
interface TtsConfig {
|
|
50
192
|
signal?: AbortSignal;
|
|
51
193
|
timeoutMs?: number;
|
|
@@ -75,12 +217,13 @@ interface TtsConfig {
|
|
|
75
217
|
customMerger?: CustomAudioMerger;
|
|
76
218
|
outputMimeType?: string;
|
|
77
219
|
postMergeValidator?: PostMergeValidator;
|
|
220
|
+
resumeValidation?: ResumeValidationMode;
|
|
78
221
|
}
|
|
79
222
|
type MappingStatus = "exact" | "fallback" | "unmapped";
|
|
80
223
|
interface AudioSpecification {
|
|
81
224
|
format: string;
|
|
82
225
|
mimeType: string;
|
|
83
|
-
codec: "pcm" | "mp3" | "opus" | "silk" | "unknown";
|
|
226
|
+
codec: "pcm" | "mulaw" | "alaw" | "siren" | "mp3" | "opus" | "silk" | "unknown";
|
|
84
227
|
sampleRate: number;
|
|
85
228
|
channels: number;
|
|
86
229
|
bitrate?: number;
|
|
@@ -89,6 +232,7 @@ interface AudioSpecification {
|
|
|
89
232
|
isVbr?: boolean;
|
|
90
233
|
isCompressed: boolean;
|
|
91
234
|
}
|
|
235
|
+
type ResumeValidationMode = "strict" | "disabled";
|
|
92
236
|
interface SynthesisTimeouts {
|
|
93
237
|
urlValidationMs?: number;
|
|
94
238
|
perChunkMs?: number;
|
|
@@ -199,6 +343,7 @@ interface SynthesizeChunksOptions {
|
|
|
199
343
|
customMerger?: CustomAudioMerger;
|
|
200
344
|
outputMimeType?: string;
|
|
201
345
|
postMergeValidator?: PostMergeValidator;
|
|
346
|
+
resumeValidation?: ResumeValidationMode;
|
|
202
347
|
}
|
|
203
348
|
interface CustomMergerContext {
|
|
204
349
|
format: string;
|
|
@@ -210,12 +355,25 @@ type CustomAudioMerger = (buffers: ArrayBuffer[], context: CustomMergerContext)
|
|
|
210
355
|
type PostMergeValidator = (result: MergedSynthesisResult, context: CustomMergerContext) => boolean | undefined | Promise<boolean | undefined>;
|
|
211
356
|
interface SynthesizedChunk extends SsmlSynthesisResult {
|
|
212
357
|
chunkIndex: number;
|
|
358
|
+
/** Fingerprint of the SSML and synthesis settings used to create this chunk. */
|
|
359
|
+
fingerprint: string;
|
|
360
|
+
}
|
|
361
|
+
type ChunkExecutionStatus = "succeeded" | "failed" | "cancelled" | "pending";
|
|
362
|
+
interface ChunkExecutionState {
|
|
363
|
+
chunkIndex: number;
|
|
364
|
+
status: ChunkExecutionStatus;
|
|
365
|
+
error?: AzureTtsError | SsmlValidationError;
|
|
366
|
+
isOriginalFailure?: boolean;
|
|
367
|
+
canResume: boolean;
|
|
368
|
+
result?: SsmlSynthesisResult;
|
|
213
369
|
}
|
|
214
370
|
interface PartialChunkSynthesisResult {
|
|
215
371
|
synthesizedChunks: readonly SynthesizedChunk[];
|
|
216
372
|
completedChunks: readonly SynthesizedChunk[];
|
|
217
373
|
pendingChunkIndices: readonly number[];
|
|
218
374
|
failedChunkIndices: readonly number[];
|
|
375
|
+
cancelledChunkIndices: readonly number[];
|
|
376
|
+
chunkStates: readonly ChunkExecutionState[];
|
|
219
377
|
totalChunks: number;
|
|
220
378
|
}
|
|
221
379
|
/** Alias for applications that use the shorter result name. */
|
|
@@ -252,147 +410,11 @@ interface AzureTtsClientOptions {
|
|
|
252
410
|
onProgress?: (event: SynthesisProgressEvent) => void;
|
|
253
411
|
concurrency?: number;
|
|
254
412
|
retryOptions?: RetryOptions;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
type SynthesisErrorKind = "validation-error" | "azure-api-error" | "merge-error" | "audio-format-mismatch" | "unsupported-format-error" | "cancelled" | "timeout";
|
|
258
|
-
declare class AzureTtsError extends Error {
|
|
259
|
-
readonly kind: "azure-api-error";
|
|
260
|
-
readonly status: number;
|
|
261
|
-
readonly statusText: string;
|
|
262
|
-
readonly responseBody: string;
|
|
263
|
-
readonly requestId: string | null;
|
|
264
|
-
readonly retryAfterMs?: number;
|
|
265
|
-
constructor(status: number, statusText: string, responseBody: string, requestId: string | null, responseHeaders?: Headers | Readonly<Record<string, string>>);
|
|
266
|
-
}
|
|
267
|
-
/** Reads Retry-After from an error-like value, returning milliseconds when present. */
|
|
268
|
-
declare function getRetryAfterDelayMs(error: unknown): number | undefined;
|
|
269
|
-
declare class AzureTtsSdkError extends AzureTtsError {
|
|
270
|
-
readonly errorDetails: string;
|
|
271
|
-
constructor(errorDetails: string);
|
|
272
|
-
}
|
|
273
|
-
declare class SynthesisCancelledError extends Error {
|
|
274
|
-
readonly kind: "cancelled";
|
|
275
|
-
constructor(message?: string);
|
|
276
|
-
}
|
|
277
|
-
declare class SynthesisTimeoutError extends Error {
|
|
278
|
-
readonly kind: "timeout";
|
|
279
|
-
constructor(message: string);
|
|
280
|
-
}
|
|
281
|
-
declare class MergeError extends Error {
|
|
282
|
-
readonly kind: "merge-error";
|
|
283
|
-
readonly cause: unknown;
|
|
284
|
-
constructor(message: string, cause?: unknown);
|
|
285
|
-
}
|
|
286
|
-
/** Thrown when chunk headers describe incompatible audio streams. */
|
|
287
|
-
declare class AudioFormatMismatchError extends Error {
|
|
288
|
-
readonly kind: "audio-format-mismatch";
|
|
289
|
-
readonly inputSpecs: readonly AudioSpecification[];
|
|
290
|
-
constructor(message: string, inputSpecs?: readonly AudioSpecification[]);
|
|
291
|
-
}
|
|
292
|
-
/** Thrown when audio buffers require container re-multiplexing before they can be merged. */
|
|
293
|
-
declare class UnsupportedMergeFormatError extends Error {
|
|
294
|
-
readonly kind: "unsupported-format-error";
|
|
295
|
-
readonly format: string;
|
|
296
|
-
constructor(format: string);
|
|
297
|
-
}
|
|
298
|
-
type AzureTtsSynthesisError = AzureTtsError | MergeError | AudioFormatMismatchError | UnsupportedMergeFormatError | SynthesisCancelledError | SynthesisTimeoutError;
|
|
299
|
-
|
|
300
|
-
interface SsmlValidationError {
|
|
301
|
-
readonly kind: "validation-error";
|
|
302
|
-
readonly message: string;
|
|
303
|
-
readonly diagnostics: readonly SsmlDiagnostic[];
|
|
304
|
-
}
|
|
305
|
-
type SsmlSynthesisError = SsmlValidationError | AzureTtsSynthesisError;
|
|
306
|
-
declare class ChunkValidationError extends Error {
|
|
307
|
-
readonly kind: "validation-error";
|
|
308
|
-
readonly chunkIndex: number;
|
|
309
|
-
readonly diagnostics: readonly SsmlDiagnostic[];
|
|
310
|
-
constructor(chunkIndex: number, diagnostics: readonly SsmlDiagnostic[]);
|
|
311
|
-
}
|
|
312
|
-
interface ChunkDiagnostics {
|
|
313
|
-
readonly chunkIndex: number;
|
|
314
|
-
readonly diagnostics: readonly SsmlDiagnostic[];
|
|
315
|
-
}
|
|
316
|
-
declare class BatchChunkValidationError extends ChunkValidationError {
|
|
317
|
-
readonly chunkDiagnostics: readonly ChunkDiagnostics[];
|
|
318
|
-
readonly totalErrorCount: number;
|
|
319
|
-
readonly errorCount: number;
|
|
320
|
-
readonly totalErrors: number;
|
|
321
|
-
constructor(chunkDiagnostics: readonly ChunkDiagnostics[]);
|
|
322
|
-
}
|
|
323
|
-
type Result<T, E> = {
|
|
324
|
-
readonly ok: true;
|
|
325
|
-
readonly success: true;
|
|
326
|
-
readonly status: "success";
|
|
327
|
-
readonly value: T;
|
|
328
|
-
} | (E extends {
|
|
329
|
-
readonly kind: infer Kind extends SynthesisErrorKind;
|
|
330
|
-
} ? {
|
|
331
|
-
readonly ok: false;
|
|
332
|
-
readonly success: false;
|
|
333
|
-
readonly status: Kind;
|
|
334
|
-
readonly error: E;
|
|
335
|
-
readonly partialResult?: PartialChunkSynthesisResult;
|
|
336
|
-
} : {
|
|
337
|
-
readonly ok: false;
|
|
338
|
-
readonly success: false;
|
|
339
|
-
readonly status: SynthesisErrorKind;
|
|
340
|
-
readonly error: E;
|
|
341
|
-
readonly partialResult?: PartialChunkSynthesisResult;
|
|
342
|
-
});
|
|
343
|
-
type SynthesisResult<T, E> = Result<T, E>;
|
|
344
|
-
type Success<T> = Extract<Result<T, never>, {
|
|
345
|
-
readonly ok: true;
|
|
346
|
-
}>;
|
|
347
|
-
type ValidationErrorResult = Extract<Result<never, SsmlValidationError>, {
|
|
348
|
-
readonly status: "validation-error";
|
|
349
|
-
}>;
|
|
350
|
-
type AzureApiErrorResult = Extract<Result<never, AzureTtsError>, {
|
|
351
|
-
readonly status: "azure-api-error";
|
|
352
|
-
}>;
|
|
353
|
-
type SsmlSynthesisSafeResult = Result<SsmlSynthesisResult, never> | Result<never, SsmlValidationError> | Result<never, SsmlSynthesisError>;
|
|
354
|
-
interface SynthesizeSsmlSafeOptions extends AzureValidationOptions {
|
|
355
|
-
/** Optional nested form for callers that want to keep validation settings grouped. */
|
|
356
|
-
validation?: AzureValidationOptions;
|
|
357
|
-
signal?: AbortSignal;
|
|
358
|
-
timeouts?: SynthesisTimeouts;
|
|
359
|
-
}
|
|
360
|
-
interface SynthesizeSsmlChunksSafeOptions extends AzureValidationOptions {
|
|
361
|
-
validation?: AzureValidationOptions;
|
|
362
|
-
outputFormat?: string;
|
|
363
|
-
signal?: AbortSignal;
|
|
364
|
-
timeoutMs?: number;
|
|
365
|
-
timeouts?: SynthesisTimeouts;
|
|
366
|
-
sourceNodePath?: string[];
|
|
367
|
-
onProgress?: (event: SynthesisProgressEvent) => void;
|
|
368
|
-
concurrency?: number;
|
|
369
|
-
retryOptions?: RetryOptions;
|
|
370
413
|
cancelOnFailure?: boolean;
|
|
371
|
-
resumeChunks?: readonly SynthesizedChunk[];
|
|
372
|
-
resumeChunkIndices?: readonly number[];
|
|
373
414
|
customMerger?: CustomAudioMerger;
|
|
374
415
|
outputMimeType?: string;
|
|
375
416
|
postMergeValidator?: PostMergeValidator;
|
|
376
|
-
|
|
377
|
-
type SsmlSynthesisChunksSafeResult = Result<SsmlSynthesisResult, never> | Result<never, ChunkValidationError> | Result<never, BatchChunkValidationError> | Result<never, SsmlSynthesisError | ChunkValidationError>;
|
|
378
|
-
interface SynthesisClient {
|
|
379
|
-
synthesizeSsml(ssml: string, options?: Partial<SynthesizeChunksOptions>): Promise<SsmlSynthesisResult>;
|
|
380
|
-
synthesizeChunks?(chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeChunksOptions): Promise<SsmlSynthesisResult>;
|
|
381
|
-
}
|
|
382
|
-
/** Validates SSML before invoking Azure and converts validation/API failures to one result shape. */
|
|
383
|
-
declare function synthesizeSsmlSafe(client: Pick<AzureTtsClient, "synthesizeSsml"> | SynthesisClient, ssml: string, options?: SynthesizeSsmlSafeOptions): Promise<SsmlSynthesisSafeResult>;
|
|
384
|
-
/** Validates every chunk before synthesis and returns a chunk-addressable result. */
|
|
385
|
-
declare function synthesizeSsmlChunksSafe(client: Pick<AzureTtsClient, "synthesizeSsml" | "synthesizeChunks"> | SynthesisClient, chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeSsmlChunksSafeOptions): Promise<SsmlSynthesisChunksSafeResult>;
|
|
386
|
-
|
|
387
|
-
declare class AzureTtsClient {
|
|
388
|
-
#private;
|
|
389
|
-
constructor(options: AzureTtsClientOptions);
|
|
390
|
-
synthesize(ssml: string): Promise<ArrayBuffer>;
|
|
391
|
-
synthesizeSsml(ssml: string, options?: Partial<TtsConfig>): Promise<SsmlSynthesisResult>;
|
|
392
|
-
synthesizeChunks(chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeChunksOptions): Promise<SsmlSynthesisResult>;
|
|
393
|
-
synthesizeSsmlSafe(ssml: string, options?: SynthesizeSsmlSafeOptions): Promise<SsmlSynthesisSafeResult>;
|
|
394
|
-
synthesizeChunksSafe(chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeSsmlChunksSafeOptions): Promise<SsmlSynthesisChunksSafeResult>;
|
|
395
|
-
synthesizeSsmlChunksSafe(chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeSsmlChunksSafeOptions): Promise<SsmlSynthesisChunksSafeResult>;
|
|
417
|
+
resumeValidation?: ResumeValidationMode;
|
|
396
418
|
}
|
|
397
419
|
|
|
398
420
|
type MergeAudioFormat = "wav" | "mp3" | "raw";
|
|
@@ -402,6 +424,12 @@ interface MergeAudioOptions {
|
|
|
402
424
|
outputMimeType?: string;
|
|
403
425
|
}
|
|
404
426
|
type InputAudioSpecs = AudioSpecification[];
|
|
427
|
+
/**
|
|
428
|
+
* Creates a deterministic, runtime-independent fingerprint for a synthesis chunk.
|
|
429
|
+
* The complete SSML is included so changes to voice, language, prosody, or text
|
|
430
|
+
* invalidate a cached result even when those settings are nested in the markup.
|
|
431
|
+
*/
|
|
432
|
+
declare function computeChunkFingerprint(ssml: string, outputFormat?: string): string;
|
|
405
433
|
interface MergeSynthesisOptions extends MergeAudioOptions {
|
|
406
434
|
customMerger?: CustomAudioMerger;
|
|
407
435
|
postMergeValidator?: PostMergeValidator;
|
|
@@ -416,6 +444,7 @@ declare function resolveMergeAudioFormat(format: string): MergeAudioFormat | und
|
|
|
416
444
|
declare function canMergeAudioFormat(format: string): boolean;
|
|
417
445
|
/** Merges audio buffers while preserving the invariants of supported containers. */
|
|
418
446
|
declare function mergeAudioBuffers(buffers: readonly ArrayBuffer[], options: MergeAudioOptions): ArrayBuffer;
|
|
447
|
+
/** Synthesizes one SSML document, optionally retrying transient failures within the job deadline. */
|
|
419
448
|
declare function synthesizeSsml(ssml: string, config: TtsConfig): Promise<SsmlSynthesisResult>;
|
|
420
449
|
/** Synthesizes chunks with bounded concurrency, retries transient failures, and merges in chunk order. */
|
|
421
450
|
declare function synthesizeSsmlChunks(chunks: readonly (SsmlSynthesisChunk | string)[], config: TtsConfig): Promise<SsmlSynthesisResult>;
|
|
@@ -455,4 +484,4 @@ interface AzureVoiceCatalog {
|
|
|
455
484
|
/** Fetches and deduplicates the current Azure Speech voice catalog for one or more regions. */
|
|
456
485
|
declare function fetchAzureVoiceCatalog(options: FetchAzureVoiceCatalogOptions): Promise<AzureVoiceCatalog>;
|
|
457
486
|
|
|
458
|
-
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 };
|
|
487
|
+
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, 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 ResumeValidationMode, 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, computeChunkFingerprint, fetchAzureVoiceCatalog, getRetryAfterDelayMs, inspectAudioSpecification, mergeAudioBuffers, mergeSynthesisResults, resolveMergeAudioFormat, resolveMimeType, synthesizeSpeech, synthesizeSsml, synthesizeSsmlChunks, synthesizeSsmlChunksSafe, synthesizeSsmlSafe };
|