ssml-builder-js 2.13.0 → 2.14.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/dist/elements.mjs CHANGED
@@ -33,12 +33,12 @@ import {
33
33
  registerSsmlCompletionProvider,
34
34
  resolveExpressAsStyles,
35
35
  updateEditableText
36
- } from "./chunk-LCTE26LS.mjs";
36
+ } from "./chunk-UZSCXPC5.mjs";
37
37
  import {
38
38
  buildSsml,
39
39
  parseSsml,
40
40
  validateAzureSsml
41
- } from "./chunk-CZ2F3TET.mjs";
41
+ } from "./chunk-QFIBPCO4.mjs";
42
42
  import "./chunk-6S5ODO6A.mjs";
43
43
 
44
44
  // packages/ssml-editor-react/src/ssmlInsertions.ts
@@ -151,6 +151,11 @@ interface SsmlDocument {
151
151
  attributes?: SsmlAttributes;
152
152
  }
153
153
 
154
+ interface SsmlTextRange {
155
+ start: number;
156
+ end: number;
157
+ }
158
+
154
159
  type SsmlDiagnosticSeverity = "error" | "warning" | "info";
155
160
  type SsmlDiagnosticSource = "ssml-static-validator";
156
161
  type AzureDiagnosticCode = "azure-unknown-voice" | "azure-unsupported-style" | "azure-locale-mismatch" | "azure-unsupported-tag-for-voice" | "azure-unsupported-model-for-voice" | "azure-preview-voice" | "azure-deprecated-voice" | "azure-preview-tag" | "azure-deprecated-tag";
