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