ssml-builder-js 2.17.0 → 2.19.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 +8 -0
- package/dist/{index.d-tpKoP1jl.d.mts → index.d-4kqVuH29.d.mts} +1 -1
- package/dist/{index.d-tpKoP1jl.d.ts → index.d-4kqVuH29.d.ts} +1 -1
- package/dist/index.d.mts +124 -44
- package/dist/index.d.ts +124 -44
- package/dist/index.js +674 -90
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +670 -90
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +45 -24
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +45 -24
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -919,6 +919,10 @@ 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
|
+
|
|
924
|
+
v2.19.0 では、再開フィンガープリントに SSML、voice、言語、出力形式、リージョン、endpoint、custom headers、スキーマバージョンを含め、環境の異なるキャッシュの再利用を防ぎます。`resumeChunkIndices` の欠落は `IncompleteChunkSetError` で結合前に拒否され、`ChunkExecutionState.error` は JSON 化可能な `SerializedChunkError` になります。単一合成を含む URL 検証、再試行、チャンク合成、結合は絶対 deadline で制限され、Ogg/WebM/RAW Opus/SILK の実体ヘッダーも検証します。Visual editor は `expressAs` などの別名を正規化し、neural-HD の非対応タグを表示します。
|
|
925
|
+
|
|
922
926
|
`validateAzureSsml` の `urlValidation` オプションは URL の重複排除、キャッシュ、`concurrency`、`signal`、`timeoutMs` を制御します。
|
|
923
927
|
|
|
924
928
|
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 +933,10 @@ In v2.16.0, use `concurrency` and `retryOptions` to control chunk synthesis; onl
|
|
|
929
933
|
|
|
930
934
|
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
935
|
|
|
936
|
+
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.
|
|
937
|
+
|
|
938
|
+
In v2.19.0, resume fingerprints include SSML, voice, language, output format, region, endpoint, custom headers, and schema version so cached chunks cannot cross synthesis environments. Missing `resumeChunkIndices` are rejected before merge with `IncompleteChunkSetError`, and `ChunkExecutionState.error` is a JSON-serializable `SerializedChunkError`. URL validation, retries, chunk synthesis, and merging share an absolute deadline, including single synthesis. Ogg/WebM/RAW Opus/SILK payloads receive concrete container or header validation, and the visual editor normalizes aliases such as `expressAs` while showing neural-HD unsupported tags.
|
|
939
|
+
|
|
932
940
|
The `urlValidation` option of `validateAzureSsml` provides URL deduplication, in-memory caching, bounded `concurrency`, `signal`, and `timeoutMs` controls.
|
|
933
941
|
|
|
934
942
|
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 {
|
|
278
|
+
export type { AzureVoiceCatalogMetadata as A, SsmlDocument as S, SsmlElement as a, SsmlTextRange as b, SsmlSourceTextSegment as c, SsmlSourceMarker as d, SsmlDiagnostic as e, AzureValidationOptions as f };
|
|
@@ -275,4 +275,4 @@ interface AzureVoiceCatalogMetadata {
|
|
|
275
275
|
regionDiffs?: Readonly<Record<string, readonly string[]>>;
|
|
276
276
|
}
|
|
277
277
|
|
|
278
|
-
export type {
|
|
278
|
+
export type { AzureVoiceCatalogMetadata as A, SsmlDocument as S, SsmlElement as a, SsmlTextRange as b, SsmlSourceTextSegment as c, SsmlSourceMarker as d, SsmlDiagnostic as e, AzureValidationOptions 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 {
|
|
2
|
+
import { b as SsmlTextRange, c as SsmlSourceTextSegment, d as SsmlSourceMarker, e as SsmlDiagnostic, f as AzureValidationOptions } from './index.d-4kqVuH29.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,68 @@ 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" | "incomplete-chunk-set";
|
|
51
|
+
type SerializedChunkErrorCode = "VALIDATION_ERROR" | "AZURE_API_ERROR" | "TIMEOUT" | "CANCELLED" | "MERGE_ERROR" | "FORMAT_MISMATCH";
|
|
52
|
+
interface SerializedChunkError {
|
|
53
|
+
code: SerializedChunkErrorCode;
|
|
54
|
+
phase: "url-validation" | "synthesis" | "merge";
|
|
55
|
+
message: string;
|
|
56
|
+
isOriginalFailure: boolean;
|
|
57
|
+
isRetryable: boolean;
|
|
58
|
+
httpStatus?: number;
|
|
59
|
+
details?: Record<string, unknown>;
|
|
60
|
+
}
|
|
61
|
+
/** Backward-compatible name used by persisted execution-state consumers. */
|
|
62
|
+
type SerializedExecutionError = SerializedChunkError;
|
|
63
|
+
declare class AzureTtsError extends Error {
|
|
64
|
+
readonly kind: "azure-api-error";
|
|
65
|
+
readonly status: number;
|
|
66
|
+
readonly statusText: string;
|
|
67
|
+
readonly responseBody: string;
|
|
68
|
+
readonly requestId: string | null;
|
|
69
|
+
readonly retryAfterMs?: number;
|
|
70
|
+
constructor(status: number, statusText: string, responseBody: string, requestId: string | null, responseHeaders?: Headers | Readonly<Record<string, string>>);
|
|
71
|
+
}
|
|
72
|
+
/** Reads Retry-After from an error-like value, returning milliseconds when present. */
|
|
73
|
+
declare function getRetryAfterDelayMs(error: unknown): number | undefined;
|
|
74
|
+
declare class AzureTtsSdkError extends AzureTtsError {
|
|
75
|
+
readonly errorDetails: string;
|
|
76
|
+
constructor(errorDetails: string);
|
|
77
|
+
}
|
|
78
|
+
declare class SynthesisCancelledError extends Error {
|
|
79
|
+
readonly kind: "cancelled";
|
|
80
|
+
constructor(message?: string);
|
|
81
|
+
}
|
|
82
|
+
declare class SynthesisTimeoutError extends Error {
|
|
83
|
+
readonly kind: "timeout";
|
|
84
|
+
constructor(message: string);
|
|
85
|
+
}
|
|
86
|
+
declare class IncompleteChunkSetError extends Error {
|
|
87
|
+
readonly kind: "incomplete-chunk-set";
|
|
88
|
+
readonly totalChunks: number;
|
|
89
|
+
readonly missingChunkIndices: readonly number[];
|
|
90
|
+
constructor(totalChunks: number, missingChunkIndices: readonly number[]);
|
|
91
|
+
}
|
|
92
|
+
declare class MergeError extends Error {
|
|
93
|
+
readonly kind: "merge-error";
|
|
94
|
+
readonly cause: unknown;
|
|
95
|
+
constructor(message: string, cause?: unknown);
|
|
96
|
+
}
|
|
97
|
+
/** Thrown when chunk headers describe incompatible audio streams. */
|
|
98
|
+
declare class AudioFormatMismatchError extends Error {
|
|
99
|
+
readonly kind: "audio-format-mismatch";
|
|
100
|
+
readonly inputSpecs: readonly AudioSpecification[];
|
|
101
|
+
constructor(message: string, inputSpecs?: readonly AudioSpecification[]);
|
|
102
|
+
}
|
|
103
|
+
/** Thrown when audio buffers require container re-multiplexing before they can be merged. */
|
|
104
|
+
declare class UnsupportedMergeFormatError extends Error {
|
|
105
|
+
readonly kind: "unsupported-format-error";
|
|
106
|
+
readonly format: string;
|
|
107
|
+
constructor(format: string);
|
|
108
|
+
}
|
|
109
|
+
type AzureTtsSynthesisError = AzureTtsError | MergeError | AudioFormatMismatchError | UnsupportedMergeFormatError | SynthesisCancelledError | SynthesisTimeoutError | IncompleteChunkSetError;
|
|
110
|
+
declare function serializeChunkError(error: unknown, phase: SerializedChunkError["phase"], isOriginalFailure: boolean): SerializedChunkError;
|
|
111
|
+
|
|
50
112
|
interface TtsConfig {
|
|
51
113
|
signal?: AbortSignal;
|
|
52
114
|
timeoutMs?: number;
|
|
@@ -55,6 +117,8 @@ interface TtsConfig {
|
|
|
55
117
|
subscriptionKey: string;
|
|
56
118
|
region: string;
|
|
57
119
|
outputFormat?: string;
|
|
120
|
+
customHeaders?: Readonly<Record<string, string>>;
|
|
121
|
+
fingerprintSchemaVersion?: string;
|
|
58
122
|
/** Original plain-text range represented by this synthesis request. */
|
|
59
123
|
sourceTextRange?: {
|
|
60
124
|
start: number;
|
|
@@ -76,12 +140,13 @@ interface TtsConfig {
|
|
|
76
140
|
customMerger?: CustomAudioMerger;
|
|
77
141
|
outputMimeType?: string;
|
|
78
142
|
postMergeValidator?: PostMergeValidator;
|
|
143
|
+
resumeValidation?: ResumeValidationMode;
|
|
79
144
|
}
|
|
80
145
|
type MappingStatus = "exact" | "fallback" | "unmapped";
|
|
81
146
|
interface AudioSpecification {
|
|
82
147
|
format: string;
|
|
83
148
|
mimeType: string;
|
|
84
|
-
codec: "pcm" | "mp3" | "opus" | "silk" | "unknown";
|
|
149
|
+
codec: "pcm" | "mulaw" | "alaw" | "siren" | "mp3" | "opus" | "silk" | "unknown";
|
|
85
150
|
sampleRate: number;
|
|
86
151
|
channels: number;
|
|
87
152
|
bitrate?: number;
|
|
@@ -90,6 +155,7 @@ interface AudioSpecification {
|
|
|
90
155
|
isVbr?: boolean;
|
|
91
156
|
isCompressed: boolean;
|
|
92
157
|
}
|
|
158
|
+
type ResumeValidationMode = "strict" | "disabled";
|
|
93
159
|
interface SynthesisTimeouts {
|
|
94
160
|
urlValidationMs?: number;
|
|
95
161
|
perChunkMs?: number;
|
|
@@ -188,6 +254,8 @@ interface SsmlSynthesisChunk {
|
|
|
188
254
|
interface SynthesizeChunksOptions {
|
|
189
255
|
onProgress?: (event: SynthesisProgressEvent) => void;
|
|
190
256
|
outputFormat?: AzureTtsOutputFormat | string;
|
|
257
|
+
customHeaders?: Readonly<Record<string, string>>;
|
|
258
|
+
fingerprintSchemaVersion?: string;
|
|
191
259
|
signal?: AbortSignal;
|
|
192
260
|
timeoutMs?: number;
|
|
193
261
|
timeouts?: SynthesisTimeouts;
|
|
@@ -200,6 +268,7 @@ interface SynthesizeChunksOptions {
|
|
|
200
268
|
customMerger?: CustomAudioMerger;
|
|
201
269
|
outputMimeType?: string;
|
|
202
270
|
postMergeValidator?: PostMergeValidator;
|
|
271
|
+
resumeValidation?: ResumeValidationMode;
|
|
203
272
|
}
|
|
204
273
|
interface CustomMergerContext {
|
|
205
274
|
format: string;
|
|
@@ -211,12 +280,25 @@ type CustomAudioMerger = (buffers: ArrayBuffer[], context: CustomMergerContext)
|
|
|
211
280
|
type PostMergeValidator = (result: MergedSynthesisResult, context: CustomMergerContext) => boolean | undefined | Promise<boolean | undefined>;
|
|
212
281
|
interface SynthesizedChunk extends SsmlSynthesisResult {
|
|
213
282
|
chunkIndex: number;
|
|
283
|
+
/** Fingerprint of the SSML and synthesis settings used to create this chunk. */
|
|
284
|
+
fingerprint: string;
|
|
285
|
+
}
|
|
286
|
+
type ChunkExecutionStatus = "succeeded" | "failed" | "cancelled" | "pending";
|
|
287
|
+
interface ChunkExecutionState {
|
|
288
|
+
chunkIndex: number;
|
|
289
|
+
status: ChunkExecutionStatus;
|
|
290
|
+
error?: SerializedChunkError;
|
|
291
|
+
isOriginalFailure?: boolean;
|
|
292
|
+
canResume: boolean;
|
|
293
|
+
result?: SsmlSynthesisResult;
|
|
214
294
|
}
|
|
215
295
|
interface PartialChunkSynthesisResult {
|
|
216
296
|
synthesizedChunks: readonly SynthesizedChunk[];
|
|
217
297
|
completedChunks: readonly SynthesizedChunk[];
|
|
218
298
|
pendingChunkIndices: readonly number[];
|
|
219
299
|
failedChunkIndices: readonly number[];
|
|
300
|
+
cancelledChunkIndices: readonly number[];
|
|
301
|
+
chunkStates: readonly ChunkExecutionState[];
|
|
220
302
|
totalChunks: number;
|
|
221
303
|
}
|
|
222
304
|
/** Alias for applications that use the shorter result name. */
|
|
@@ -249,54 +331,31 @@ interface AzureTtsClientOptions {
|
|
|
249
331
|
region: string;
|
|
250
332
|
endpoint?: string;
|
|
251
333
|
outputFormat?: string;
|
|
334
|
+
customHeaders?: Readonly<Record<string, string>>;
|
|
335
|
+
fingerprintSchemaVersion?: string;
|
|
252
336
|
logger?: AzureTtsLogger;
|
|
253
337
|
onProgress?: (event: SynthesisProgressEvent) => void;
|
|
254
338
|
concurrency?: number;
|
|
255
339
|
retryOptions?: RetryOptions;
|
|
340
|
+
cancelOnFailure?: boolean;
|
|
341
|
+
customMerger?: CustomAudioMerger;
|
|
342
|
+
outputMimeType?: string;
|
|
343
|
+
postMergeValidator?: PostMergeValidator;
|
|
344
|
+
resumeValidation?: ResumeValidationMode;
|
|
256
345
|
}
|
|
257
346
|
|
|
258
|
-
|
|
259
|
-
declare class
|
|
260
|
-
|
|
261
|
-
readonly
|
|
262
|
-
readonly
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
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);
|
|
347
|
+
/** Coordinates one absolute deadline across validation, synthesis, retries, and merging. */
|
|
348
|
+
declare class DeadlineController {
|
|
349
|
+
#private;
|
|
350
|
+
readonly deadlineAtMs: number | undefined;
|
|
351
|
+
readonly signal: AbortSignal;
|
|
352
|
+
constructor(totalJobMs: number | undefined, parent?: AbortSignal);
|
|
353
|
+
get timedOut(): boolean;
|
|
354
|
+
get remainingMs(): number;
|
|
355
|
+
throwIfExpired(): void;
|
|
356
|
+
abort(): void;
|
|
357
|
+
dispose(): void;
|
|
298
358
|
}
|
|
299
|
-
type AzureTtsSynthesisError = AzureTtsError | MergeError | AudioFormatMismatchError | UnsupportedMergeFormatError | SynthesisCancelledError | SynthesisTimeoutError;
|
|
300
359
|
|
|
301
360
|
interface SsmlValidationError {
|
|
302
361
|
readonly kind: "validation-error";
|
|
@@ -361,6 +420,8 @@ interface SynthesizeSsmlSafeOptions extends AzureValidationOptions {
|
|
|
361
420
|
interface SynthesizeSsmlChunksSafeOptions extends AzureValidationOptions {
|
|
362
421
|
validation?: AzureValidationOptions;
|
|
363
422
|
outputFormat?: string;
|
|
423
|
+
customHeaders?: Readonly<Record<string, string>>;
|
|
424
|
+
fingerprintSchemaVersion?: string;
|
|
364
425
|
signal?: AbortSignal;
|
|
365
426
|
timeoutMs?: number;
|
|
366
427
|
timeouts?: SynthesisTimeouts;
|
|
@@ -374,6 +435,7 @@ interface SynthesizeSsmlChunksSafeOptions extends AzureValidationOptions {
|
|
|
374
435
|
customMerger?: CustomAudioMerger;
|
|
375
436
|
outputMimeType?: string;
|
|
376
437
|
postMergeValidator?: PostMergeValidator;
|
|
438
|
+
resumeValidation?: ResumeValidationMode;
|
|
377
439
|
}
|
|
378
440
|
type SsmlSynthesisChunksSafeResult = Result<SsmlSynthesisResult, never> | Result<never, ChunkValidationError> | Result<never, BatchChunkValidationError> | Result<never, SsmlSynthesisError | ChunkValidationError>;
|
|
379
441
|
interface SynthesisClient {
|
|
@@ -403,9 +465,26 @@ interface MergeAudioOptions {
|
|
|
403
465
|
outputMimeType?: string;
|
|
404
466
|
}
|
|
405
467
|
type InputAudioSpecs = AudioSpecification[];
|
|
468
|
+
/**
|
|
469
|
+
* Creates a deterministic, runtime-independent fingerprint for a synthesis chunk.
|
|
470
|
+
* The complete SSML is included so changes to voice, language, prosody, or text
|
|
471
|
+
* invalidate a cached result even when those settings are nested in the markup.
|
|
472
|
+
*/
|
|
473
|
+
interface ChunkFingerprintOptions {
|
|
474
|
+
outputFormat?: string;
|
|
475
|
+
region?: string;
|
|
476
|
+
endpoint?: string;
|
|
477
|
+
voice?: string;
|
|
478
|
+
lang?: string;
|
|
479
|
+
schemaVersion?: string;
|
|
480
|
+
fingerprintSchemaVersion?: string;
|
|
481
|
+
customHeaders?: Readonly<Record<string, string>>;
|
|
482
|
+
}
|
|
483
|
+
declare function computeChunkFingerprint(ssml: string, outputFormat?: string, options?: Omit<ChunkFingerprintOptions, "outputFormat">): string;
|
|
406
484
|
interface MergeSynthesisOptions extends MergeAudioOptions {
|
|
407
485
|
customMerger?: CustomAudioMerger;
|
|
408
486
|
postMergeValidator?: PostMergeValidator;
|
|
487
|
+
deadline?: DeadlineController;
|
|
409
488
|
}
|
|
410
489
|
type AsyncMergeSynthesisOptions = MergeSynthesisOptions & {
|
|
411
490
|
customMerger: NonNullable<MergeSynthesisOptions["customMerger"]>;
|
|
@@ -417,6 +496,7 @@ declare function resolveMergeAudioFormat(format: string): MergeAudioFormat | und
|
|
|
417
496
|
declare function canMergeAudioFormat(format: string): boolean;
|
|
418
497
|
/** Merges audio buffers while preserving the invariants of supported containers. */
|
|
419
498
|
declare function mergeAudioBuffers(buffers: readonly ArrayBuffer[], options: MergeAudioOptions): ArrayBuffer;
|
|
499
|
+
/** Synthesizes one SSML document, optionally retrying transient failures within the job deadline. */
|
|
420
500
|
declare function synthesizeSsml(ssml: string, config: TtsConfig): Promise<SsmlSynthesisResult>;
|
|
421
501
|
/** Synthesizes chunks with bounded concurrency, retries transient failures, and merges in chunk order. */
|
|
422
502
|
declare function synthesizeSsmlChunks(chunks: readonly (SsmlSynthesisChunk | string)[], config: TtsConfig): Promise<SsmlSynthesisResult>;
|
|
@@ -456,4 +536,4 @@ interface AzureVoiceCatalog {
|
|
|
456
536
|
/** Fetches and deduplicates the current Azure Speech voice catalog for one or more regions. */
|
|
457
537
|
declare function fetchAzureVoiceCatalog(options: FetchAzureVoiceCatalogOptions): Promise<AzureVoiceCatalog>;
|
|
458
538
|
|
|
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 };
|
|
539
|
+
export { AudioFormatMismatchError, type AudioSpecification, type AzureApiErrorResult, type SsmlValidationError as AzureSsmlValidationError, AzureTtsClient, type AzureTtsClientOptions, AzureTtsError, type AzureTtsLogger, type AzureTtsOutputFormat, AzureTtsSdkError, type AzureTtsSynthesisError, type AzureVoiceCatalog, type AzureVoiceCatalogVoice, BatchChunkValidationError, type ChunkDiagnostics, type ChunkExecutionState, type ChunkExecutionStatus, type ChunkFingerprintOptions, ChunkValidationError, type CustomAudioMerger, type CustomMergerContext, DEFAULT_OUTPUT_FORMAT, DeadlineController, type FetchAzureVoiceCatalogOptions, type FetchedAzureVoiceCatalogMetadata, IncompleteChunkSetError, type InputAudioSpecs, type MappingStatus, type MergeAudioFormat, type MergeAudioOptions, MergeError, type MergeSynthesisOptions, type MergedSynthesisResult, type PartialChunkSynthesisResult, type PartialSynthesisResult, type PostMergeValidator, type Result, type ResumeValidationMode, type RetryOptions, type SerializedChunkError, type SerializedChunkErrorCode, type SerializedExecutionError, type SsmlSynthesisBookmark, type SsmlSynthesisBoundary, type SsmlSynthesisChunk, type SsmlSynthesisChunksSafeResult, type SsmlSynthesisError, type SsmlSynthesisResult, type SsmlSynthesisSafeResult, type SsmlSynthesisViseme, type Success, SynthesisCancelledError, type SynthesisChunkStatus, type SynthesisErrorKind, type SynthesisProgressEvent, type SynthesisResult, SynthesisTimeoutError, type SynthesisTimeouts, type SynthesizeChunksOptions, type SynthesizeSsmlChunksSafeOptions, type SynthesizeSsmlSafeOptions, type SynthesizedChunk, type TtsConfig, UnsupportedMergeFormatError, type ValidationErrorResult, canMergeAudioFormat, computeChunkFingerprint, fetchAzureVoiceCatalog, getRetryAfterDelayMs, inspectAudioSpecification, mergeAudioBuffers, mergeSynthesisResults, resolveMergeAudioFormat, resolveMimeType, serializeChunkError, synthesizeSpeech, synthesizeSsml, synthesizeSsmlChunks, synthesizeSsmlChunksSafe, synthesizeSsmlSafe };
|
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 {
|
|
2
|
+
import { b as SsmlTextRange, c as SsmlSourceTextSegment, d as SsmlSourceMarker, e as SsmlDiagnostic, f as AzureValidationOptions } from './index.d-4kqVuH29.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,6 +47,68 @@ 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" | "incomplete-chunk-set";
|
|
51
|
+
type SerializedChunkErrorCode = "VALIDATION_ERROR" | "AZURE_API_ERROR" | "TIMEOUT" | "CANCELLED" | "MERGE_ERROR" | "FORMAT_MISMATCH";
|
|
52
|
+
interface SerializedChunkError {
|
|
53
|
+
code: SerializedChunkErrorCode;
|
|
54
|
+
phase: "url-validation" | "synthesis" | "merge";
|
|
55
|
+
message: string;
|
|
56
|
+
isOriginalFailure: boolean;
|
|
57
|
+
isRetryable: boolean;
|
|
58
|
+
httpStatus?: number;
|
|
59
|
+
details?: Record<string, unknown>;
|
|
60
|
+
}
|
|
61
|
+
/** Backward-compatible name used by persisted execution-state consumers. */
|
|
62
|
+
type SerializedExecutionError = SerializedChunkError;
|
|
63
|
+
declare class AzureTtsError extends Error {
|
|
64
|
+
readonly kind: "azure-api-error";
|
|
65
|
+
readonly status: number;
|
|
66
|
+
readonly statusText: string;
|
|
67
|
+
readonly responseBody: string;
|
|
68
|
+
readonly requestId: string | null;
|
|
69
|
+
readonly retryAfterMs?: number;
|
|
70
|
+
constructor(status: number, statusText: string, responseBody: string, requestId: string | null, responseHeaders?: Headers | Readonly<Record<string, string>>);
|
|
71
|
+
}
|
|
72
|
+
/** Reads Retry-After from an error-like value, returning milliseconds when present. */
|
|
73
|
+
declare function getRetryAfterDelayMs(error: unknown): number | undefined;
|
|
74
|
+
declare class AzureTtsSdkError extends AzureTtsError {
|
|
75
|
+
readonly errorDetails: string;
|
|
76
|
+
constructor(errorDetails: string);
|
|
77
|
+
}
|
|
78
|
+
declare class SynthesisCancelledError extends Error {
|
|
79
|
+
readonly kind: "cancelled";
|
|
80
|
+
constructor(message?: string);
|
|
81
|
+
}
|
|
82
|
+
declare class SynthesisTimeoutError extends Error {
|
|
83
|
+
readonly kind: "timeout";
|
|
84
|
+
constructor(message: string);
|
|
85
|
+
}
|
|
86
|
+
declare class IncompleteChunkSetError extends Error {
|
|
87
|
+
readonly kind: "incomplete-chunk-set";
|
|
88
|
+
readonly totalChunks: number;
|
|
89
|
+
readonly missingChunkIndices: readonly number[];
|
|
90
|
+
constructor(totalChunks: number, missingChunkIndices: readonly number[]);
|
|
91
|
+
}
|
|
92
|
+
declare class MergeError extends Error {
|
|
93
|
+
readonly kind: "merge-error";
|
|
94
|
+
readonly cause: unknown;
|
|
95
|
+
constructor(message: string, cause?: unknown);
|
|
96
|
+
}
|
|
97
|
+
/** Thrown when chunk headers describe incompatible audio streams. */
|
|
98
|
+
declare class AudioFormatMismatchError extends Error {
|
|
99
|
+
readonly kind: "audio-format-mismatch";
|
|
100
|
+
readonly inputSpecs: readonly AudioSpecification[];
|
|
101
|
+
constructor(message: string, inputSpecs?: readonly AudioSpecification[]);
|
|
102
|
+
}
|
|
103
|
+
/** Thrown when audio buffers require container re-multiplexing before they can be merged. */
|
|
104
|
+
declare class UnsupportedMergeFormatError extends Error {
|
|
105
|
+
readonly kind: "unsupported-format-error";
|
|
106
|
+
readonly format: string;
|
|
107
|
+
constructor(format: string);
|
|
108
|
+
}
|
|
109
|
+
type AzureTtsSynthesisError = AzureTtsError | MergeError | AudioFormatMismatchError | UnsupportedMergeFormatError | SynthesisCancelledError | SynthesisTimeoutError | IncompleteChunkSetError;
|
|
110
|
+
declare function serializeChunkError(error: unknown, phase: SerializedChunkError["phase"], isOriginalFailure: boolean): SerializedChunkError;
|
|
111
|
+
|
|
50
112
|
interface TtsConfig {
|
|
51
113
|
signal?: AbortSignal;
|
|
52
114
|
timeoutMs?: number;
|
|
@@ -55,6 +117,8 @@ interface TtsConfig {
|
|
|
55
117
|
subscriptionKey: string;
|
|
56
118
|
region: string;
|
|
57
119
|
outputFormat?: string;
|
|
120
|
+
customHeaders?: Readonly<Record<string, string>>;
|
|
121
|
+
fingerprintSchemaVersion?: string;
|
|
58
122
|
/** Original plain-text range represented by this synthesis request. */
|
|
59
123
|
sourceTextRange?: {
|
|
60
124
|
start: number;
|
|
@@ -76,12 +140,13 @@ interface TtsConfig {
|
|
|
76
140
|
customMerger?: CustomAudioMerger;
|
|
77
141
|
outputMimeType?: string;
|
|
78
142
|
postMergeValidator?: PostMergeValidator;
|
|
143
|
+
resumeValidation?: ResumeValidationMode;
|
|
79
144
|
}
|
|
80
145
|
type MappingStatus = "exact" | "fallback" | "unmapped";
|
|
81
146
|
interface AudioSpecification {
|
|
82
147
|
format: string;
|
|
83
148
|
mimeType: string;
|
|
84
|
-
codec: "pcm" | "mp3" | "opus" | "silk" | "unknown";
|
|
149
|
+
codec: "pcm" | "mulaw" | "alaw" | "siren" | "mp3" | "opus" | "silk" | "unknown";
|
|
85
150
|
sampleRate: number;
|
|
86
151
|
channels: number;
|
|
87
152
|
bitrate?: number;
|
|
@@ -90,6 +155,7 @@ interface AudioSpecification {
|
|
|
90
155
|
isVbr?: boolean;
|
|
91
156
|
isCompressed: boolean;
|
|
92
157
|
}
|
|
158
|
+
type ResumeValidationMode = "strict" | "disabled";
|
|
93
159
|
interface SynthesisTimeouts {
|
|
94
160
|
urlValidationMs?: number;
|
|
95
161
|
perChunkMs?: number;
|
|
@@ -188,6 +254,8 @@ interface SsmlSynthesisChunk {
|
|
|
188
254
|
interface SynthesizeChunksOptions {
|
|
189
255
|
onProgress?: (event: SynthesisProgressEvent) => void;
|
|
190
256
|
outputFormat?: AzureTtsOutputFormat | string;
|
|
257
|
+
customHeaders?: Readonly<Record<string, string>>;
|
|
258
|
+
fingerprintSchemaVersion?: string;
|
|
191
259
|
signal?: AbortSignal;
|
|
192
260
|
timeoutMs?: number;
|
|
193
261
|
timeouts?: SynthesisTimeouts;
|
|
@@ -200,6 +268,7 @@ interface SynthesizeChunksOptions {
|
|
|
200
268
|
customMerger?: CustomAudioMerger;
|
|
201
269
|
outputMimeType?: string;
|
|
202
270
|
postMergeValidator?: PostMergeValidator;
|
|
271
|
+
resumeValidation?: ResumeValidationMode;
|
|
203
272
|
}
|
|
204
273
|
interface CustomMergerContext {
|
|
205
274
|
format: string;
|
|
@@ -211,12 +280,25 @@ type CustomAudioMerger = (buffers: ArrayBuffer[], context: CustomMergerContext)
|
|
|
211
280
|
type PostMergeValidator = (result: MergedSynthesisResult, context: CustomMergerContext) => boolean | undefined | Promise<boolean | undefined>;
|
|
212
281
|
interface SynthesizedChunk extends SsmlSynthesisResult {
|
|
213
282
|
chunkIndex: number;
|
|
283
|
+
/** Fingerprint of the SSML and synthesis settings used to create this chunk. */
|
|
284
|
+
fingerprint: string;
|
|
285
|
+
}
|
|
286
|
+
type ChunkExecutionStatus = "succeeded" | "failed" | "cancelled" | "pending";
|
|
287
|
+
interface ChunkExecutionState {
|
|
288
|
+
chunkIndex: number;
|
|
289
|
+
status: ChunkExecutionStatus;
|
|
290
|
+
error?: SerializedChunkError;
|
|
291
|
+
isOriginalFailure?: boolean;
|
|
292
|
+
canResume: boolean;
|
|
293
|
+
result?: SsmlSynthesisResult;
|
|
214
294
|
}
|
|
215
295
|
interface PartialChunkSynthesisResult {
|
|
216
296
|
synthesizedChunks: readonly SynthesizedChunk[];
|
|
217
297
|
completedChunks: readonly SynthesizedChunk[];
|
|
218
298
|
pendingChunkIndices: readonly number[];
|
|
219
299
|
failedChunkIndices: readonly number[];
|
|
300
|
+
cancelledChunkIndices: readonly number[];
|
|
301
|
+
chunkStates: readonly ChunkExecutionState[];
|
|
220
302
|
totalChunks: number;
|
|
221
303
|
}
|
|
222
304
|
/** Alias for applications that use the shorter result name. */
|
|
@@ -249,54 +331,31 @@ interface AzureTtsClientOptions {
|
|
|
249
331
|
region: string;
|
|
250
332
|
endpoint?: string;
|
|
251
333
|
outputFormat?: string;
|
|
334
|
+
customHeaders?: Readonly<Record<string, string>>;
|
|
335
|
+
fingerprintSchemaVersion?: string;
|
|
252
336
|
logger?: AzureTtsLogger;
|
|
253
337
|
onProgress?: (event: SynthesisProgressEvent) => void;
|
|
254
338
|
concurrency?: number;
|
|
255
339
|
retryOptions?: RetryOptions;
|
|
340
|
+
cancelOnFailure?: boolean;
|
|
341
|
+
customMerger?: CustomAudioMerger;
|
|
342
|
+
outputMimeType?: string;
|
|
343
|
+
postMergeValidator?: PostMergeValidator;
|
|
344
|
+
resumeValidation?: ResumeValidationMode;
|
|
256
345
|
}
|
|
257
346
|
|
|
258
|
-
|
|
259
|
-
declare class
|
|
260
|
-
|
|
261
|
-
readonly
|
|
262
|
-
readonly
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
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);
|
|
347
|
+
/** Coordinates one absolute deadline across validation, synthesis, retries, and merging. */
|
|
348
|
+
declare class DeadlineController {
|
|
349
|
+
#private;
|
|
350
|
+
readonly deadlineAtMs: number | undefined;
|
|
351
|
+
readonly signal: AbortSignal;
|
|
352
|
+
constructor(totalJobMs: number | undefined, parent?: AbortSignal);
|
|
353
|
+
get timedOut(): boolean;
|
|
354
|
+
get remainingMs(): number;
|
|
355
|
+
throwIfExpired(): void;
|
|
356
|
+
abort(): void;
|
|
357
|
+
dispose(): void;
|
|
298
358
|
}
|
|
299
|
-
type AzureTtsSynthesisError = AzureTtsError | MergeError | AudioFormatMismatchError | UnsupportedMergeFormatError | SynthesisCancelledError | SynthesisTimeoutError;
|
|
300
359
|
|
|
301
360
|
interface SsmlValidationError {
|
|
302
361
|
readonly kind: "validation-error";
|
|
@@ -361,6 +420,8 @@ interface SynthesizeSsmlSafeOptions extends AzureValidationOptions {
|
|
|
361
420
|
interface SynthesizeSsmlChunksSafeOptions extends AzureValidationOptions {
|
|
362
421
|
validation?: AzureValidationOptions;
|
|
363
422
|
outputFormat?: string;
|
|
423
|
+
customHeaders?: Readonly<Record<string, string>>;
|
|
424
|
+
fingerprintSchemaVersion?: string;
|
|
364
425
|
signal?: AbortSignal;
|
|
365
426
|
timeoutMs?: number;
|
|
366
427
|
timeouts?: SynthesisTimeouts;
|
|
@@ -374,6 +435,7 @@ interface SynthesizeSsmlChunksSafeOptions extends AzureValidationOptions {
|
|
|
374
435
|
customMerger?: CustomAudioMerger;
|
|
375
436
|
outputMimeType?: string;
|
|
376
437
|
postMergeValidator?: PostMergeValidator;
|
|
438
|
+
resumeValidation?: ResumeValidationMode;
|
|
377
439
|
}
|
|
378
440
|
type SsmlSynthesisChunksSafeResult = Result<SsmlSynthesisResult, never> | Result<never, ChunkValidationError> | Result<never, BatchChunkValidationError> | Result<never, SsmlSynthesisError | ChunkValidationError>;
|
|
379
441
|
interface SynthesisClient {
|
|
@@ -403,9 +465,26 @@ interface MergeAudioOptions {
|
|
|
403
465
|
outputMimeType?: string;
|
|
404
466
|
}
|
|
405
467
|
type InputAudioSpecs = AudioSpecification[];
|
|
468
|
+
/**
|
|
469
|
+
* Creates a deterministic, runtime-independent fingerprint for a synthesis chunk.
|
|
470
|
+
* The complete SSML is included so changes to voice, language, prosody, or text
|
|
471
|
+
* invalidate a cached result even when those settings are nested in the markup.
|
|
472
|
+
*/
|
|
473
|
+
interface ChunkFingerprintOptions {
|
|
474
|
+
outputFormat?: string;
|
|
475
|
+
region?: string;
|
|
476
|
+
endpoint?: string;
|
|
477
|
+
voice?: string;
|
|
478
|
+
lang?: string;
|
|
479
|
+
schemaVersion?: string;
|
|
480
|
+
fingerprintSchemaVersion?: string;
|
|
481
|
+
customHeaders?: Readonly<Record<string, string>>;
|
|
482
|
+
}
|
|
483
|
+
declare function computeChunkFingerprint(ssml: string, outputFormat?: string, options?: Omit<ChunkFingerprintOptions, "outputFormat">): string;
|
|
406
484
|
interface MergeSynthesisOptions extends MergeAudioOptions {
|
|
407
485
|
customMerger?: CustomAudioMerger;
|
|
408
486
|
postMergeValidator?: PostMergeValidator;
|
|
487
|
+
deadline?: DeadlineController;
|
|
409
488
|
}
|
|
410
489
|
type AsyncMergeSynthesisOptions = MergeSynthesisOptions & {
|
|
411
490
|
customMerger: NonNullable<MergeSynthesisOptions["customMerger"]>;
|
|
@@ -417,6 +496,7 @@ declare function resolveMergeAudioFormat(format: string): MergeAudioFormat | und
|
|
|
417
496
|
declare function canMergeAudioFormat(format: string): boolean;
|
|
418
497
|
/** Merges audio buffers while preserving the invariants of supported containers. */
|
|
419
498
|
declare function mergeAudioBuffers(buffers: readonly ArrayBuffer[], options: MergeAudioOptions): ArrayBuffer;
|
|
499
|
+
/** Synthesizes one SSML document, optionally retrying transient failures within the job deadline. */
|
|
420
500
|
declare function synthesizeSsml(ssml: string, config: TtsConfig): Promise<SsmlSynthesisResult>;
|
|
421
501
|
/** Synthesizes chunks with bounded concurrency, retries transient failures, and merges in chunk order. */
|
|
422
502
|
declare function synthesizeSsmlChunks(chunks: readonly (SsmlSynthesisChunk | string)[], config: TtsConfig): Promise<SsmlSynthesisResult>;
|
|
@@ -456,4 +536,4 @@ interface AzureVoiceCatalog {
|
|
|
456
536
|
/** Fetches and deduplicates the current Azure Speech voice catalog for one or more regions. */
|
|
457
537
|
declare function fetchAzureVoiceCatalog(options: FetchAzureVoiceCatalogOptions): Promise<AzureVoiceCatalog>;
|
|
458
538
|
|
|
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 };
|
|
539
|
+
export { AudioFormatMismatchError, type AudioSpecification, type AzureApiErrorResult, type SsmlValidationError as AzureSsmlValidationError, AzureTtsClient, type AzureTtsClientOptions, AzureTtsError, type AzureTtsLogger, type AzureTtsOutputFormat, AzureTtsSdkError, type AzureTtsSynthesisError, type AzureVoiceCatalog, type AzureVoiceCatalogVoice, BatchChunkValidationError, type ChunkDiagnostics, type ChunkExecutionState, type ChunkExecutionStatus, type ChunkFingerprintOptions, ChunkValidationError, type CustomAudioMerger, type CustomMergerContext, DEFAULT_OUTPUT_FORMAT, DeadlineController, type FetchAzureVoiceCatalogOptions, type FetchedAzureVoiceCatalogMetadata, IncompleteChunkSetError, type InputAudioSpecs, type MappingStatus, type MergeAudioFormat, type MergeAudioOptions, MergeError, type MergeSynthesisOptions, type MergedSynthesisResult, type PartialChunkSynthesisResult, type PartialSynthesisResult, type PostMergeValidator, type Result, type ResumeValidationMode, type RetryOptions, type SerializedChunkError, type SerializedChunkErrorCode, type SerializedExecutionError, type SsmlSynthesisBookmark, type SsmlSynthesisBoundary, type SsmlSynthesisChunk, type SsmlSynthesisChunksSafeResult, type SsmlSynthesisError, type SsmlSynthesisResult, type SsmlSynthesisSafeResult, type SsmlSynthesisViseme, type Success, SynthesisCancelledError, type SynthesisChunkStatus, type SynthesisErrorKind, type SynthesisProgressEvent, type SynthesisResult, SynthesisTimeoutError, type SynthesisTimeouts, type SynthesizeChunksOptions, type SynthesizeSsmlChunksSafeOptions, type SynthesizeSsmlSafeOptions, type SynthesizedChunk, type TtsConfig, UnsupportedMergeFormatError, type ValidationErrorResult, canMergeAudioFormat, computeChunkFingerprint, fetchAzureVoiceCatalog, getRetryAfterDelayMs, inspectAudioSpecification, mergeAudioBuffers, mergeSynthesisResults, resolveMergeAudioFormat, resolveMimeType, serializeChunkError, synthesizeSpeech, synthesizeSsml, synthesizeSsmlChunks, synthesizeSsmlChunksSafe, synthesizeSsmlSafe };
|