ssml-builder-js 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/README.md +4 -0
- package/dist/{index.d-tpKoP1jl.d.mts → index.d-B2WddTa4.d.mts} +1 -1
- package/dist/{index.d-tpKoP1jl.d.ts → index.d-B2WddTa4.d.ts} +1 -1
- 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/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -919,6 +919,8 @@ v2.16.0 では `concurrency` と `retryOptions`(429/5xx・ネットワーク
|
|
|
919
919
|
|
|
920
920
|
v2.17.0 では `customMerger`、`outputMimeType`、`postMergeValidator` をチャンク合成の末尾まで構成でき、`BatchChunkValidationError` が全チャンクの診断と総エラー数を返します。`cancelOnFailure` と `resumeChunks` により成功済みバイナリを再利用でき、`timeouts`(URL 検証、チャンク、リトライ込みチャンク、ジョブ全体)を個別に設定できます。429 の `Retry-After` は指数バックオフより優先されます。`AudioSpecification` には `bitDepth`、`container`、`isVbr` が追加され、同期 `mappingStatus` は JSON 化後も保持されます。
|
|
921
921
|
|
|
922
|
+
v2.18.0 では `resumeChunks` に SSML・音声設定・出力形式のフィンガープリントを付与し、不一致のキャッシュを自動的に再合成します。`PartialChunkSynthesisResult.chunkStates` は成功、直接失敗、連鎖キャンセル、未実行を区別します。`totalJobMs` は単一合成にも適用され、上限を超える `Retry-After` は待機せずタイムアウトになります。`AzureTtsClient` の既定値として再試行、キャンセル、結合器、MIME、結合後検証、再開検証を注入できます。RAW 音声はサンプリング周波数、ビット深度、codec、フレーム境界を検証します。
|
|
923
|
+
|
|
922
924
|
`validateAzureSsml` の `urlValidation` オプションは URL の重複排除、キャッシュ、`concurrency`、`signal`、`timeoutMs` を制御します。
|
|
923
925
|
|
|
924
926
|
For long documents, use `synthesizeSsmlChunks` or `AzureTtsClient.synthesizeChunks`; `onProgress` reports completed chunks while audio and synchronization offsets are merged. `synthesizeSsmlSafe(client, ssml, { validation })` validates before synthesis and returns a discriminated result without calling Azure when static validation fails.
|
|
@@ -929,6 +931,8 @@ In v2.16.0, use `concurrency` and `retryOptions` to control chunk synthesis; onl
|
|
|
929
931
|
|
|
930
932
|
In v2.17.0, configure `customMerger`, `outputMimeType`, and `postMergeValidator` through the chunk synthesis pipeline. `BatchChunkValidationError` aggregates diagnostics and the total error count for every invalid chunk. `cancelOnFailure` and `resumeChunks` allow successful binary chunks to be reused, while `timeouts` independently bounds URL validation, individual chunks, retries, and the total job. HTTP 429 `Retry-After` takes priority over exponential backoff. `AudioSpecification` now includes `bitDepth`, `container`, and `isVbr`, and `mappingStatus` remains present after JSON serialization.
|
|
931
933
|
|
|
934
|
+
In v2.18.0, `resumeChunks` carries a fingerprint of the SSML, voice settings, and output format; stale cache entries are automatically re-synthesized. `PartialChunkSynthesisResult.chunkStates` distinguishes succeeded, directly failed, chained-cancelled, and pending chunks. `totalJobMs` also bounds single synthesis, and an over-budget `Retry-After` fails immediately without sleeping. `AzureTtsClient` accepts retry, cancellation, merger, MIME, post-merge validation, and resume-validation defaults. RAW audio now validates sample rate, bit depth, codec, and frame alignment.
|
|
935
|
+
|
|
932
936
|
The `urlValidation` option of `validateAzureSsml` provides URL deduplication, in-memory caching, bounded `concurrency`, `signal`, and `timeoutMs` controls.
|
|
933
937
|
|
|
934
938
|
The public updater CLI is `npx ssml-builder sync-voices --region eastus --output ./azure-voices.json`. It reads the key from `AZURE_SPEECH_KEY` (or `--key`) and regions from `AZURE_SPEECH_REGION(S)` (or `--region(s)`).
|
|
@@ -275,4 +275,4 @@ interface AzureVoiceCatalogMetadata {
|
|
|
275
275
|
regionDiffs?: Readonly<Record<string, readonly string[]>>;
|
|
276
276
|
}
|
|
277
277
|
|
|
278
|
-
export type { AzureValidationOptions as A,
|
|
278
|
+
export type { AzureValidationOptions as A, SsmlDiagnostic as S, SsmlTextRange as a, SsmlSourceTextSegment as b, SsmlSourceMarker as c, SsmlDocument as d, SsmlElement as e, AzureVoiceCatalogMetadata as f };
|
|
@@ -275,4 +275,4 @@ interface AzureVoiceCatalogMetadata {
|
|
|
275
275
|
regionDiffs?: Readonly<Record<string, readonly string[]>>;
|
|
276
276
|
}
|
|
277
277
|
|
|
278
|
-
export type { AzureValidationOptions as A,
|
|
278
|
+
export type { AzureValidationOptions as A, SsmlDiagnostic as S, SsmlTextRange as a, SsmlSourceTextSegment as b, SsmlSourceMarker 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
|
|
2
|
+
import { S as SsmlDiagnostic, A as AzureValidationOptions, a as SsmlTextRange, b as SsmlSourceTextSegment, c as SsmlSourceMarker } from './index.d-B2WddTa4.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";
|
|
@@ -47,6 +47,148 @@ 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;
|
|
@@ -76,12 +218,13 @@ interface TtsConfig {
|
|
|
76
218
|
customMerger?: CustomAudioMerger;
|
|
77
219
|
outputMimeType?: string;
|
|
78
220
|
postMergeValidator?: PostMergeValidator;
|
|
221
|
+
resumeValidation?: ResumeValidationMode;
|
|
79
222
|
}
|
|
80
223
|
type MappingStatus = "exact" | "fallback" | "unmapped";
|
|
81
224
|
interface AudioSpecification {
|
|
82
225
|
format: string;
|
|
83
226
|
mimeType: string;
|
|
84
|
-
codec: "pcm" | "mp3" | "opus" | "silk" | "unknown";
|
|
227
|
+
codec: "pcm" | "mulaw" | "alaw" | "siren" | "mp3" | "opus" | "silk" | "unknown";
|
|
85
228
|
sampleRate: number;
|
|
86
229
|
channels: number;
|
|
87
230
|
bitrate?: number;
|
|
@@ -90,6 +233,7 @@ interface AudioSpecification {
|
|
|
90
233
|
isVbr?: boolean;
|
|
91
234
|
isCompressed: boolean;
|
|
92
235
|
}
|
|
236
|
+
type ResumeValidationMode = "strict" | "disabled";
|
|
93
237
|
interface SynthesisTimeouts {
|
|
94
238
|
urlValidationMs?: number;
|
|
95
239
|
perChunkMs?: number;
|
|
@@ -200,6 +344,7 @@ interface SynthesizeChunksOptions {
|
|
|
200
344
|
customMerger?: CustomAudioMerger;
|
|
201
345
|
outputMimeType?: string;
|
|
202
346
|
postMergeValidator?: PostMergeValidator;
|
|
347
|
+
resumeValidation?: ResumeValidationMode;
|
|
203
348
|
}
|
|
204
349
|
interface CustomMergerContext {
|
|
205
350
|
format: string;
|
|
@@ -211,12 +356,25 @@ type CustomAudioMerger = (buffers: ArrayBuffer[], context: CustomMergerContext)
|
|
|
211
356
|
type PostMergeValidator = (result: MergedSynthesisResult, context: CustomMergerContext) => boolean | undefined | Promise<boolean | undefined>;
|
|
212
357
|
interface SynthesizedChunk extends SsmlSynthesisResult {
|
|
213
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;
|
|
214
370
|
}
|
|
215
371
|
interface PartialChunkSynthesisResult {
|
|
216
372
|
synthesizedChunks: readonly SynthesizedChunk[];
|
|
217
373
|
completedChunks: readonly SynthesizedChunk[];
|
|
218
374
|
pendingChunkIndices: readonly number[];
|
|
219
375
|
failedChunkIndices: readonly number[];
|
|
376
|
+
cancelledChunkIndices: readonly number[];
|
|
377
|
+
chunkStates: readonly ChunkExecutionState[];
|
|
220
378
|
totalChunks: number;
|
|
221
379
|
}
|
|
222
380
|
/** Alias for applications that use the shorter result name. */
|
|
@@ -253,147 +411,11 @@ interface AzureTtsClientOptions {
|
|
|
253
411
|
onProgress?: (event: SynthesisProgressEvent) => void;
|
|
254
412
|
concurrency?: number;
|
|
255
413
|
retryOptions?: RetryOptions;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
type SynthesisErrorKind = "validation-error" | "azure-api-error" | "merge-error" | "audio-format-mismatch" | "unsupported-format-error" | "cancelled" | "timeout";
|
|
259
|
-
declare class AzureTtsError extends Error {
|
|
260
|
-
readonly kind: "azure-api-error";
|
|
261
|
-
readonly status: number;
|
|
262
|
-
readonly statusText: string;
|
|
263
|
-
readonly responseBody: string;
|
|
264
|
-
readonly requestId: string | null;
|
|
265
|
-
readonly retryAfterMs?: number;
|
|
266
|
-
constructor(status: number, statusText: string, responseBody: string, requestId: string | null, responseHeaders?: Headers | Readonly<Record<string, string>>);
|
|
267
|
-
}
|
|
268
|
-
/** Reads Retry-After from an error-like value, returning milliseconds when present. */
|
|
269
|
-
declare function getRetryAfterDelayMs(error: unknown): number | undefined;
|
|
270
|
-
declare class AzureTtsSdkError extends AzureTtsError {
|
|
271
|
-
readonly errorDetails: string;
|
|
272
|
-
constructor(errorDetails: string);
|
|
273
|
-
}
|
|
274
|
-
declare class SynthesisCancelledError extends Error {
|
|
275
|
-
readonly kind: "cancelled";
|
|
276
|
-
constructor(message?: string);
|
|
277
|
-
}
|
|
278
|
-
declare class SynthesisTimeoutError extends Error {
|
|
279
|
-
readonly kind: "timeout";
|
|
280
|
-
constructor(message: string);
|
|
281
|
-
}
|
|
282
|
-
declare class MergeError extends Error {
|
|
283
|
-
readonly kind: "merge-error";
|
|
284
|
-
readonly cause: unknown;
|
|
285
|
-
constructor(message: string, cause?: unknown);
|
|
286
|
-
}
|
|
287
|
-
/** Thrown when chunk headers describe incompatible audio streams. */
|
|
288
|
-
declare class AudioFormatMismatchError extends Error {
|
|
289
|
-
readonly kind: "audio-format-mismatch";
|
|
290
|
-
readonly inputSpecs: readonly AudioSpecification[];
|
|
291
|
-
constructor(message: string, inputSpecs?: readonly AudioSpecification[]);
|
|
292
|
-
}
|
|
293
|
-
/** Thrown when audio buffers require container re-multiplexing before they can be merged. */
|
|
294
|
-
declare class UnsupportedMergeFormatError extends Error {
|
|
295
|
-
readonly kind: "unsupported-format-error";
|
|
296
|
-
readonly format: string;
|
|
297
|
-
constructor(format: string);
|
|
298
|
-
}
|
|
299
|
-
type AzureTtsSynthesisError = AzureTtsError | MergeError | AudioFormatMismatchError | UnsupportedMergeFormatError | SynthesisCancelledError | SynthesisTimeoutError;
|
|
300
|
-
|
|
301
|
-
interface SsmlValidationError {
|
|
302
|
-
readonly kind: "validation-error";
|
|
303
|
-
readonly message: string;
|
|
304
|
-
readonly diagnostics: readonly SsmlDiagnostic[];
|
|
305
|
-
}
|
|
306
|
-
type SsmlSynthesisError = SsmlValidationError | AzureTtsSynthesisError;
|
|
307
|
-
declare class ChunkValidationError extends Error {
|
|
308
|
-
readonly kind: "validation-error";
|
|
309
|
-
readonly chunkIndex: number;
|
|
310
|
-
readonly diagnostics: readonly SsmlDiagnostic[];
|
|
311
|
-
constructor(chunkIndex: number, diagnostics: readonly SsmlDiagnostic[]);
|
|
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
|
-
}
|
|
324
|
-
type Result<T, E> = {
|
|
325
|
-
readonly ok: true;
|
|
326
|
-
readonly success: true;
|
|
327
|
-
readonly status: "success";
|
|
328
|
-
readonly value: T;
|
|
329
|
-
} | (E extends {
|
|
330
|
-
readonly kind: infer Kind extends SynthesisErrorKind;
|
|
331
|
-
} ? {
|
|
332
|
-
readonly ok: false;
|
|
333
|
-
readonly success: false;
|
|
334
|
-
readonly status: Kind;
|
|
335
|
-
readonly error: E;
|
|
336
|
-
readonly partialResult?: PartialChunkSynthesisResult;
|
|
337
|
-
} : {
|
|
338
|
-
readonly ok: false;
|
|
339
|
-
readonly success: false;
|
|
340
|
-
readonly status: SynthesisErrorKind;
|
|
341
|
-
readonly error: E;
|
|
342
|
-
readonly partialResult?: PartialChunkSynthesisResult;
|
|
343
|
-
});
|
|
344
|
-
type SynthesisResult<T, E> = Result<T, E>;
|
|
345
|
-
type Success<T> = Extract<Result<T, never>, {
|
|
346
|
-
readonly ok: true;
|
|
347
|
-
}>;
|
|
348
|
-
type ValidationErrorResult = Extract<Result<never, SsmlValidationError>, {
|
|
349
|
-
readonly status: "validation-error";
|
|
350
|
-
}>;
|
|
351
|
-
type AzureApiErrorResult = Extract<Result<never, AzureTtsError>, {
|
|
352
|
-
readonly status: "azure-api-error";
|
|
353
|
-
}>;
|
|
354
|
-
type SsmlSynthesisSafeResult = Result<SsmlSynthesisResult, never> | Result<never, SsmlValidationError> | Result<never, SsmlSynthesisError>;
|
|
355
|
-
interface SynthesizeSsmlSafeOptions extends AzureValidationOptions {
|
|
356
|
-
/** Optional nested form for callers that want to keep validation settings grouped. */
|
|
357
|
-
validation?: AzureValidationOptions;
|
|
358
|
-
signal?: AbortSignal;
|
|
359
|
-
timeouts?: SynthesisTimeouts;
|
|
360
|
-
}
|
|
361
|
-
interface SynthesizeSsmlChunksSafeOptions extends AzureValidationOptions {
|
|
362
|
-
validation?: AzureValidationOptions;
|
|
363
|
-
outputFormat?: string;
|
|
364
|
-
signal?: AbortSignal;
|
|
365
|
-
timeoutMs?: number;
|
|
366
|
-
timeouts?: SynthesisTimeouts;
|
|
367
|
-
sourceNodePath?: string[];
|
|
368
|
-
onProgress?: (event: SynthesisProgressEvent) => void;
|
|
369
|
-
concurrency?: number;
|
|
370
|
-
retryOptions?: RetryOptions;
|
|
371
414
|
cancelOnFailure?: boolean;
|
|
372
|
-
resumeChunks?: readonly SynthesizedChunk[];
|
|
373
|
-
resumeChunkIndices?: readonly number[];
|
|
374
415
|
customMerger?: CustomAudioMerger;
|
|
375
416
|
outputMimeType?: string;
|
|
376
417
|
postMergeValidator?: PostMergeValidator;
|
|
377
|
-
|
|
378
|
-
type SsmlSynthesisChunksSafeResult = Result<SsmlSynthesisResult, never> | Result<never, ChunkValidationError> | Result<never, BatchChunkValidationError> | Result<never, SsmlSynthesisError | ChunkValidationError>;
|
|
379
|
-
interface SynthesisClient {
|
|
380
|
-
synthesizeSsml(ssml: string, options?: Partial<SynthesizeChunksOptions>): Promise<SsmlSynthesisResult>;
|
|
381
|
-
synthesizeChunks?(chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeChunksOptions): Promise<SsmlSynthesisResult>;
|
|
382
|
-
}
|
|
383
|
-
/** Validates SSML before invoking Azure and converts validation/API failures to one result shape. */
|
|
384
|
-
declare function synthesizeSsmlSafe(client: Pick<AzureTtsClient, "synthesizeSsml"> | SynthesisClient, ssml: string, options?: SynthesizeSsmlSafeOptions): Promise<SsmlSynthesisSafeResult>;
|
|
385
|
-
/** Validates every chunk before synthesis and returns a chunk-addressable result. */
|
|
386
|
-
declare function synthesizeSsmlChunksSafe(client: Pick<AzureTtsClient, "synthesizeSsml" | "synthesizeChunks"> | SynthesisClient, chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeSsmlChunksSafeOptions): Promise<SsmlSynthesisChunksSafeResult>;
|
|
387
|
-
|
|
388
|
-
declare class AzureTtsClient {
|
|
389
|
-
#private;
|
|
390
|
-
constructor(options: AzureTtsClientOptions);
|
|
391
|
-
synthesize(ssml: string): Promise<ArrayBuffer>;
|
|
392
|
-
synthesizeSsml(ssml: string, options?: Partial<TtsConfig>): Promise<SsmlSynthesisResult>;
|
|
393
|
-
synthesizeChunks(chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeChunksOptions): Promise<SsmlSynthesisResult>;
|
|
394
|
-
synthesizeSsmlSafe(ssml: string, options?: SynthesizeSsmlSafeOptions): Promise<SsmlSynthesisSafeResult>;
|
|
395
|
-
synthesizeChunksSafe(chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeSsmlChunksSafeOptions): Promise<SsmlSynthesisChunksSafeResult>;
|
|
396
|
-
synthesizeSsmlChunksSafe(chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeSsmlChunksSafeOptions): Promise<SsmlSynthesisChunksSafeResult>;
|
|
418
|
+
resumeValidation?: ResumeValidationMode;
|
|
397
419
|
}
|
|
398
420
|
|
|
399
421
|
type MergeAudioFormat = "wav" | "mp3" | "raw";
|
|
@@ -403,6 +425,12 @@ interface MergeAudioOptions {
|
|
|
403
425
|
outputMimeType?: string;
|
|
404
426
|
}
|
|
405
427
|
type InputAudioSpecs = AudioSpecification[];
|
|
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;
|
|
406
434
|
interface MergeSynthesisOptions extends MergeAudioOptions {
|
|
407
435
|
customMerger?: CustomAudioMerger;
|
|
408
436
|
postMergeValidator?: PostMergeValidator;
|
|
@@ -417,6 +445,7 @@ declare function resolveMergeAudioFormat(format: string): MergeAudioFormat | und
|
|
|
417
445
|
declare function canMergeAudioFormat(format: string): boolean;
|
|
418
446
|
/** Merges audio buffers while preserving the invariants of supported containers. */
|
|
419
447
|
declare function mergeAudioBuffers(buffers: readonly ArrayBuffer[], options: MergeAudioOptions): ArrayBuffer;
|
|
448
|
+
/** Synthesizes one SSML document, optionally retrying transient failures within the job deadline. */
|
|
420
449
|
declare function synthesizeSsml(ssml: string, config: TtsConfig): Promise<SsmlSynthesisResult>;
|
|
421
450
|
/** Synthesizes chunks with bounded concurrency, retries transient failures, and merges in chunk order. */
|
|
422
451
|
declare function synthesizeSsmlChunks(chunks: readonly (SsmlSynthesisChunk | string)[], config: TtsConfig): Promise<SsmlSynthesisResult>;
|
|
@@ -456,4 +485,4 @@ interface AzureVoiceCatalog {
|
|
|
456
485
|
/** Fetches and deduplicates the current Azure Speech voice catalog for one or more regions. */
|
|
457
486
|
declare function fetchAzureVoiceCatalog(options: FetchAzureVoiceCatalogOptions): Promise<AzureVoiceCatalog>;
|
|
458
487
|
|
|
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 };
|
|
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 };
|