ssml-builder-js 2.8.0 → 2.9.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/core.d.mts CHANGED
@@ -99,11 +99,44 @@ interface MsttsVisemeElement extends SsmlElementBase {
99
99
  typeValue?: string;
100
100
  visemeType?: string;
101
101
  }
102
+ interface MsttsAudioDurationElement extends SsmlElementBase {
103
+ type: "mstts:audioduration";
104
+ value?: SsmlAttributeValue;
105
+ }
106
+ interface SsmlDialogNode extends SsmlElementBase {
107
+ type: "mstts:dialog";
108
+ }
109
+ interface SsmlTurnNode extends SsmlElementBase {
110
+ type: "mstts:turn";
111
+ voice?: string;
112
+ }
113
+ interface SsmlBackgroundAudioNode extends SsmlElementBase {
114
+ type: "mstts:backgroundaudio";
115
+ src?: string;
116
+ volume?: SsmlAttributeValue;
117
+ fadeIn?: SsmlAttributeValue;
118
+ fadeOut?: SsmlAttributeValue;
119
+ /** XML spelling aliases retained for ergonomic object construction. */
120
+ fadein?: SsmlAttributeValue;
121
+ fadeout?: SsmlAttributeValue;
122
+ }
123
+ interface MsttsTtsEmbeddingElement extends SsmlElementBase {
124
+ type: "mstts:ttsembedding";
125
+ }
126
+ interface MsttsEmbeddingElement extends SsmlElementBase {
127
+ type: "mstts:embedding";
128
+ }
129
+ interface MsttsVoiceConversionElement extends SsmlElementBase {
130
+ type: "mstts:voiceconversion";
131
+ }
132
+ type SsmlTtsEmbeddingNode = MsttsTtsEmbeddingElement;
133
+ type SsmlEmbeddingNode = MsttsEmbeddingElement;
134
+ type SsmlVoiceConversionNode = MsttsVoiceConversionElement;
102
135
  interface CustomElement extends SsmlElementBase {
103
136
  type: "custom" | "element";
104
137
  name: string;
105
138
  }