@@ -183,6 +188,13 @@ interface AzureValidationOptions {
183
188
  urlValidator?: AzureUrlValidator;
184
189
  /** Alias for urlValidator retained for applications that use the longer name. */
185
190
  customUrlValidator?: AzureUrlValidator;
191
+ /** Controls deduplication, caching, cancellation, and concurrency for URL checks. */
192
+ urlValidation?: AzureUrlValidationRunnerOptions;
193
+ /** Flat aliases retained for callers that prefer not to nest URL runner options. */
194
+ urlValidatorConcurrency?: number;
195
+ urlValidatorTimeoutMs?: number;
196
+ urlValidatorSignal?: AbortSignal;
197
+ urlValidatorCache?: Map<string, AzureUrlValidationResult>;
186
198
  languageAliases?: Record<string, string | readonly string[]>;
187
199
  maxLength?: number;
188
200
  /** Maximum XML element nesting depth, counting `<speak>` as depth 1. */
@@ -210,5 +222,11 @@ type AzureUrlValidator = (url: string, context: {
210
222
  tag: string;
211
223
  attribute: string;
212
224
  }) => AzureUrlValidationResult | Promise<AzureUrlValidationResult>;
225
+ interface AzureUrlValidationRunnerOptions {
226
+ concurrency?: number;
227
+ cache?: Map<string, AzureUrlValidationResult>;
228
+ signal?: AbortSignal;
229
+ timeoutMs?: number;
230
+ }
213
231
 
214
- export type { AzureValidationOptions as A, SsmlDiagnostic as S, SsmlDocument as a, SsmlElement as b };
232
+ export type { AzureValidationOptions as A, SsmlTextRange as S, SsmlDiagnostic as a, SsmlDocument as b, SsmlElement as c };
@@ -151,6 +151,11 @@ interface SsmlDocument {
151
151
  attributes?: SsmlAttributes;
152
152
  }
153
153
 
154
+ interface SsmlTextRange {
155
+ start: number;
156
+ end: number;
157
+ }
158
+
154
159
  type SsmlDiagnosticSeverity = "error" | "warning" | "info";
155
160
  type SsmlDiagnosticSource = "ssml-static-validator";
156
161
  type AzureDiagnosticCode = "azure-unknown-voice" | "azure-unsupported-style" | "azure-locale-mismatch" | "azure-unsupported-tag-for-voice" | "azure-unsupported-model-for-voice" | "azure-preview-voice" | "azure-deprecated-voice" | "azure-preview-tag" | "azure-deprecated-tag";
@@ -183,6 +188,13 @@ interface AzureValidationOptions {
183
188
  urlValidator?: AzureUrlValidator;
184
189
  /** Alias for urlValidator retained for applications that use the longer name. */
185
190
  customUrlValidator?: AzureUrlValidator;
191
+ /** Controls deduplication, caching, cancellation, and concurrency for URL checks. */
192
+ urlValidation?: AzureUrlValidationRunnerOptions;
193
+ /** Flat aliases retained for callers that prefer not to nest URL runner options. */
194
+ urlValidatorConcurrency?: number;
195
+ urlValidatorTimeoutMs?: number;
196
+ urlValidatorSignal?: AbortSignal;
197
+ urlValidatorCache?: Map<string, AzureUrlValidationResult>;
186
198
  languageAliases?: Record<string, string | readonly string[]>;
187
199
  maxLength?: number;
188
200
  /** Maximum XML element nesting depth, counting `<speak>` as depth 1. */
@@ -210,5 +222,11 @@ type AzureUrlValidator = (url: string, context: {
210
222
  tag: string;
211
223
  attribute: string;
212
224
  }) => AzureUrlValidationResult | Promise<AzureUrlValidationResult>;
225
+ interface AzureUrlValidationRunnerOptions {
226
+ concurrency?: number;
227
+ cache?: Map<string, AzureUrlValidationResult>;
228
+ signal?: AbortSignal;
229
+ timeoutMs?: number;
230
+ }
213
231
 
214
- export type { AzureValidationOptions as A, SsmlDiagnostic as S, SsmlDocument as a, SsmlElement as b };
232
+ export type { AzureValidationOptions as A, SsmlTextRange as S, SsmlDiagnostic as a, SsmlDocument as b, SsmlElement as c };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- export { AudioElement, AzureDiagnosticCode, AzureLanguageNormalizationOptions, AzureSsmlValidationOptions, AzureUrlValidationResult, 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, SsmlStructureIntegrityResult, SsmlStructureMismatch, SsmlText, SsmlTextNodeContext, SsmlTextRange, SsmlTtsEmbeddingNode, SsmlTurnNode, SsmlValidationError, SsmlVoiceConversionNode, SsmlVoiceElement, SubElement, VoiceElement, WordElement, areAzureLanguagesEquivalent, buildPartialSsml, buildSsml, extractSsmlText, extractSsmlTranslatableText, fromPlainTextToSsml, getAzureVoiceCatalogMetadata, getBuiltInVoiceCatalogMetadata, isValidAzureAudioDuration, mapSsmlTextNodes, normalizeAzureLanguage, parseSsml, splitSsmlDocument, validateAzureSsml, validateSsml, validateSsmlStructureIntegrity } from './core.mjs';
2
- import { S as SsmlDiagnostic, A as AzureValidationOptions } from './index.d-Xbr6ZWnK.mjs';
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, SsmlStructureIntegrityResult, SsmlStructureMismatch, SsmlText, SsmlTextNodeContext, SsmlTextRange, SsmlTtsEmbeddingNode, SsmlTurnNode, SsmlValidationError, SsmlVoiceConversionNode, SsmlVoiceElement, SubElement, VoiceElement, WordElement, areAzureLanguagesEquivalent, buildPartialSsml, buildSsml, createAzureUrlValidatorRunner, extractSsmlText, extractSsmlTranslatableText, fromPlainTextToSsml, getAzureVoiceCatalogMetadata, getBuiltInVoiceCatalogMetadata, isValidAzureAudioDuration, mapSsmlTextNodes, normalizeAzureLanguage, parseSsml, splitSsmlDocument, validateAzureSsml, validateSsml, validateSsmlStructureIntegrity } from './core.mjs';
2
+ import { S as SsmlTextRange, a as SsmlDiagnostic, A as AzureValidationOptions } from './index.d-CUXRwSw0.mjs';
3
3
 
4
4
  interface TtsConfig {
5
5
  signal?: AbortSignal;
@@ -13,13 +13,13 @@ interface TtsConfig {
13
13
  start: number;
14
14
  end: number;
15
15
  };
16
- /** Reports completion of a chunk when using synthesizeSsmlChunks. */
17
- onProgress?: (event: {
18
- currentChunk: number;
19
- totalChunks: number;
20
- percent: number;
21
- }) => void;
16
+ /** Reports chunk lifecycle events when using chunk synthesis. */
17
+ onProgress?: (event: SynthesisProgressEvent) => void;
18
+ /** Metadata used to map synchronization events back to the source document. */
19
+ chunkIndex?: number;
20
+ sourceNodePath?: string[];
22
21
  }
22
+ type SynthesisChunkStatus = "pending" | "synthesizing" | "success" | "failed";
23
23
  interface SsmlSynthesisBoundary {
24
24
  text: string;
25
25
  audioOffsetMs: number;
@@ -28,6 +28,14 @@ interface SsmlSynthesisBoundary {
28
28
  start: number;
29
29
  end: number;
30
30
  };
31
+ /** Chunk that produced this event. */
32
+ chunkIndex?: number;
33
+ /** Path of the source SSML node, when available. */
34
+ sourceNodePath?: string[];
35
+ /** Original text range represented by this event. */
36
+ originalTextRange?: SsmlTextRange;
37
+ /** Audio offset within the originating chunk before merge. */
38
+ chunkAudioOffsetMs?: number;
31
39
  requestId?: string;
32
40
  }
33
41
  interface SsmlSynthesisViseme {
@@ -37,6 +45,10 @@ interface SsmlSynthesisViseme {
37
45
  start: number;
38
46
  end: number;
39
47
  };
48
+ chunkIndex?: number;
49
+ sourceNodePath?: string[];
50
+ originalTextRange?: SsmlTextRange;
51
+ chunkAudioOffsetMs?: number;
40
52
  requestId?: string;
41
53
  }
42
54
  interface SsmlSynthesisBookmark {
@@ -46,6 +58,10 @@ interface SsmlSynthesisBookmark {
46
58
  start: number;
47
59
  end: number;
48
60
  };
61
+ chunkIndex?: number;
62
+ sourceNodePath?: string[];
63
+ originalTextRange?: SsmlTextRange;
64
+ chunkAudioOffsetMs?: number;
49
65
  requestId?: string;
50
66
  }
51
67
  /** Audio and Azure Speech synchronization events emitted for one SSML request. */
@@ -73,14 +89,21 @@ interface SsmlSynthesisChunk {
73
89
  start: number;
74
90
  end: number;
75
91
  };
92
+ sourceNodePath?: string[];
76
93
  }
