ssml-builder-js 2.15.0 → 2.16.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 +5 -1
- package/dist/{chunk-BDY2Q2JL.mjs → chunk-F2EMU3HM.mjs} +2 -2
- package/dist/{chunk-WXFLUCLR.mjs → chunk-HI74FTKY.mjs} +34 -5
- package/dist/chunk-HI74FTKY.mjs.map +1 -0
- package/dist/{chunk-FXUM45ZY.mjs → chunk-NKLZGITR.mjs} +50 -5
- package/dist/chunk-NKLZGITR.mjs.map +1 -0
- package/dist/core.d.mts +20 -1
- package/dist/core.d.ts +20 -1
- package/dist/core.js +50 -4
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +3 -1
- package/dist/elements.js +32 -4
- package/dist/elements.js.map +1 -1
- package/dist/elements.mjs +2 -2
- package/dist/{index.d-8BvkB9gz.d.mts → index.d-DR5Qz43p.d.mts} +15 -0
- package/dist/{index.d-8BvkB9gz.d.ts → index.d-DR5Qz43p.d.ts} +15 -0
- package/dist/index.d.mts +54 -7
- package/dist/index.d.ts +54 -7
- package/dist/index.js +592 -162
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +513 -156
- 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 +32 -4
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +2 -2
- package/package.json +1 -1
- package/dist/chunk-FXUM45ZY.mjs.map +0 -1
- package/dist/chunk-WXFLUCLR.mjs.map +0 -1
- /package/dist/{chunk-BDY2Q2JL.mjs.map → chunk-F2EMU3HM.mjs.map} +0 -0
package/dist/elements.mjs
CHANGED
|
@@ -33,12 +33,12 @@ import {
|
|
|
33
33
|
registerSsmlCompletionProvider,
|
|
34
34
|
resolveExpressAsStyles,
|
|
35
35
|
updateEditableText
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-F2EMU3HM.mjs";
|
|
37
37
|
import {
|
|
38
38
|
buildSsml,
|
|
39
39
|
parseSsml,
|
|
40
40
|
validateAzureSsml
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-HI74FTKY.mjs";
|
|
42
42
|
import "./chunk-6S5ODO6A.mjs";
|
|
43
43
|
|
|
44
44
|
// packages/ssml-editor-react/src/ssmlInsertions.ts
|
|
@@ -183,6 +183,18 @@ interface SsmlDiagnostic {
|
|
|
183
183
|
message: string;
|
|
184
184
|
severity: SsmlDiagnosticSeverity;
|
|
185
185
|
source: SsmlDiagnosticSource;
|
|
186
|
+
/** Structured location and source metadata; message parsing is not required. */
|
|
187
|
+
targetNodePath?: string[];
|
|
188
|
+
/** Alias retained for callers using the shorter terminology. */
|
|
189
|
+
nodePath?: string[];
|
|
190
|
+
range?: {
|
|
191
|
+
start: number;
|
|
192
|
+
end: number;
|
|
193
|
+
};
|
|
194
|
+
tagName?: string;
|
|
195
|
+
attributeName?: string;
|
|
196
|
+
voiceName?: string;
|
|
197
|
+
chunkIndex?: number;
|
|
186
198
|
}
|
|
187
199
|
interface AzureVoiceDefinition {
|
|
188
200
|
name: string;
|
|
@@ -205,6 +217,7 @@ interface AzureValidationOptions {
|
|
|
205
217
|
urlValidator?: AzureUrlValidator;
|
|
206
218
|
/** Source path associated with a chunk being validated. */
|
|
207
219
|
sourceNodePath?: readonly string[];
|
|
220
|
+
chunkIndex?: number;
|
|
208
221
|
/** Alias for urlValidator retained for applications that use the longer name. */
|
|
209
222
|
customUrlValidator?: AzureUrlValidator;
|
|
210
223
|
/** Controls deduplication, caching, cancellation, and concurrency for URL checks. */
|
|
@@ -214,6 +227,8 @@ interface AzureValidationOptions {
|
|
|
214
227
|
urlValidatorTimeoutMs?: number;
|
|
215
228
|
urlValidatorSignal?: AbortSignal;
|
|
216
229
|
urlValidatorCache?: Map<string, AzureUrlValidationResult>;
|
|
230
|
+
/** Shared runner used by chunk orchestration to deduplicate in-flight checks. */
|
|
231
|
+
urlValidatorRunner?: AzureUrlValidator;
|
|
217
232
|
languageAliases?: Record<string, string | readonly string[]>;
|
|
218
233
|
maxLength?: number;
|
|
219
234
|
/** Maximum XML element nesting depth, counting `<speak>` as depth 1. */
|
|
@@ -183,6 +183,18 @@ interface SsmlDiagnostic {
|
|
|
183
183
|
message: string;
|
|
184
184
|
severity: SsmlDiagnosticSeverity;
|
|
185
185
|
source: SsmlDiagnosticSource;
|
|
186
|
+
/** Structured location and source metadata; message parsing is not required. */
|
|
187
|
+
targetNodePath?: string[];
|
|
188
|
+
/** Alias retained for callers using the shorter terminology. */
|
|
189
|
+
nodePath?: string[];
|
|
190
|
+
range?: {
|
|
191
|
+
start: number;
|
|
192
|
+
end: number;
|
|
193
|
+
};
|
|
194
|
+
tagName?: string;
|
|
195
|
+
attributeName?: string;
|
|
196
|
+
voiceName?: string;
|
|
197
|
+
chunkIndex?: number;
|
|
186
198
|
}
|
|
187
199
|
interface AzureVoiceDefinition {
|
|
188
200
|
name: string;
|
|
@@ -205,6 +217,7 @@ interface AzureValidationOptions {
|
|
|
205
217
|
urlValidator?: AzureUrlValidator;
|
|
206
218
|
/** Source path associated with a chunk being validated. */
|
|
207
219
|
sourceNodePath?: readonly string[];
|
|
220
|
+
chunkIndex?: number;
|
|
208
221
|
/** Alias for urlValidator retained for applications that use the longer name. */
|
|
209
222
|
customUrlValidator?: AzureUrlValidator;
|
|
210
223
|
/** Controls deduplication, caching, cancellation, and concurrency for URL checks. */
|
|
@@ -214,6 +227,8 @@ interface AzureValidationOptions {
|
|
|
214
227
|
urlValidatorTimeoutMs?: number;
|
|
215
228
|
urlValidatorSignal?: AbortSignal;
|
|
216
229
|
urlValidatorCache?: Map<string, AzureUrlValidationResult>;
|
|
230
|
+
/** Shared runner used by chunk orchestration to deduplicate in-flight checks. */
|
|
231
|
+
urlValidatorRunner?: AzureUrlValidator;
|
|
217
232
|
languageAliases?: Record<string, string | readonly string[]>;
|
|
218
233
|
maxLength?: number;
|
|
219
234
|
/** Maximum XML element nesting depth, counting `<speak>` as depth 1. */
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { AudioElement, AzureDiagnosticCode, AzureLanguageNormalizationOptions, AzureSsmlValidationOptions, AzureUrlValidationResult, AzureUrlValidationRunnerOptions, AzureUrlValidator, AzureValidationOptions, AzureVoiceCatalogMetadata, AzureVoiceDefinition, AzureVoiceMetadata, BookmarkElement, BreakElement, BuildPartialSsmlOptions, CustomElement, 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, validateSsml, validateSsmlStructureIntegrity } from './core.mjs';
|
|
2
|
-
import { S as SsmlTextRange, a as SsmlSourceTextSegment, b as SsmlSourceMarker, c as SsmlDiagnostic, A as AzureValidationOptions } from './index.d-
|
|
1
|
+
export { AudioElement, AzureDiagnosticCode, AzureLanguageNormalizationOptions, AzureSsmlValidationOptions, AzureUrlValidationResult, AzureUrlValidationRunnerOptions, AzureUrlValidator, AzureValidationOptions, AzureVoiceCatalogMetadata, AzureVoiceDefinition, AzureVoiceMetadata, BookmarkElement, BreakElement, BuildPartialSsmlOptions, CustomElement, Diagnostic, EmphasisElement, ExpressAsElement, ExtractSsmlTranslatableTextOptions, FromPlainTextToSsmlOptions, LangElement, LexiconElement, MapSsmlTextNodesOptions, MarkElement, MsttsAudioDurationElement, MsttsEmbeddingElement, MsttsSilenceElement, MsttsTtsEmbeddingElement, MsttsVisemeElement, MsttsVoiceConversionElement, NamedElement, ParagraphElement, PhonemeElement, ProsodyElement, SayAsElement, SentenceElement, SplitSsmlOptions, SsmlAttributeValue, SsmlAttributes, SsmlBackgroundAudioNode, SsmlBreakElement, SsmlChunk, SsmlChunkContext, SsmlDiagnostic, SsmlDiagnosticSeverity, SsmlDiagnosticSource, SsmlDialogNode, SsmlDocument, SsmlElement, SsmlElementBase, SsmlEmbeddingNode, SsmlExpressAsElement, SsmlNode, SsmlPartialContext, SsmlPartialProsody, SsmlPartialVoice, SsmlPhonemeElement, SsmlProsodyElement, SsmlSayAsElement, SsmlSourceMap, SsmlSourceMarker, SsmlSourceTextSegment, SsmlStructureIntegrityResult, SsmlStructureMismatch, SsmlText, SsmlTextNodeContext, SsmlTextRange, SsmlTtsEmbeddingNode, SsmlTurnNode, SsmlValidationError, SsmlVoiceConversionNode, SsmlVoiceElement, SubElement, VoiceElement, WordElement, areAzureLanguagesEquivalent, buildPartialSsml, buildSsml, createAzureUrlValidatorRunner, extractSsmlText, extractSsmlTranslatableText, fromPlainTextToSsml, getAzureVoiceCatalogMetadata, getBuiltInVoiceCatalogMetadata, getSsmlSourceMap, isValidAzureAudioDuration, mapSsmlTextNodes, normalizeAzureLanguage, parseSsml, splitSsmlDocument, validateAzureSsml, validateAzureSsmlChunks, validateSsml, validateSsmlStructureIntegrity } from './core.mjs';
|
|
2
|
+
import { S as SsmlTextRange, a as SsmlSourceTextSegment, b as SsmlSourceMarker, c as SsmlDiagnostic, A as AzureValidationOptions } from './index.d-DR5Qz43p.mjs';
|
|
3
3
|
import * as SpeechSDK from 'microsoft-cognitiveservices-speech-sdk';
|
|
4
4
|
|
|
5
5
|
declare const DEFAULT_OUTPUT_FORMAT = "audio-16khz-128kbitrate-mono-mp3";
|
|
@@ -67,6 +67,23 @@ interface TtsConfig {
|
|
|
67
67
|
/** Exact source text segments used to map individual Azure events. */
|
|
68
68
|
sourceTextSegments?: SsmlSourceTextSegment[];
|
|
69
69
|
sourceMarkers?: SsmlSourceMarker[];
|
|
70
|
+
concurrency?: number;
|
|
71
|
+
retryOptions?: RetryOptions;
|
|
72
|
+
}
|
|
73
|
+
type MappingStatus = "exact" | "fallback" | "unmapped";
|
|
74
|
+
interface AudioSpecification {
|
|
75
|
+
format: string;
|
|
76
|
+
mimeType: string;
|
|
77
|
+
codec: "pcm" | "mp3" | "opus" | "silk" | "unknown";
|
|
78
|
+
sampleRate: number;
|
|
79
|
+
channels: number;
|
|
80
|
+
bitrate?: number;
|
|
81
|
+
isCompressed: boolean;
|
|
82
|
+
}
|
|
83
|
+
interface RetryOptions {
|
|
84
|
+
maxRetries: number;
|
|
85
|
+
initialDelayMs: number;
|
|
86
|
+
maxDelayMs: number;
|
|
70
87
|
}
|
|
71
88
|
type SynthesisChunkStatus = "pending" | "synthesizing" | "success" | "failed";
|
|
72
89
|
interface SsmlSynthesisBoundary {
|
|
@@ -86,6 +103,7 @@ interface SsmlSynthesisBoundary {
|
|
|
86
103
|
/** Audio offset within the originating chunk before merge. */
|
|
87
104
|
chunkAudioOffsetMs?: number;
|
|
88
105
|
requestId?: string;
|
|
106
|
+
mappingStatus: MappingStatus;
|
|
89
107
|
}
|
|
90
108
|
interface SsmlSynthesisViseme {
|
|
91
109
|
visemeId: number;
|
|
@@ -99,6 +117,7 @@ interface SsmlSynthesisViseme {
|
|
|
99
117
|
originalTextRange?: SsmlTextRange;
|
|
100
118
|
chunkAudioOffsetMs?: number;
|
|
101
119
|
requestId?: string;
|
|
120
|
+
mappingStatus: MappingStatus;
|
|
102
121
|
}
|
|
103
122
|
interface SsmlSynthesisBookmark {
|
|
104
123
|
name: string;
|
|
@@ -112,6 +131,7 @@ interface SsmlSynthesisBookmark {
|
|
|
112
131
|
originalTextRange?: SsmlTextRange;
|
|
113
132
|
chunkAudioOffsetMs?: number;
|
|
114
133
|
requestId?: string;
|
|
134
|
+
mappingStatus: MappingStatus;
|
|
115
135
|
}
|
|
116
136
|
/** Audio and Azure Speech synchronization events emitted for one SSML request. */
|
|
117
137
|
interface SsmlSynthesisResult {
|
|
@@ -133,6 +153,7 @@ interface SsmlSynthesisResult {
|
|
|
133
153
|
};
|
|
134
154
|
/** MIME type of a result produced by an explicit merge operation. */
|
|
135
155
|
mimeType?: string;
|
|
156
|
+
audioSpec?: AudioSpecification;
|
|
136
157
|
}
|
|
137
158
|
interface MergedSynthesisResult extends SsmlSynthesisResult {
|
|
138
159
|
mimeType: string;
|
|
@@ -153,6 +174,8 @@ interface SynthesizeChunksOptions {
|
|
|
153
174
|
signal?: AbortSignal;
|
|
154
175
|
timeoutMs?: number;
|
|
155
176
|
sourceNodePath?: string[];
|
|
177
|
+
concurrency?: number;
|
|
178
|
+
retryOptions?: RetryOptions;
|
|
156
179
|
}
|
|
157
180
|
interface SynthesisProgressEvent {
|
|
158
181
|
/** 1-based completed chunk count retained for backward compatibility. */
|
|
@@ -164,6 +187,9 @@ interface SynthesisProgressEvent {
|
|
|
164
187
|
status: SynthesisChunkStatus;
|
|
165
188
|
durationMs: number;
|
|
166
189
|
error?: unknown;
|
|
190
|
+
retryAttempt?: number;
|
|
191
|
+
nextRetryDelayMs?: number;
|
|
192
|
+
isRetrying?: boolean;
|
|
167
193
|
}
|
|
168
194
|
interface AzureTtsLogger {
|
|
169
195
|
debug?: (...args: unknown[]) => void;
|
|
@@ -180,9 +206,11 @@ interface AzureTtsClientOptions {
|
|
|
180
206
|
outputFormat?: string;
|
|
181
207
|
logger?: AzureTtsLogger;
|
|
182
208
|
onProgress?: (event: SynthesisProgressEvent) => void;
|
|
209
|
+
concurrency?: number;
|
|
210
|
+
retryOptions?: RetryOptions;
|
|
183
211
|
}
|
|
184
212
|
|
|
185
|
-
type SynthesisErrorKind = "validation-error" | "azure-api-error" | "merge-error" | "unsupported-format-error" | "cancelled" | "timeout";
|
|
213
|
+
type SynthesisErrorKind = "validation-error" | "azure-api-error" | "merge-error" | "audio-format-mismatch" | "unsupported-format-error" | "cancelled" | "timeout";
|
|
186
214
|
declare class AzureTtsError extends Error {
|
|
187
215
|
readonly kind: "azure-api-error";
|
|
188
216
|
readonly status: number;
|
|
@@ -208,13 +236,19 @@ declare class MergeError extends Error {
|
|
|
208
236
|
readonly cause: unknown;
|
|
209
237
|
constructor(message: string, cause?: unknown);
|
|
210
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
|
+
}
|
|
211
245
|
/** Thrown when audio buffers require container re-multiplexing before they can be merged. */
|
|
212
246
|
declare class UnsupportedMergeFormatError extends Error {
|
|
213
247
|
readonly kind: "unsupported-format-error";
|
|
214
248
|
readonly format: string;
|
|
215
249
|
constructor(format: string);
|
|
216
250
|
}
|
|
217
|
-
type AzureTtsSynthesisError = AzureTtsError | MergeError | UnsupportedMergeFormatError | SynthesisCancelledError | SynthesisTimeoutError;
|
|
251
|
+
type AzureTtsSynthesisError = AzureTtsError | MergeError | AudioFormatMismatchError | UnsupportedMergeFormatError | SynthesisCancelledError | SynthesisTimeoutError;
|
|
218
252
|
|
|
219
253
|
interface SsmlValidationError {
|
|
220
254
|
readonly kind: "validation-error";
|
|
@@ -269,6 +303,8 @@ interface SynthesizeSsmlChunksSafeOptions extends AzureValidationOptions {
|
|
|
269
303
|
timeoutMs?: number;
|
|
270
304
|
sourceNodePath?: string[];
|
|
271
305
|
onProgress?: (event: SynthesisProgressEvent) => void;
|
|
306
|
+
concurrency?: number;
|
|
307
|
+
retryOptions?: RetryOptions;
|
|
272
308
|
}
|
|
273
309
|
type SsmlSynthesisChunksSafeResult = Result<SsmlSynthesisResult, never> | Result<never, ChunkValidationError> | Result<never, SsmlSynthesisError | ChunkValidationError>;
|
|
274
310
|
interface SynthesisClient {
|
|
@@ -294,20 +330,31 @@ declare class AzureTtsClient {
|
|
|
294
330
|
type MergeAudioFormat = "wav" | "mp3" | "raw";
|
|
295
331
|
interface MergeAudioOptions {
|
|
296
332
|
format: AzureTtsOutputFormat;
|
|
333
|
+
signal?: AbortSignal;
|
|
334
|
+
outputMimeType?: string;
|
|
335
|
+
}
|
|
336
|
+
type InputAudioSpecs = AudioSpecification[];
|
|
337
|
+
interface CustomMergerContext {
|
|
338
|
+
format: string;
|
|
339
|
+
outputMimeType: string;
|
|
340
|
+
inputSpecs: InputAudioSpecs;
|
|
341
|
+
signal: AbortSignal;
|
|
297
342
|
}
|
|
298
343
|
interface MergeSynthesisOptions extends MergeAudioOptions {
|
|
299
|
-
customMerger?: (buffers: ArrayBuffer[],
|
|
344
|
+
customMerger?: (buffers: ArrayBuffer[], context: CustomMergerContext) => Promise<ArrayBuffer> | ArrayBuffer;
|
|
300
345
|
}
|
|
301
346
|
type AsyncMergeSynthesisOptions = MergeSynthesisOptions & {
|
|
302
347
|
customMerger: NonNullable<MergeSynthesisOptions["customMerger"]>;
|
|
303
348
|
};
|
|
349
|
+
/** Extracts the stream specification from a WAV/MP3 header and output-format fallback. */
|
|
350
|
+
declare function inspectAudioSpecification(buffer: ArrayBuffer, format: string): AudioSpecification;
|
|
304
351
|
/** Returns whether the named output format can be safely concatenated without re-multiplexing. */
|
|
305
352
|
declare function resolveMergeAudioFormat(format: string): MergeAudioFormat | undefined;
|
|
306
353
|
declare function canMergeAudioFormat(format: string): boolean;
|
|
307
354
|
/** Merges audio buffers while preserving the invariants of supported containers. */
|
|
308
355
|
declare function mergeAudioBuffers(buffers: readonly ArrayBuffer[], options: MergeAudioOptions): ArrayBuffer;
|
|
309
356
|
declare function synthesizeSsml(ssml: string, config: TtsConfig): Promise<SsmlSynthesisResult>;
|
|
310
|
-
/** Synthesizes chunks
|
|
357
|
+
/** Synthesizes chunks with bounded concurrency, retries transient failures, and merges in chunk order. */
|
|
311
358
|
declare function synthesizeSsmlChunks(chunks: readonly (SsmlSynthesisChunk | string)[], config: TtsConfig): Promise<SsmlSynthesisResult>;
|
|
312
359
|
declare function mergeSynthesisResults(results: readonly SsmlSynthesisResult[], options: AsyncMergeSynthesisOptions): Promise<MergedSynthesisResult>;
|
|
313
360
|
declare function mergeSynthesisResults(results: readonly SsmlSynthesisResult[], options: MergeAudioOptions): MergedSynthesisResult;
|
|
@@ -342,4 +389,4 @@ interface AzureVoiceCatalog {
|
|
|
342
389
|
/** Fetches and deduplicates the current Azure Speech voice catalog for one or more regions. */
|
|
343
390
|
declare function fetchAzureVoiceCatalog(options: FetchAzureVoiceCatalogOptions): Promise<AzureVoiceCatalog>;
|
|
344
391
|
|
|
345
|
-
export { type AzureApiErrorResult, type SsmlValidationError as AzureSsmlValidationError, AzureTtsClient, type AzureTtsClientOptions, AzureTtsError, type AzureTtsLogger, type AzureTtsOutputFormat, AzureTtsSdkError, type AzureTtsSynthesisError, type AzureVoiceCatalog, type AzureVoiceCatalogVoice, ChunkValidationError, DEFAULT_OUTPUT_FORMAT, type FetchAzureVoiceCatalogOptions, type FetchedAzureVoiceCatalogMetadata, type MergeAudioFormat, type MergeAudioOptions, MergeError, type MergeSynthesisOptions, type MergedSynthesisResult, type Result, 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, mergeAudioBuffers, mergeSynthesisResults, resolveMergeAudioFormat, resolveMimeType, synthesizeSpeech, synthesizeSsml, synthesizeSsmlChunks, synthesizeSsmlChunksSafe, synthesizeSsmlSafe };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { AudioElement, AzureDiagnosticCode, AzureLanguageNormalizationOptions, AzureSsmlValidationOptions, AzureUrlValidationResult, AzureUrlValidationRunnerOptions, AzureUrlValidator, AzureValidationOptions, AzureVoiceCatalogMetadata, AzureVoiceDefinition, AzureVoiceMetadata, BookmarkElement, BreakElement, BuildPartialSsmlOptions, CustomElement, 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, validateSsml, validateSsmlStructureIntegrity } from './core.js';
|
|
2
|
-
import { S as SsmlTextRange, a as SsmlSourceTextSegment, b as SsmlSourceMarker, c as SsmlDiagnostic, A as AzureValidationOptions } from './index.d-
|
|
1
|
+
export { AudioElement, AzureDiagnosticCode, AzureLanguageNormalizationOptions, AzureSsmlValidationOptions, AzureUrlValidationResult, AzureUrlValidationRunnerOptions, AzureUrlValidator, AzureValidationOptions, AzureVoiceCatalogMetadata, AzureVoiceDefinition, AzureVoiceMetadata, BookmarkElement, BreakElement, BuildPartialSsmlOptions, CustomElement, Diagnostic, EmphasisElement, ExpressAsElement, ExtractSsmlTranslatableTextOptions, FromPlainTextToSsmlOptions, LangElement, LexiconElement, MapSsmlTextNodesOptions, MarkElement, MsttsAudioDurationElement, MsttsEmbeddingElement, MsttsSilenceElement, MsttsTtsEmbeddingElement, MsttsVisemeElement, MsttsVoiceConversionElement, NamedElement, ParagraphElement, PhonemeElement, ProsodyElement, SayAsElement, SentenceElement, SplitSsmlOptions, SsmlAttributeValue, SsmlAttributes, SsmlBackgroundAudioNode, SsmlBreakElement, SsmlChunk, SsmlChunkContext, SsmlDiagnostic, SsmlDiagnosticSeverity, SsmlDiagnosticSource, SsmlDialogNode, SsmlDocument, SsmlElement, SsmlElementBase, SsmlEmbeddingNode, SsmlExpressAsElement, SsmlNode, SsmlPartialContext, SsmlPartialProsody, SsmlPartialVoice, SsmlPhonemeElement, SsmlProsodyElement, SsmlSayAsElement, SsmlSourceMap, SsmlSourceMarker, SsmlSourceTextSegment, SsmlStructureIntegrityResult, SsmlStructureMismatch, SsmlText, SsmlTextNodeContext, SsmlTextRange, SsmlTtsEmbeddingNode, SsmlTurnNode, SsmlValidationError, SsmlVoiceConversionNode, SsmlVoiceElement, SubElement, VoiceElement, WordElement, areAzureLanguagesEquivalent, buildPartialSsml, buildSsml, createAzureUrlValidatorRunner, extractSsmlText, extractSsmlTranslatableText, fromPlainTextToSsml, getAzureVoiceCatalogMetadata, getBuiltInVoiceCatalogMetadata, getSsmlSourceMap, isValidAzureAudioDuration, mapSsmlTextNodes, normalizeAzureLanguage, parseSsml, splitSsmlDocument, validateAzureSsml, validateAzureSsmlChunks, validateSsml, validateSsmlStructureIntegrity } from './core.js';
|
|
2
|
+
import { S as SsmlTextRange, a as SsmlSourceTextSegment, b as SsmlSourceMarker, c as SsmlDiagnostic, A as AzureValidationOptions } from './index.d-DR5Qz43p.js';
|
|
3
3
|
import * as SpeechSDK from 'microsoft-cognitiveservices-speech-sdk';
|
|
4
4
|
|
|
5
5
|
declare const DEFAULT_OUTPUT_FORMAT = "audio-16khz-128kbitrate-mono-mp3";
|
|
@@ -67,6 +67,23 @@ interface TtsConfig {
|
|
|
67
67
|
/** Exact source text segments used to map individual Azure events. */
|
|
68
68
|
sourceTextSegments?: SsmlSourceTextSegment[];
|
|
69
69
|
sourceMarkers?: SsmlSourceMarker[];
|
|
70
|
+
concurrency?: number;
|
|
71
|
+
retryOptions?: RetryOptions;
|
|
72
|
+
}
|
|
73
|
+
type MappingStatus = "exact" | "fallback" | "unmapped";
|
|
74
|
+
interface AudioSpecification {
|
|
75
|
+
format: string;
|
|
76
|
+
mimeType: string;
|
|
77
|
+
codec: "pcm" | "mp3" | "opus" | "silk" | "unknown";
|
|
78
|
+
sampleRate: number;
|
|
79
|
+
channels: number;
|
|
80
|
+
bitrate?: number;
|
|
81
|
+
isCompressed: boolean;
|
|
82
|
+
}
|
|
83
|
+
interface RetryOptions {
|
|
84
|
+
maxRetries: number;
|
|
85
|
+
initialDelayMs: number;
|
|
86
|
+
maxDelayMs: number;
|
|
70
87
|
}
|
|
71
88
|
type SynthesisChunkStatus = "pending" | "synthesizing" | "success" | "failed";
|
|
72
89
|
interface SsmlSynthesisBoundary {
|
|
@@ -86,6 +103,7 @@ interface SsmlSynthesisBoundary {
|
|
|
86
103
|
/** Audio offset within the originating chunk before merge. */
|
|
87
104
|
chunkAudioOffsetMs?: number;
|
|
88
105
|
requestId?: string;
|
|
106
|
+
mappingStatus: MappingStatus;
|
|
89
107
|
}
|
|
90
108
|
interface SsmlSynthesisViseme {
|
|
91
109
|
visemeId: number;
|
|
@@ -99,6 +117,7 @@ interface SsmlSynthesisViseme {
|
|
|
99
117
|
originalTextRange?: SsmlTextRange;
|
|
100
118
|
chunkAudioOffsetMs?: number;
|
|
101
119
|
requestId?: string;
|
|
120
|
+
mappingStatus: MappingStatus;
|
|
102
121
|
}
|
|
103
122
|
interface SsmlSynthesisBookmark {
|
|
104
123
|
name: string;
|
|
@@ -112,6 +131,7 @@ interface SsmlSynthesisBookmark {
|
|
|
112
131
|
originalTextRange?: SsmlTextRange;
|
|
113
132
|
chunkAudioOffsetMs?: number;
|
|
114
133
|
requestId?: string;
|
|
134
|
+
mappingStatus: MappingStatus;
|
|
115
135
|
}
|
|
116
136
|
/** Audio and Azure Speech synchronization events emitted for one SSML request. */
|
|
117
137
|
interface SsmlSynthesisResult {
|
|
@@ -133,6 +153,7 @@ interface SsmlSynthesisResult {
|
|
|
133
153
|
};
|
|
134
154
|
/** MIME type of a result produced by an explicit merge operation. */
|
|
135
155
|
mimeType?: string;
|
|
156
|
+
audioSpec?: AudioSpecification;
|
|
136
157
|
}
|
|
137
158
|
interface MergedSynthesisResult extends SsmlSynthesisResult {
|
|
138
159
|
mimeType: string;
|
|
@@ -153,6 +174,8 @@ interface SynthesizeChunksOptions {
|
|
|
153
174
|
signal?: AbortSignal;
|
|
154
175
|
timeoutMs?: number;
|
|
155
176
|
sourceNodePath?: string[];
|
|
177
|
+
concurrency?: number;
|
|
178
|
+
retryOptions?: RetryOptions;
|
|
156
179
|
}
|
|
157
180
|
interface SynthesisProgressEvent {
|
|
158
181
|
/** 1-based completed chunk count retained for backward compatibility. */
|
|
@@ -164,6 +187,9 @@ interface SynthesisProgressEvent {
|
|
|
164
187
|
status: SynthesisChunkStatus;
|
|
165
188
|
durationMs: number;
|
|
166
189
|
error?: unknown;
|
|
190
|
+
retryAttempt?: number;
|
|
191
|
+
nextRetryDelayMs?: number;
|
|
192
|
+
isRetrying?: boolean;
|
|
167
193
|
}
|
|
168
194
|
interface AzureTtsLogger {
|
|
169
195
|
debug?: (...args: unknown[]) => void;
|
|
@@ -180,9 +206,11 @@ interface AzureTtsClientOptions {
|
|
|
180
206
|
outputFormat?: string;
|
|
181
207
|
logger?: AzureTtsLogger;
|
|
182
208
|
onProgress?: (event: SynthesisProgressEvent) => void;
|
|
209
|
+
concurrency?: number;
|
|
210
|
+
retryOptions?: RetryOptions;
|
|
183
211
|
}
|
|
184
212
|
|
|
185
|
-
type SynthesisErrorKind = "validation-error" | "azure-api-error" | "merge-error" | "unsupported-format-error" | "cancelled" | "timeout";
|
|
213
|
+
type SynthesisErrorKind = "validation-error" | "azure-api-error" | "merge-error" | "audio-format-mismatch" | "unsupported-format-error" | "cancelled" | "timeout";
|
|
186
214
|
declare class AzureTtsError extends Error {
|
|
187
215
|
readonly kind: "azure-api-error";
|
|
188
216
|
readonly status: number;
|
|
@@ -208,13 +236,19 @@ declare class MergeError extends Error {
|
|
|
208
236
|
readonly cause: unknown;
|
|
209
237
|
constructor(message: string, cause?: unknown);
|
|
210
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
|
+
}
|
|
211
245
|
/** Thrown when audio buffers require container re-multiplexing before they can be merged. */
|
|
212
246
|
declare class UnsupportedMergeFormatError extends Error {
|
|
213
247
|
readonly kind: "unsupported-format-error";
|
|
214
248
|
readonly format: string;
|
|
215
249
|
constructor(format: string);
|
|
216
250
|
}
|
|
217
|
-
type AzureTtsSynthesisError = AzureTtsError | MergeError | UnsupportedMergeFormatError | SynthesisCancelledError | SynthesisTimeoutError;
|
|
251
|
+
type AzureTtsSynthesisError = AzureTtsError | MergeError | AudioFormatMismatchError | UnsupportedMergeFormatError | SynthesisCancelledError | SynthesisTimeoutError;
|
|
218
252
|
|
|
219
253
|
interface SsmlValidationError {
|
|
220
254
|
readonly kind: "validation-error";
|
|
@@ -269,6 +303,8 @@ interface SynthesizeSsmlChunksSafeOptions extends AzureValidationOptions {
|
|
|
269
303
|
timeoutMs?: number;
|
|
270
304
|
sourceNodePath?: string[];
|
|
271
305
|
onProgress?: (event: SynthesisProgressEvent) => void;
|
|
306
|
+
concurrency?: number;
|
|
307
|
+
retryOptions?: RetryOptions;
|
|
272
308
|
}
|
|
273
309
|
type SsmlSynthesisChunksSafeResult = Result<SsmlSynthesisResult, never> | Result<never, ChunkValidationError> | Result<never, SsmlSynthesisError | ChunkValidationError>;
|
|
274
310
|
interface SynthesisClient {
|
|
@@ -294,20 +330,31 @@ declare class AzureTtsClient {
|
|
|
294
330
|
type MergeAudioFormat = "wav" | "mp3" | "raw";
|
|
295
331
|
interface MergeAudioOptions {
|
|
296
332
|
format: AzureTtsOutputFormat;
|
|
333
|
+
signal?: AbortSignal;
|
|
334
|
+
outputMimeType?: string;
|
|
335
|
+
}
|
|
336
|
+
type InputAudioSpecs = AudioSpecification[];
|
|
337
|
+
interface CustomMergerContext {
|
|
338
|
+
format: string;
|
|
339
|
+
outputMimeType: string;
|
|
340
|
+
inputSpecs: InputAudioSpecs;
|
|
341
|
+
signal: AbortSignal;
|
|
297
342
|
}
|
|
298
343
|
interface MergeSynthesisOptions extends MergeAudioOptions {
|
|
299
|
-
customMerger?: (buffers: ArrayBuffer[],
|
|
344
|
+
customMerger?: (buffers: ArrayBuffer[], context: CustomMergerContext) => Promise<ArrayBuffer> | ArrayBuffer;
|
|
300
345
|
}
|
|
301
346
|
type AsyncMergeSynthesisOptions = MergeSynthesisOptions & {
|
|
302
347
|
customMerger: NonNullable<MergeSynthesisOptions["customMerger"]>;
|
|
303
348
|
};
|
|
349
|
+
/** Extracts the stream specification from a WAV/MP3 header and output-format fallback. */
|
|
350
|
+
declare function inspectAudioSpecification(buffer: ArrayBuffer, format: string): AudioSpecification;
|
|
304
351
|
/** Returns whether the named output format can be safely concatenated without re-multiplexing. */
|
|
305
352
|
declare function resolveMergeAudioFormat(format: string): MergeAudioFormat | undefined;
|
|
306
353
|
declare function canMergeAudioFormat(format: string): boolean;
|
|
307
354
|
/** Merges audio buffers while preserving the invariants of supported containers. */
|
|
308
355
|
declare function mergeAudioBuffers(buffers: readonly ArrayBuffer[], options: MergeAudioOptions): ArrayBuffer;
|
|
309
356
|
declare function synthesizeSsml(ssml: string, config: TtsConfig): Promise<SsmlSynthesisResult>;
|
|
310
|
-
/** Synthesizes chunks
|
|
357
|
+
/** Synthesizes chunks with bounded concurrency, retries transient failures, and merges in chunk order. */
|
|
311
358
|
declare function synthesizeSsmlChunks(chunks: readonly (SsmlSynthesisChunk | string)[], config: TtsConfig): Promise<SsmlSynthesisResult>;
|
|
312
359
|
declare function mergeSynthesisResults(results: readonly SsmlSynthesisResult[], options: AsyncMergeSynthesisOptions): Promise<MergedSynthesisResult>;
|
|
313
360
|
declare function mergeSynthesisResults(results: readonly SsmlSynthesisResult[], options: MergeAudioOptions): MergedSynthesisResult;
|
|
@@ -342,4 +389,4 @@ interface AzureVoiceCatalog {
|
|
|
342
389
|
/** Fetches and deduplicates the current Azure Speech voice catalog for one or more regions. */
|
|
343
390
|
declare function fetchAzureVoiceCatalog(options: FetchAzureVoiceCatalogOptions): Promise<AzureVoiceCatalog>;
|
|
344
391
|
|
|
345
|
-
export { type AzureApiErrorResult, type SsmlValidationError as AzureSsmlValidationError, AzureTtsClient, type AzureTtsClientOptions, AzureTtsError, type AzureTtsLogger, type AzureTtsOutputFormat, AzureTtsSdkError, type AzureTtsSynthesisError, type AzureVoiceCatalog, type AzureVoiceCatalogVoice, ChunkValidationError, DEFAULT_OUTPUT_FORMAT, type FetchAzureVoiceCatalogOptions, type FetchedAzureVoiceCatalogMetadata, type MergeAudioFormat, type MergeAudioOptions, MergeError, type MergeSynthesisOptions, type MergedSynthesisResult, type Result, 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, mergeAudioBuffers, mergeSynthesisResults, resolveMergeAudioFormat, resolveMimeType, synthesizeSpeech, synthesizeSsml, synthesizeSsmlChunks, synthesizeSsmlChunksSafe, synthesizeSsmlSafe };
|
|
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 };
|