106
- type SsmlElement = VoiceElement | ProsodyElement | BreakElement | ExpressAsElement | SayAsElement | PhonemeElement | EmphasisElement | AudioElement | SubElement | LangElement | MarkElement | BookmarkElement | LexiconElement | ParagraphElement | SentenceElement | WordElement | MsttsSilenceElement | MsttsVisemeElement | CustomElement;
139
+ type SsmlElement = VoiceElement | ProsodyElement | BreakElement | ExpressAsElement | SayAsElement | PhonemeElement | EmphasisElement | AudioElement | SubElement | LangElement | MarkElement | BookmarkElement | LexiconElement | ParagraphElement | SentenceElement | WordElement | MsttsSilenceElement | MsttsVisemeElement | MsttsAudioDurationElement | SsmlDialogNode | SsmlTurnNode | SsmlBackgroundAudioNode | MsttsTtsEmbeddingElement | MsttsEmbeddingElement | MsttsVoiceConversionElement | CustomElement;
107
140
  interface SsmlDocument {
108
141
  type?: "speak";
109
142
  version: string;
@@ -171,9 +204,51 @@ interface MapSsmlTextNodesOptions {
171
204
  declare function extractSsmlText(ssml: string): string[];
172
205
  declare function mapSsmlTextNodes(ssml: string, transform: (text: string, context: SsmlTextNodeContext) => string | Promise<string>, options?: MapSsmlTextNodesOptions): Promise<string>;
173
206
 
207
+ interface ExtractSsmlTranslatableTextOptions {
208
+ /** Element names whose descendants are not translation targets. */
209
+ skipTags?: readonly string[];
210
+ /** Include indentation and whitespace-only text nodes. Defaults to false. */
211
+ includeWhitespace?: boolean;
212
+ /** Further restrict text nodes after the skip-tag check. */
213
+ filter?: (context: SsmlTextNodeContext) => boolean;
214
+ }
215
+ interface FromPlainTextToSsmlOptions {
216
+ version?: string;
217
+ lang?: string;
218
+ /** Alias for lang, useful when options come from an application form. */
219
+ language?: string;
220
+ /** Wrap generated paragraphs in a voice element. */
221
+ voice?: string;
222
+ /** Alias for voice. */
223
+ voiceName?: string;
224
+ /** Generate sentence elements inside paragraphs. Defaults to true. */
225
+ includeSentences?: boolean;
226
+ /** Alias for includeSentences. */
227
+ splitSentences?: boolean;
228
+ }
229
+ interface SsmlStructureMismatch {
230
+ kind: "element" | "attribute" | "parse";
231
+ path: string;
232
+ original?: string;
233
+ translated?: string;
234
+ message: string;
235
+ }
236
+ interface SsmlStructureIntegrityResult {
237
+ isValid: boolean;
238
+ /** Alias for isValid for callers that prefer a shorter result property. */
239
+ valid: boolean;
240
+ errors: string[];
241
+ mismatches: SsmlStructureMismatch[];
242
+ /** Element or attribute names involved in each mismatch. */
243
+ mismatchedTags: string[];
244
+ }
245
+ declare function extractSsmlTranslatableText(ssml: string, options?: ExtractSsmlTranslatableTextOptions): string[];
246
+ declare function fromPlainTextToSsml(text: string, options?: FromPlainTextToSsmlOptions): string;
247
+ declare function validateSsmlStructureIntegrity(originalSsml: string, translatedSsml: string): SsmlStructureIntegrityResult;
248
+
174
249
  type SsmlDiagnosticSeverity = "error" | "warning";
175
250
  type SsmlDiagnosticSource = "ssml-static-validator";
176
- type AzureDiagnosticCode = "azure-unknown-voice" | "azure-unsupported-style" | "azure-locale-mismatch";
251
+ type AzureDiagnosticCode = "azure-unknown-voice" | "azure-unsupported-style" | "azure-locale-mismatch" | "azure-unsupported-tag-for-voice" | "azure-unsupported-model-for-voice";
177
252
  interface SsmlDiagnostic {
178
253
  code?: AzureDiagnosticCode;
179
254
  line: number;
@@ -187,6 +262,9 @@ interface AzureVoiceDefinition {
187
262
  locale: string;
188
263
  secondaryLocales?: readonly string[];
189
264
  styles?: readonly string[];
265
+ supportedTags?: readonly string[];
266
+ unsupportedTags?: readonly string[];
267
+ models?: readonly string[];
190
268
  }
191
269
  /** Alias retained for consumers that prefer the metadata terminology. */
192
270
  interface AzureVoiceMetadata extends AzureVoiceDefinition {
@@ -199,6 +277,8 @@ interface AzureValidationOptions {
199
277
  customVoiceDefinitions?: readonly AzureVoiceDefinition[];
200
278
  languageAliases?: Record<string, string | readonly string[]>;
201
279
  maxLength?: number;
280
+ /** Optional model identifier used to validate a voice's model compatibility. */
281
+ model?: string;
202
282
  normalizeLanguage?: (lang: string) => string;
203
283
  unknownVoicePolicy?: "error" | "warn" | "ignore";
204
284
  unsupportedStylePolicy?: "error" | "warn" | "ignore";
@@ -209,10 +289,24 @@ interface AzureValidationOptions {
209
289
  type AzureLanguageNormalizationOptions = Pick<AzureValidationOptions, "languageAliases" | "normalizeLanguage">;
210
290
  /** @deprecated Use AzureValidationOptions instead. */
211
291
  type AzureSsmlValidationOptions = AzureValidationOptions;
292
+ /** Returns whether a value is a positive Azure SSML audio duration. */
293
+ declare function isValidAzureAudioDuration(value: string): boolean;
212
294
  /** Normalizes an Azure language tag using BCP 47 and the configured aliases. */
213
295
  declare function normalizeAzureLanguage(language: string, options?: AzureLanguageNormalizationOptions): string;
214
296
  /** Compares two Azure language tags after BCP 47 and alias normalization. */
215
297
  declare function areAzureLanguagesEquivalent(first: string, second: string, options?: AzureLanguageNormalizationOptions): boolean;
216
298
  declare function validateAzureSsml(ssml: string, options?: AzureValidationOptions): SsmlDiagnostic[];
217
299
 
218
- export { type AudioElement, type AzureDiagnosticCode, type AzureLanguageNormalizationOptions, type AzureSsmlValidationOptions, type AzureValidationOptions, type AzureVoiceDefinition, type AzureVoiceMetadata, type BookmarkElement, type BreakElement, type BuildPartialSsmlOptions, type CustomElement, type EmphasisElement, type ExpressAsElement, type LangElement, type LexiconElement, type MapSsmlTextNodesOptions, type MarkElement, type MsttsSilenceElement, type MsttsVisemeElement, type NamedElement, type ParagraphElement, type PhonemeElement, type ProsodyElement, type SayAsElement, type SentenceElement, type SsmlAttributeValue, type SsmlAttributes, type SsmlBreakElement, type SsmlDiagnostic, type SsmlDiagnosticSeverity, type SsmlDiagnosticSource, type SsmlDocument, type SsmlElement, type SsmlElementBase, type SsmlExpressAsElement, type SsmlNode, type SsmlPartialContext, type SsmlPartialProsody, type SsmlPartialVoice, type SsmlPhonemeElement, type SsmlProsodyElement, type SsmlSayAsElement, type SsmlText, type SsmlTextNodeContext, type SsmlValidationError, type SsmlVoiceElement, type SubElement, type VoiceElement, type WordElement, areAzureLanguagesEquivalent, buildPartialSsml, buildSsml, extractSsmlText, mapSsmlTextNodes, normalizeAzureLanguage, parseSsml, validateAzureSsml, validateSsml };
300
+ interface AzureVoiceCatalogMetadata {
301
+ apiVersion: string;
302
+ generatedAt: string;
303
+ regions: readonly string[];
304
+ voiceCount: number;
305
+ }
306
+
307
+ /** Returns metadata for the built-in Azure voice catalog snapshot. */
308
+ declare function getAzureVoiceCatalogMetadata(): AzureVoiceCatalogMetadata;
309
+ /** Alias for consumers that refer to the bundled catalog as the built-in catalog. */
310
+ declare const getBuiltInVoiceCatalogMetadata: typeof getAzureVoiceCatalogMetadata;
311
+
312
+ export { type AudioElement, type AzureDiagnosticCode, type AzureLanguageNormalizationOptions, type AzureSsmlValidationOptions, type AzureValidationOptions, type AzureVoiceCatalogMetadata, type AzureVoiceDefinition, type AzureVoiceMetadata, type BookmarkElement, type BreakElement, type BuildPartialSsmlOptions, type CustomElement, type EmphasisElement, type ExpressAsElement, type ExtractSsmlTranslatableTextOptions, type FromPlainTextToSsmlOptions, type LangElement, type LexiconElement, type MapSsmlTextNodesOptions, type MarkElement, type MsttsAudioDurationElement, type MsttsEmbeddingElement, type MsttsSilenceElement, type MsttsTtsEmbeddingElement, type MsttsVisemeElement, type MsttsVoiceConversionElement, type NamedElement, type ParagraphElement, type PhonemeElement, type ProsodyElement, type SayAsElement, type SentenceElement, type SsmlAttributeValue, type SsmlAttributes, type SsmlBackgroundAudioNode, type SsmlBreakElement, type SsmlDiagnostic, type SsmlDiagnosticSeverity, type SsmlDiagnosticSource, type SsmlDialogNode, type SsmlDocument, type SsmlElement, type SsmlElementBase, type SsmlEmbeddingNode, type SsmlExpressAsElement, type SsmlNode, type SsmlPartialContext, type SsmlPartialProsody, type SsmlPartialVoice, type SsmlPhonemeElement, type SsmlProsodyElement, type SsmlSayAsElement, type SsmlStructureIntegrityResult, type SsmlStructureMismatch, type SsmlText, type SsmlTextNodeContext, type SsmlTtsEmbeddingNode, type SsmlTurnNode, type SsmlValidationError, type SsmlVoiceConversionNode, type SsmlVoiceElement, type SubElement, type VoiceElement, type WordElement, areAzureLanguagesEquivalent, buildPartialSsml, buildSsml, extractSsmlText, extractSsmlTranslatableText, fromPlainTextToSsml, getAzureVoiceCatalogMetadata, getBuiltInVoiceCatalogMetadata, isValidAzureAudioDuration, mapSsmlTextNodes, normalizeAzureLanguage, parseSsml, validateAzureSsml, validateSsml, validateSsmlStructureIntegrity };
package/dist/core.d.ts CHANGED
@@ -99,11 +99,44 @@ interface MsttsVisemeElement extends SsmlElementBase {
99
99
  typeValue?: string;
100
100
  visemeType?: string;
101
101
  }
102
+ interface MsttsAudioDurationElement extends SsmlElementBase {
103
+ type: "mstts:audioduration";
104
+ value?: SsmlAttributeValue;
105
+ }
106
+ interface SsmlDialogNode extends SsmlElementBase {
107
+ type: "mstts:dialog";
108
+ }
109
+ interface SsmlTurnNode extends SsmlElementBase {
110
+ type: "mstts:turn";
111
+ voice?: string;
112
+ }
113
+ interface SsmlBackgroundAudioNode extends SsmlElementBase {
114
+ type: "mstts:backgroundaudio";
115
+ src?: string;
116
+ volume?: SsmlAttributeValue;
117
+ fadeIn?: SsmlAttributeValue;
118
+ fadeOut?: SsmlAttributeValue;
119
+ /** XML spelling aliases retained for ergonomic object construction. */
120
+ fadein?: SsmlAttributeValue;
121
+ fadeout?: SsmlAttributeValue;
122
+ }
123
+ interface MsttsTtsEmbeddingElement extends SsmlElementBase {
124
+ type: "mstts:ttsembedding";
125
+ }
126
+ interface MsttsEmbeddingElement extends SsmlElementBase {
127
+ type: "mstts:embedding";
128
+ }
129
+ interface MsttsVoiceConversionElement extends SsmlElementBase {
130
+ type: "mstts:voiceconversion";
131
+ }
132
+ type SsmlTtsEmbeddingNode = MsttsTtsEmbeddingElement;
133
+ type SsmlEmbeddingNode = MsttsEmbeddingElement;
134
+ type SsmlVoiceConversionNode = MsttsVoiceConversionElement;
102
135
  interface CustomElement extends SsmlElementBase {
103
136
  type: "custom" | "element";
104
137
  name: string;
105
138
  }
106
- type SsmlElement = VoiceElement | ProsodyElement | BreakElement | ExpressAsElement | SayAsElement | PhonemeElement | EmphasisElement | AudioElement | SubElement | LangElement | MarkElement | BookmarkElement | LexiconElement | ParagraphElement | SentenceElement | WordElement | MsttsSilenceElement | MsttsVisemeElement | CustomElement;
139
+ type SsmlElement = VoiceElement | ProsodyElement | BreakElement | ExpressAsElement | SayAsElement | PhonemeElement | EmphasisElement | AudioElement | SubElement | LangElement | MarkElement | BookmarkElement | LexiconElement | ParagraphElement | SentenceElement | WordElement | MsttsSilenceElement | MsttsVisemeElement | MsttsAudioDurationElement | SsmlDialogNode | SsmlTurnNode | SsmlBackgroundAudioNode | MsttsTtsEmbeddingElement | MsttsEmbeddingElement | MsttsVoiceConversionElement | CustomElement;
107
140
  interface SsmlDocument {
108
141
  type?: "speak";
109
142
  version: string;
@@ -171,9 +204,51 @@ interface MapSsmlTextNodesOptions {
171
204
  declare function extractSsmlText(ssml: string): string[];
172
205
  declare function mapSsmlTextNodes(ssml: string, transform: (text: string, context: SsmlTextNodeContext) => string | Promise<string>, options?: MapSsmlTextNodesOptions): Promise<string>;
173
206
 
207
+ interface ExtractSsmlTranslatableTextOptions {
208
+ /** Element names whose descendants are not translation targets. */
209
+ skipTags?: readonly string[];
210
+ /** Include indentation and whitespace-only text nodes. Defaults to false. */
211
+ includeWhitespace?: boolean;
212
+ /** Further restrict text nodes after the skip-tag check. */
213
+ filter?: (context: SsmlTextNodeContext) => boolean;
214
+ }
215
+ interface FromPlainTextToSsmlOptions {
216
+ version?: string;
217
+ lang?: string;
218
+ /** Alias for lang, useful when options come from an application form. */
219
+ language?: string;
220
+ /** Wrap generated paragraphs in a voice element. */
221
+ voice?: string;
222
+ /** Alias for voice. */
223
+ voiceName?: string;
224
+ /** Generate sentence elements inside paragraphs. Defaults to true. */
225
+ includeSentences?: boolean;
226
+ /** Alias for includeSentences. */
227
+ splitSentences?: boolean;
228
+ }
229
+ interface SsmlStructureMismatch {
230
+ kind: "element" | "attribute" | "parse";
231
+ path: string;
232
+ original?: string;
233
+ translated?: string;
234
+ message: string;
235
+ }
236
+ interface SsmlStructureIntegrityResult {
237
+ isValid: boolean;
238
+ /** Alias for isValid for callers that prefer a shorter result property. */
239
+ valid: boolean;
240
+ errors: string[];
241
+ mismatches: SsmlStructureMismatch[];
242
+ /** Element or attribute names involved in each mismatch. */
243
+ mismatchedTags: string[];
244
+ }
245
+ declare function extractSsmlTranslatableText(ssml: string, options?: ExtractSsmlTranslatableTextOptions): string[];
246
+ declare function fromPlainTextToSsml(text: string, options?: FromPlainTextToSsmlOptions): string;
247
+ declare function validateSsmlStructureIntegrity(originalSsml: string, translatedSsml: string): SsmlStructureIntegrityResult;
248
+
174
249
  type SsmlDiagnosticSeverity = "error" | "warning";
175
250
  type SsmlDiagnosticSource = "ssml-static-validator";
176
- type AzureDiagnosticCode = "azure-unknown-voice" | "azure-unsupported-style" | "azure-locale-mismatch";
251
+ type AzureDiagnosticCode = "azure-unknown-voice" | "azure-unsupported-style" | "azure-locale-mismatch" | "azure-unsupported-tag-for-voice" | "azure-unsupported-model-for-voice";
177
252
  interface SsmlDiagnostic {
178
253
  code?: AzureDiagnosticCode;
179
254
  line: number;
@@ -187,6 +262,9 @@ interface AzureVoiceDefinition {
187
262
  locale: string;
188
263
  secondaryLocales?: readonly string[];
189
264
  styles?: readonly string[];
265
+ supportedTags?: readonly string[];
266
+ unsupportedTags?: readonly string[];
267
+ models?: readonly string[];
190
268
  }
191
269
  /** Alias retained for consumers that prefer the metadata terminology. */
192
270
  interface AzureVoiceMetadata extends AzureVoiceDefinition {
@@ -199,6 +277,8 @@ interface AzureValidationOptions {
199
277
  customVoiceDefinitions?: readonly AzureVoiceDefinition[];
200
278
  languageAliases?: Record<string, string | readonly string[]>;
201
279
  maxLength?: number;
280
+ /** Optional model identifier used to validate a voice's model compatibility. */
281
+ model?: string;
202
282
  normalizeLanguage?: (lang: string) => string;
203
283
  unknownVoicePolicy?: "error" | "warn" | "ignore";
204
284
  unsupportedStylePolicy?: "error" | "warn" | "ignore";
@@ -209,10 +289,24 @@ interface AzureValidationOptions {
209
289
  type AzureLanguageNormalizationOptions = Pick<AzureValidationOptions, "languageAliases" | "normalizeLanguage">;
210
290
  /** @deprecated Use AzureValidationOptions instead. */
211
291
  type AzureSsmlValidationOptions = AzureValidationOptions;
292
+ /** Returns whether a value is a positive Azure SSML audio duration. */
293
+ declare function isValidAzureAudioDuration(value: string): boolean;
212
294
  /** Normalizes an Azure language tag using BCP 47 and the configured aliases. */
213
295
  declare function normalizeAzureLanguage(language: string, options?: AzureLanguageNormalizationOptions): string;
214
296
  /** Compares two Azure language tags after BCP 47 and alias normalization. */
215
297
  declare function areAzureLanguagesEquivalent(first: string, second: string, options?: AzureLanguageNormalizationOptions): boolean;
216
298
  declare function validateAzureSsml(ssml: string, options?: AzureValidationOptions): SsmlDiagnostic[];
217
299
 
218
- export { type AudioElement, type AzureDiagnosticCode, type AzureLanguageNormalizationOptions, type AzureSsmlValidationOptions, type AzureValidationOptions, type AzureVoiceDefinition, type AzureVoiceMetadata, type BookmarkElement, type BreakElement, type BuildPartialSsmlOptions, type CustomElement, type EmphasisElement, type ExpressAsElement, type LangElement, type LexiconElement, type MapSsmlTextNodesOptions, type MarkElement, type MsttsSilenceElement, type MsttsVisemeElement, type NamedElement, type ParagraphElement, type PhonemeElement, type ProsodyElement, type SayAsElement, type SentenceElement, type SsmlAttributeValue, type SsmlAttributes, type SsmlBreakElement, type SsmlDiagnostic, type SsmlDiagnosticSeverity, type SsmlDiagnosticSource, type SsmlDocument, type SsmlElement, type SsmlElementBase, type SsmlExpressAsElement, type SsmlNode, type SsmlPartialContext, type SsmlPartialProsody, type SsmlPartialVoice, type SsmlPhonemeElement, type SsmlProsodyElement, type SsmlSayAsElement, type SsmlText, type SsmlTextNodeContext, type SsmlValidationError, type SsmlVoiceElement, type SubElement, type VoiceElement, type WordElement, areAzureLanguagesEquivalent, buildPartialSsml, buildSsml, extractSsmlText, mapSsmlTextNodes, normalizeAzureLanguage, parseSsml, validateAzureSsml, validateSsml };
300
+ interface AzureVoiceCatalogMetadata {
301
+ apiVersion: string;
302
+ generatedAt: string;
303
+ regions: readonly string[];
304
+ voiceCount: number;
305
+ }
306
+
307
+ /** Returns metadata for the built-in Azure voice catalog snapshot. */
308
+ declare function getAzureVoiceCatalogMetadata(): AzureVoiceCatalogMetadata;
309
+ /** Alias for consumers that refer to the bundled catalog as the built-in catalog. */
310
+ declare const getBuiltInVoiceCatalogMetadata: typeof getAzureVoiceCatalogMetadata;
311
+
312
+ export { type AudioElement, type AzureDiagnosticCode, type AzureLanguageNormalizationOptions, type AzureSsmlValidationOptions, type AzureValidationOptions, type AzureVoiceCatalogMetadata, type AzureVoiceDefinition, type AzureVoiceMetadata, type BookmarkElement, type BreakElement, type BuildPartialSsmlOptions, type CustomElement, type EmphasisElement, type ExpressAsElement, type ExtractSsmlTranslatableTextOptions, type FromPlainTextToSsmlOptions, type LangElement, type LexiconElement, type MapSsmlTextNodesOptions, type MarkElement, type MsttsAudioDurationElement, type MsttsEmbeddingElement, type MsttsSilenceElement, type MsttsTtsEmbeddingElement, type MsttsVisemeElement, type MsttsVoiceConversionElement, type NamedElement, type ParagraphElement, type PhonemeElement, type ProsodyElement, type SayAsElement, type SentenceElement, type SsmlAttributeValue, type SsmlAttributes, type SsmlBackgroundAudioNode, type SsmlBreakElement, type SsmlDiagnostic, type SsmlDiagnosticSeverity, type SsmlDiagnosticSource, type SsmlDialogNode, type SsmlDocument, type SsmlElement, type SsmlElementBase, type SsmlEmbeddingNode, type SsmlExpressAsElement, type SsmlNode, type SsmlPartialContext, type SsmlPartialProsody, type SsmlPartialVoice, type SsmlPhonemeElement, type SsmlProsodyElement, type SsmlSayAsElement, type SsmlStructureIntegrityResult, type SsmlStructureMismatch, type SsmlText, type SsmlTextNodeContext, type SsmlTtsEmbeddingNode, type SsmlTurnNode, type SsmlValidationError, type SsmlVoiceConversionNode, type SsmlVoiceElement, type SubElement, type VoiceElement, type WordElement, areAzureLanguagesEquivalent, buildPartialSsml, buildSsml, extractSsmlText, extractSsmlTranslatableText, fromPlainTextToSsml, getAzureVoiceCatalogMetadata, getBuiltInVoiceCatalogMetadata, isValidAzureAudioDuration, mapSsmlTextNodes, normalizeAzureLanguage, parseSsml, validateAzureSsml, validateSsml, validateSsmlStructureIntegrity };