ssml-builder-js 2.8.1 → 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
@@ -103,11 +103,40 @@ interface MsttsAudioDurationElement extends SsmlElementBase {
103
103
  type: "mstts:audioduration";
104
104
  value?: SsmlAttributeValue;
105
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;
106
135
  interface CustomElement extends SsmlElementBase {
107
136
  type: "custom" | "element";
108
137
  name: string;
109
138
  }
110
- type SsmlElement = VoiceElement | ProsodyElement | BreakElement | ExpressAsElement | SayAsElement | PhonemeElement | EmphasisElement | AudioElement | SubElement | LangElement | MarkElement | BookmarkElement | LexiconElement | ParagraphElement | SentenceElement | WordElement | MsttsSilenceElement | MsttsVisemeElement | MsttsAudioDurationElement | 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;
111
140
  interface SsmlDocument {
112
141
  type?: "speak";
113
142
  version: string;
@@ -175,9 +204,51 @@ interface MapSsmlTextNodesOptions {
175
204
  declare function extractSsmlText(ssml: string): string[];
176
205
  declare function mapSsmlTextNodes(ssml: string, transform: (text: string, context: SsmlTextNodeContext) => string | Promise<string>, options?: MapSsmlTextNodesOptions): Promise<string>;
177
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
+
178
249
  type SsmlDiagnosticSeverity = "error" | "warning";
179
250
  type SsmlDiagnosticSource = "ssml-static-validator";
180
- 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";
181
252
  interface SsmlDiagnostic {
182
253
  code?: AzureDiagnosticCode;
183
254
  line: number;
@@ -191,6 +262,9 @@ interface AzureVoiceDefinition {
191
262
  locale: string;
192
263
  secondaryLocales?: readonly string[];
193
264
  styles?: readonly string[];
265
+ supportedTags?: readonly string[];
266
+ unsupportedTags?: readonly string[];
267
+ models?: readonly string[];
194
268
  }
195
269
  /** Alias retained for consumers that prefer the metadata terminology. */
196
270
  interface AzureVoiceMetadata extends AzureVoiceDefinition {
@@ -203,6 +277,8 @@ interface AzureValidationOptions {
203
277
  customVoiceDefinitions?: readonly AzureVoiceDefinition[];
204
278
  languageAliases?: Record<string, string | readonly string[]>;
205
279
  maxLength?: number;
280
+ /** Optional model identifier used to validate a voice's model compatibility. */
281
+ model?: string;
206
282
  normalizeLanguage?: (lang: string) => string;
207
283
  unknownVoicePolicy?: "error" | "warn" | "ignore";
208
284
  unsupportedStylePolicy?: "error" | "warn" | "ignore";
@@ -221,4 +297,16 @@ declare function normalizeAzureLanguage(language: string, options?: AzureLanguag
221
297
  declare function areAzureLanguagesEquivalent(first: string, second: string, options?: AzureLanguageNormalizationOptions): boolean;
222
298
  declare function validateAzureSsml(ssml: string, options?: AzureValidationOptions): SsmlDiagnostic[];
223
299
 
224
- 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 MsttsAudioDurationElement, 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, isValidAzureAudioDuration, 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
@@ -103,11 +103,40 @@ interface MsttsAudioDurationElement extends SsmlElementBase {
103
103
  type: "mstts:audioduration";
104
104
  value?: SsmlAttributeValue;
105
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;
106
135
  interface CustomElement extends SsmlElementBase {
107
136
  type: "custom" | "element";
108
137
  name: string;
109
138
  }
110
- type SsmlElement = VoiceElement | ProsodyElement | BreakElement | ExpressAsElement | SayAsElement | PhonemeElement | EmphasisElement | AudioElement | SubElement | LangElement | MarkElement | BookmarkElement | LexiconElement | ParagraphElement | SentenceElement | WordElement | MsttsSilenceElement | MsttsVisemeElement | MsttsAudioDurationElement | 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;
111
140
  interface SsmlDocument {
112
141
  type?: "speak";
113
142
  version: string;
@@ -175,9 +204,51 @@ interface MapSsmlTextNodesOptions {
175
204
  declare function extractSsmlText(ssml: string): string[];
176
205
  declare function mapSsmlTextNodes(ssml: string, transform: (text: string, context: SsmlTextNodeContext) => string | Promise<string>, options?: MapSsmlTextNodesOptions): Promise<string>;
177
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
+
178
249
  type SsmlDiagnosticSeverity = "error" | "warning";
179
250
  type SsmlDiagnosticSource = "ssml-static-validator";
180
- 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";
181
252
  interface SsmlDiagnostic {
182
253
  code?: AzureDiagnosticCode;
183
254
  line: number;
@@ -191,6 +262,9 @@ interface AzureVoiceDefinition {
191
262
  locale: string;
192
263
  secondaryLocales?: readonly string[];
193
264
  styles?: readonly string[];
265
+ supportedTags?: readonly string[];
266
+ unsupportedTags?: readonly string[];
267
+ models?: readonly string[];
194
268
  }
195
269
  /** Alias retained for consumers that prefer the metadata terminology. */
196
270
  interface AzureVoiceMetadata extends AzureVoiceDefinition {
@@ -203,6 +277,8 @@ interface AzureValidationOptions {
203
277
  customVoiceDefinitions?: readonly AzureVoiceDefinition[];
204
278
  languageAliases?: Record<string, string | readonly string[]>;
205
279
  maxLength?: number;
280
+ /** Optional model identifier used to validate a voice's model compatibility. */
281
+ model?: string;
206
282
  normalizeLanguage?: (lang: string) => string;
207
283
  unknownVoicePolicy?: "error" | "warn" | "ignore";
208
284
  unsupportedStylePolicy?: "error" | "warn" | "ignore";
@@ -221,4 +297,16 @@ declare function normalizeAzureLanguage(language: string, options?: AzureLanguag
221
297
  declare function areAzureLanguagesEquivalent(first: string, second: string, options?: AzureLanguageNormalizationOptions): boolean;
222
298
  declare function validateAzureSsml(ssml: string, options?: AzureValidationOptions): SsmlDiagnostic[];
223
299
 
224
- 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 MsttsAudioDurationElement, 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, isValidAzureAudioDuration, 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 };