77
94
  interface SynthesizeChunksOptions {
78
95
  onProgress?: (event: SynthesisProgressEvent) => void;
79
96
  }
80
97
  interface SynthesisProgressEvent {
98
+ /** 1-based completed chunk count retained for backward compatibility. */
81
99
  currentChunk: number;
82
100
  totalChunks: number;
83
101
  percent: number;
102
+ chunkIndex: number;
103
+ originalTextRange?: SsmlTextRange;
104
+ status: SynthesisChunkStatus;
105
+ durationMs: number;
106
+ error?: unknown;
84
107
  }
85
108
  interface AzureTtsLogger {
86
109
  debug?: (...args: unknown[]) => void;
@@ -110,12 +133,23 @@ declare class AzureTtsSdkError extends AzureTtsError {
110
133
  readonly errorDetails: string;
111
134
  constructor(errorDetails: string);
112
135
  }
136
+ /** Thrown when audio buffers require container re-multiplexing before they can be merged. */
137
+ declare class UnsupportedMergeFormatError extends Error {
138
+ readonly format: string;
139
+ constructor(format: string);
140
+ }
113
141
 
114
142
  interface SsmlValidationError {
115
143
  readonly kind: "validation";
116
144
  readonly message: string;
117
145
  readonly diagnostics: readonly SsmlDiagnostic[];
118
146
  }
147
+ declare class ChunkValidationError extends Error {
148
+ readonly kind: "chunk-validation";
149
+ readonly chunkIndex: number;
150
+ readonly diagnostics: readonly SsmlDiagnostic[];
151
+ constructor(chunkIndex: number, diagnostics: readonly SsmlDiagnostic[]);
152
+ }
119
153
  type Result<T, E> = {
120
154
  readonly ok: true;
121
155
  readonly success: true;
@@ -142,11 +176,22 @@ interface SynthesizeSsmlSafeOptions extends AzureValidationOptions {
142
176
  /** Optional nested form for callers that want to keep validation settings grouped. */
143
177
  validation?: AzureValidationOptions;
144
178
  }
179
+ interface SynthesizeSsmlChunksSafeOptions extends AzureValidationOptions {
180
+ validation?: AzureValidationOptions;
181
+ outputFormat?: string;
182
+ onProgress?: (event: SynthesisProgressEvent) => void;
183
+ }
184
+ type SsmlSynthesisChunksSafeResult = Result<SsmlSynthesisResult, never> | Result<never, ChunkValidationError> | Result<never, AzureTtsError>;
145
185
  interface SynthesisClient {
146
186
  synthesizeSsml(ssml: string): Promise<SsmlSynthesisResult>;
187
+ synthesizeChunks?(chunks: readonly (SsmlSynthesisChunk | string)[], options?: {
188
+ onProgress?: (event: SynthesisProgressEvent) => void;
189
+ }): Promise<SsmlSynthesisResult>;
147
190
  }
148
191
  /** Validates SSML before invoking Azure and converts validation/API failures to one result shape. */
149
192
  declare function synthesizeSsmlSafe(client: Pick<AzureTtsClient, "synthesizeSsml"> | SynthesisClient, ssml: string, options?: SynthesizeSsmlSafeOptions): Promise<SsmlSynthesisSafeResult>;
193
+ /** Validates every chunk before synthesis and returns a chunk-addressable result. */
194
+ declare function synthesizeSsmlChunksSafe(client: Pick<AzureTtsClient, "synthesizeSsml" | "synthesizeChunks"> | SynthesisClient, chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeSsmlChunksSafeOptions): Promise<SsmlSynthesisChunksSafeResult>;
150
195
 
151
196
  declare class AzureTtsClient {
152
197
  #private;
@@ -155,13 +200,21 @@ declare class AzureTtsClient {
155
200
  synthesizeSsml(ssml: string): Promise<SsmlSynthesisResult>;
156
201
  synthesizeChunks(chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeChunksOptions): Promise<SsmlSynthesisResult>;
157
202
  synthesizeSsmlSafe(ssml: string, options?: SynthesizeSsmlSafeOptions): Promise<SsmlSynthesisSafeResult>;
203
+ synthesizeChunksSafe(chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeSsmlChunksSafeOptions): Promise<SsmlSynthesisChunksSafeResult>;
204
+ synthesizeSsmlChunksSafe(chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeSsmlChunksSafeOptions): Promise<SsmlSynthesisChunksSafeResult>;
158
205
  }
159
206
 
207
+ type MergeAudioFormat = "wav" | "mp3" | "raw";
208
+ /** Returns whether the named output format can be safely concatenated without re-multiplexing. */
209
+ declare function resolveMergeAudioFormat(format: string): MergeAudioFormat | undefined;
210
+ declare function canMergeAudioFormat(format: string): boolean;
211
+ /** Merges audio buffers while preserving the invariants of supported containers. */
212
+ declare function mergeAudioBuffers(buffers: readonly ArrayBuffer[], format: string): ArrayBuffer;
160
213
  declare function synthesizeSsml(ssml: string, config: TtsConfig): Promise<SsmlSynthesisResult>;
161
214
  /** Synthesizes chunks sequentially, annotates synchronization events, and merges the results. */
162
215
  declare function synthesizeSsmlChunks(chunks: readonly (SsmlSynthesisChunk | string)[], config: TtsConfig): Promise<SsmlSynthesisResult>;
163
216
  /** Concatenates audio buffers and shifts all synchronization events by prior chunk durations. */
164
- declare function mergeSynthesisResults(results: readonly SsmlSynthesisResult[]): SsmlSynthesisResult;
217
+ declare function mergeSynthesisResults(results: readonly SsmlSynthesisResult[], format?: string): SsmlSynthesisResult;
165
218
  /** Backward-compatible audio-only synthesis helper. */
166
219
  declare function synthesizeSpeech(ssml: string, config: TtsConfig): Promise<ArrayBuffer>;
167
220
 
@@ -174,6 +227,9 @@ interface AzureVoiceCatalogVoice {
174
227
  locale: string;
175
228
  secondaryLocales?: readonly string[];
176
229
  styles?: readonly string[];
230
+ supportedTags?: readonly string[];
231
+ unsupportedTags?: readonly string[];
232
+ models?: readonly string[];
177
233
  regions: readonly string[];
178
234
  status?: "ga" | "preview" | "deprecated";
179
235
  }
@@ -190,4 +246,4 @@ interface AzureVoiceCatalog {
190
246
  /** Fetches and deduplicates the current Azure Speech voice catalog for one or more regions. */
191
247
  declare function fetchAzureVoiceCatalog(options: FetchAzureVoiceCatalogOptions): Promise<AzureVoiceCatalog>;
192
248
 
193
- export { type AzureApiErrorResult, type SsmlValidationError as AzureSsmlValidationError, AzureTtsClient, type AzureTtsClientOptions, AzureTtsError, type AzureTtsLogger, AzureTtsSdkError, type AzureVoiceCatalog, type AzureVoiceCatalogVoice, type FetchAzureVoiceCatalogOptions, type FetchedAzureVoiceCatalogMetadata, type Result, type SsmlSynthesisBookmark, type SsmlSynthesisBoundary, type SsmlSynthesisChunk, type SsmlSynthesisResult, type SsmlSynthesisSafeResult, type SsmlSynthesisViseme, type Success, type SynthesisProgressEvent, type SynthesisResult, type SynthesizeChunksOptions, type SynthesizeSsmlSafeOptions, type TtsConfig, type ValidationErrorResult, fetchAzureVoiceCatalog, mergeSynthesisResults, synthesizeSpeech, synthesizeSsml, synthesizeSsmlChunks, synthesizeSsmlSafe };
249
+ export { type AzureApiErrorResult, type SsmlValidationError as AzureSsmlValidationError, AzureTtsClient, type AzureTtsClientOptions, AzureTtsError, type AzureTtsLogger, AzureTtsSdkError, type AzureVoiceCatalog, type AzureVoiceCatalogVoice, ChunkValidationError, type FetchAzureVoiceCatalogOptions, type FetchedAzureVoiceCatalogMetadata, type MergeAudioFormat, type Result, type SsmlSynthesisBookmark, type SsmlSynthesisBoundary, type SsmlSynthesisChunk, type SsmlSynthesisChunksSafeResult, type SsmlSynthesisResult, type SsmlSynthesisSafeResult, type SsmlSynthesisViseme, type Success, type SynthesisChunkStatus, type SynthesisProgressEvent, type SynthesisResult, type SynthesizeChunksOptions, type SynthesizeSsmlChunksSafeOptions, type SynthesizeSsmlSafeOptions, type TtsConfig, UnsupportedMergeFormatError, type ValidationErrorResult, canMergeAudioFormat, fetchAzureVoiceCatalog, mergeAudioBuffers, mergeSynthesisResults, resolveMergeAudioFormat, synthesizeSpeech, synthesizeSsml, synthesizeSsmlChunks, synthesizeSsmlChunksSafe, synthesizeSsmlSafe };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { AudioElement, AzureDiagnosticCode, AzureLanguageNormalizationOptions, AzureSsmlValidationOptions, AzureUrlValidationResult, 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, SsmlStructureIntegrityResult, SsmlStructureMismatch, SsmlText, SsmlTextNodeContext, SsmlTextRange, SsmlTtsEmbeddingNode, SsmlTurnNode, SsmlValidationError, SsmlVoiceConversionNode, SsmlVoiceElement, SubElement, VoiceElement, WordElement, areAzureLanguagesEquivalent, buildPartialSsml, buildSsml, extractSsmlText, extractSsmlTranslatableText, fromPlainTextToSsml, getAzureVoiceCatalogMetadata, getBuiltInVoiceCatalogMetadata, isValidAzureAudioDuration, mapSsmlTextNodes, normalizeAzureLanguage, parseSsml, splitSsmlDocument, validateAzureSsml, validateSsml, validateSsmlStructureIntegrity } from './core.js';
2
- import { S as SsmlDiagnostic, A as AzureValidationOptions } from './index.d-Xbr6ZWnK.js';
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, SsmlStructureIntegrityResult, SsmlStructureMismatch, SsmlText, SsmlTextNodeContext, SsmlTextRange, SsmlTtsEmbeddingNode, SsmlTurnNode, SsmlValidationError, SsmlVoiceConversionNode, SsmlVoiceElement, SubElement, VoiceElement, WordElement, areAzureLanguagesEquivalent, buildPartialSsml, buildSsml, createAzureUrlValidatorRunner, extractSsmlText, extractSsmlTranslatableText, fromPlainTextToSsml, getAzureVoiceCatalogMetadata, getBuiltInVoiceCatalogMetadata, isValidAzureAudioDuration, mapSsmlTextNodes, normalizeAzureLanguage, parseSsml, splitSsmlDocument, validateAzureSsml, validateSsml, validateSsmlStructureIntegrity } from './core.js';
2
+ import { S as SsmlTextRange, a as SsmlDiagnostic, A as AzureValidationOptions } from './index.d-CUXRwSw0.js';
3
3
 
4
4
  interface TtsConfig {
5
5
  signal?: AbortSignal;
@@ -13,13 +13,13 @@ interface TtsConfig {
13
13
  start: number;
14
14
  end: number;
15
15
  };
16
- /** Reports completion of a chunk when using synthesizeSsmlChunks. */
17
- onProgress?: (event: {
18
- currentChunk: number;
19
- totalChunks: number;
20
- percent: number;
21
- }) => void;
16
+ /** Reports chunk lifecycle events when using chunk synthesis. */
17
+ onProgress?: (event: SynthesisProgressEvent) => void;
18
+ /** Metadata used to map synchronization events back to the source document. */
19
+ chunkIndex?: number;
20
+ sourceNodePath?: string[];
22
21
  }
22
+ type SynthesisChunkStatus = "pending" | "synthesizing" | "success" | "failed";
23
23
  interface SsmlSynthesisBoundary {
24
24
  text: string;
25
25
  audioOffsetMs: number;
@@ -28,6 +28,14 @@ interface SsmlSynthesisBoundary {
28
28
  start: number;
29
29
  end: number;
30
30
  };
31
+ /** Chunk that produced this event. */
32
+ chunkIndex?: number;
33
+ /** Path of the source SSML node, when available. */
34
+ sourceNodePath?: string[];
35
+ /** Original text range represented by this event. */
36
+ originalTextRange?: SsmlTextRange;
37
+ /** Audio offset within the originating chunk before merge. */
38
+ chunkAudioOffsetMs?: number;
31
39
  requestId?: string;
32
40
  }
33
41
  interface SsmlSynthesisViseme {
@@ -37,6 +45,10 @@ interface SsmlSynthesisViseme {
37
45
  start: number;
38
46
  end: number;
39
47
  };
48
+ chunkIndex?: number;
49
+ sourceNodePath?: string[];
50
+ originalTextRange?: SsmlTextRange;
51
+ chunkAudioOffsetMs?: number;
40
52
  requestId?: string;
41
53
  }
42
54
  interface SsmlSynthesisBookmark {
@@ -46,6 +58,10 @@ interface SsmlSynthesisBookmark {
46
58
  start: number;
47
59
  end: number;
48
60
  };
61
+ chunkIndex?: number;
62
+ sourceNodePath?: string[];
63
+ originalTextRange?: SsmlTextRange;
64
+ chunkAudioOffsetMs?: number;
49
65
  requestId?: string;
50
66
  }
51
67
  /** Audio and Azure Speech synchronization events emitted for one SSML request. */
@@ -73,14 +89,21 @@ interface SsmlSynthesisChunk {
73
89
  start: number;
74
90
  end: number;
75
91
  };
92
+ sourceNodePath?: string[];
76
93
  }
77
94
  interface SynthesizeChunksOptions {
78
95
  onProgress?: (event: SynthesisProgressEvent) => void;
79
96
  }
80
97
  interface SynthesisProgressEvent {
98
+ /** 1-based completed chunk count retained for backward compatibility. */
81
99
  currentChunk: number;
82
100
  totalChunks: number;
83
101
  percent: number;
102
+ chunkIndex: number;
103
+ originalTextRange?: SsmlTextRange;
104
+ status: SynthesisChunkStatus;
105
+ durationMs: number;
106
+ error?: unknown;
84
107
  }
85
108
  interface AzureTtsLogger {
86
109
  debug?: (...args: unknown[]) => void;
@@ -110,12 +133,23 @@ declare class AzureTtsSdkError extends AzureTtsError {
110
133
  readonly errorDetails: string;
111
134
  constructor(errorDetails: string);
112
135
  }
136
+ /** Thrown when audio buffers require container re-multiplexing before they can be merged. */
137
+ declare class UnsupportedMergeFormatError extends Error {
138
+ readonly format: string;
139
+ constructor(format: string);
140
+ }
113
141
 
114
142
  interface SsmlValidationError {
115
143
  readonly kind: "validation";
116
144
  readonly message: string;
117
145
  readonly diagnostics: readonly SsmlDiagnostic[];
118
146
  }
147
+ declare class ChunkValidationError extends Error {
148
+ readonly kind: "chunk-validation";
149
+ readonly chunkIndex: number;
150
+ readonly diagnostics: readonly SsmlDiagnostic[];
151
+ constructor(chunkIndex: number, diagnostics: readonly SsmlDiagnostic[]);
152
+ }
119
153
  type Result<T, E> = {
120
154
  readonly ok: true;
121
155
  readonly success: true;
@@ -142,11 +176,22 @@ interface SynthesizeSsmlSafeOptions extends AzureValidationOptions {
142
176
  /** Optional nested form for callers that want to keep validation settings grouped. */
143
177
  validation?: AzureValidationOptions;
144
178
  }
179
+ interface SynthesizeSsmlChunksSafeOptions extends AzureValidationOptions {
180
+ validation?: AzureValidationOptions;
181
+ outputFormat?: string;
182
+ onProgress?: (event: SynthesisProgressEvent) => void;
183
+ }
184
+ type SsmlSynthesisChunksSafeResult = Result<SsmlSynthesisResult, never> | Result<never, ChunkValidationError> | Result<never, AzureTtsError>;
145
185
  interface SynthesisClient {
146
186
  synthesizeSsml(ssml: string): Promise<SsmlSynthesisResult>;
187
+ synthesizeChunks?(chunks: readonly (SsmlSynthesisChunk | string)[], options?: {
188
+ onProgress?: (event: SynthesisProgressEvent) => void;
189
+ }): Promise<SsmlSynthesisResult>;
147
190
  }
148
191
  /** Validates SSML before invoking Azure and converts validation/API failures to one result shape. */
149
192
  declare function synthesizeSsmlSafe(client: Pick<AzureTtsClient, "synthesizeSsml"> | SynthesisClient, ssml: string, options?: SynthesizeSsmlSafeOptions): Promise<SsmlSynthesisSafeResult>;
193
+ /** Validates every chunk before synthesis and returns a chunk-addressable result. */
194
+ declare function synthesizeSsmlChunksSafe(client: Pick<AzureTtsClient, "synthesizeSsml" | "synthesizeChunks"> | SynthesisClient, chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeSsmlChunksSafeOptions): Promise<SsmlSynthesisChunksSafeResult>;
150
195
 
151
196
  declare class AzureTtsClient {
152
197
  #private;
@@ -155,13 +200,21 @@ declare class AzureTtsClient {
155
200
  synthesizeSsml(ssml: string): Promise<SsmlSynthesisResult>;
156
201
  synthesizeChunks(chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeChunksOptions): Promise<SsmlSynthesisResult>;
157
202
  synthesizeSsmlSafe(ssml: string, options?: SynthesizeSsmlSafeOptions): Promise<SsmlSynthesisSafeResult>;
203
+ synthesizeChunksSafe(chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeSsmlChunksSafeOptions): Promise<SsmlSynthesisChunksSafeResult>;
204
+ synthesizeSsmlChunksSafe(chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeSsmlChunksSafeOptions): Promise<SsmlSynthesisChunksSafeResult>;
158
205
  }
159
206
 
207
+ type MergeAudioFormat = "wav" | "mp3" | "raw";
208
+ /** Returns whether the named output format can be safely concatenated without re-multiplexing. */
209
+ declare function resolveMergeAudioFormat(format: string): MergeAudioFormat | undefined;
210
+ declare function canMergeAudioFormat(format: string): boolean;
211
+ /** Merges audio buffers while preserving the invariants of supported containers. */
212
+ declare function mergeAudioBuffers(buffers: readonly ArrayBuffer[], format: string): ArrayBuffer;
160
213
  declare function synthesizeSsml(ssml: string, config: TtsConfig): Promise<SsmlSynthesisResult>;
161
214
  /** Synthesizes chunks sequentially, annotates synchronization events, and merges the results. */
162
215
  declare function synthesizeSsmlChunks(chunks: readonly (SsmlSynthesisChunk | string)[], config: TtsConfig): Promise<SsmlSynthesisResult>;
163
216
  /** Concatenates audio buffers and shifts all synchronization events by prior chunk durations. */
164
- declare function mergeSynthesisResults(results: readonly SsmlSynthesisResult[]): SsmlSynthesisResult;
217
+ declare function mergeSynthesisResults(results: readonly SsmlSynthesisResult[], format?: string): SsmlSynthesisResult;
165
218
  /** Backward-compatible audio-only synthesis helper. */
166
219
  declare function synthesizeSpeech(ssml: string, config: TtsConfig): Promise<ArrayBuffer>;
167
220
 
@@ -174,6 +227,9 @@ interface AzureVoiceCatalogVoice {
174
227
  locale: string;
175
228
  secondaryLocales?: readonly string[];
176
229
  styles?: readonly string[];
230
+ supportedTags?: readonly string[];
231
+ unsupportedTags?: readonly string[];
232
+ models?: readonly string[];
177
233
  regions: readonly string[];
178
234
  status?: "ga" | "preview" | "deprecated";
179
235
  }
@@ -190,4 +246,4 @@ interface AzureVoiceCatalog {
190
246
  /** Fetches and deduplicates the current Azure Speech voice catalog for one or more regions. */
191
247
  declare function fetchAzureVoiceCatalog(options: FetchAzureVoiceCatalogOptions): Promise<AzureVoiceCatalog>;
192
248
 
193
- export { type AzureApiErrorResult, type SsmlValidationError as AzureSsmlValidationError, AzureTtsClient, type AzureTtsClientOptions, AzureTtsError, type AzureTtsLogger, AzureTtsSdkError, type AzureVoiceCatalog, type AzureVoiceCatalogVoice, type FetchAzureVoiceCatalogOptions, type FetchedAzureVoiceCatalogMetadata, type Result, type SsmlSynthesisBookmark, type SsmlSynthesisBoundary, type SsmlSynthesisChunk, type SsmlSynthesisResult, type SsmlSynthesisSafeResult, type SsmlSynthesisViseme, type Success, type SynthesisProgressEvent, type SynthesisResult, type SynthesizeChunksOptions, type SynthesizeSsmlSafeOptions, type TtsConfig, type ValidationErrorResult, fetchAzureVoiceCatalog, mergeSynthesisResults, synthesizeSpeech, synthesizeSsml, synthesizeSsmlChunks, synthesizeSsmlSafe };
249
+ export { type AzureApiErrorResult, type SsmlValidationError as AzureSsmlValidationError, AzureTtsClient, type AzureTtsClientOptions, AzureTtsError, type AzureTtsLogger, AzureTtsSdkError, type AzureVoiceCatalog, type AzureVoiceCatalogVoice, ChunkValidationError, type FetchAzureVoiceCatalogOptions, type FetchedAzureVoiceCatalogMetadata, type MergeAudioFormat, type Result, type SsmlSynthesisBookmark, type SsmlSynthesisBoundary, type SsmlSynthesisChunk, type SsmlSynthesisChunksSafeResult, type SsmlSynthesisResult, type SsmlSynthesisSafeResult, type SsmlSynthesisViseme, type Success, type SynthesisChunkStatus, type SynthesisProgressEvent, type SynthesisResult, type SynthesizeChunksOptions, type SynthesizeSsmlChunksSafeOptions, type SynthesizeSsmlSafeOptions, type TtsConfig, UnsupportedMergeFormatError, type ValidationErrorResult, canMergeAudioFormat, fetchAzureVoiceCatalog, mergeAudioBuffers, mergeSynthesisResults, resolveMergeAudioFormat, synthesizeSpeech, synthesizeSsml, synthesizeSsmlChunks, synthesizeSsmlChunksSafe, synthesizeSsmlSafe };