ssml-builder-js 2.17.0 → 2.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, ReactElement, CSSProperties } from 'react';
3
- import { d as SsmlDocument, e as SsmlElement, f as AzureVoiceCatalogMetadata } from './index.d-tpKoP1jl.mjs';
3
+ import { S as SsmlDocument, a as SsmlElement, A as AzureVoiceCatalogMetadata } from './index.d-4kqVuH29.mjs';
4
4
  import { OnMount, Monaco } from '@monaco-editor/react';
5
5
 
6
6
  type SsmlEditorInsertionButton = "break" | "emphasis" | "rate" | "pitch" | "volume" | "emotion" | "say-as" | "phoneme" | "audio" | "sub" | "lang" | "mark" | "bookmark" | "mstts:silence" | "mstts:audioduration" | "mstts:viseme" | (string & {});
package/dist/react.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, ReactElement, CSSProperties } from 'react';
3
- import { d as SsmlDocument, e as SsmlElement, f as AzureVoiceCatalogMetadata } from './index.d-tpKoP1jl.js';
3
+ import { S as SsmlDocument, a as SsmlElement, A as AzureVoiceCatalogMetadata } from './index.d-4kqVuH29.js';
4
4
  import { OnMount, Monaco } from '@monaco-editor/react';
5
5
 
6
6
  type SsmlEditorInsertionButton = "break" | "emphasis" | "rate" | "pitch" | "volume" | "emotion" | "say-as" | "phoneme" | "audio" | "sub" | "lang" | "mark" | "bookmark" | "mstts:silence" | "mstts:audioduration" | "mstts:viseme" | (string & {});
package/dist/react.js CHANGED
@@ -6897,22 +6897,35 @@ function voiceForPath(document2, path, voiceCatalog) {
6897
6897
  const voiceName = candidates.find((element) => element.type === "voice")?.name ?? candidates.find((element) => element.type === "mstts:turn")?.voice;
6898
6898
  return voiceName ? voiceCatalog.find((voice) => voice.name.toLowerCase() === voiceName.toLowerCase()) : void 0;
6899
6899
  }
6900
- function isVisualTagSupported(tagName, voice) {
6900
+ function normalizeVisualTagName(tagName) {
6901
+ const normalized = tagName.toLowerCase();
6902
+ if (normalized === "express-as" || normalized === "expressas" || normalized === "mstts:express-as")
6903
+ return "mstts:express-as";
6904
+ if (normalized === "sayas" || normalized === "say-as") return "say-as";
6905
+ return normalized;
6906
+ }
6907
+ function isVisualTagSupported(tagName, voice, model) {
6901
6908
  if (!voice) return true;
6902
- const tag = tagName.toLowerCase();
6903
- const unsupported = new Set((voice.unsupportedTags ?? []).map((candidate) => candidate.toLowerCase()));
6904
- const supported = voice.supportedTags?.map((candidate) => candidate.toLowerCase());
6909
+ const tag = normalizeVisualTagName(tagName);
6910
+ const unsupported = new Set((voice.unsupportedTags ?? []).map(normalizeVisualTagName));
6911
+ if (model && /neural[-_ ]?hd/i.test(model)) unsupported.add("emphasis");
6912
+ const supported = voice.supportedTags?.map(normalizeVisualTagName);
6905
6913
  return !unsupported.has(tag) && (supported === void 0 || supported.includes(tag));
6906
6914
  }
6907
6915
  function VoiceCapabilityMatrix({
6908
6916
  voice,
6909
- locale
6917
+ locale,
6918
+ model
6910
6919
  }) {
6911
6920
  const status = voice.status ?? (voice.preview ? "preview" : void 0);
6912
- return /* @__PURE__ */ React.createElement("div", { className: "ssml-editor-voice-capabilities", "data-voice-capabilities": "" }, /* @__PURE__ */ React.createElement("div", null, locale === "ja" ? "\u30B9\u30C6\u30FC\u30BF\u30B9" : "Status", ": ", status?.toUpperCase() ?? (locale === "ja" ? "GA" : "GA"), status === "preview" || status === "deprecated" ? /* @__PURE__ */ React.createElement("span", { role: "status", "aria-label": status, className: "ssml-editor-voice-warning-badge" }, status === "preview" ? "\u26A0 Preview" : "\u26A0 Deprecated") : null), (voice.regions?.length || voice.region) && /* @__PURE__ */ React.createElement("div", null, locale === "ja" ? "\u30EA\u30FC\u30B8\u30E7\u30F3" : "Regions", ":", " ", [...voice.regions ?? [], ...voice.region ? [voice.region] : []].filter((region, index, all) => all.indexOf(region) === index).join(", ")), voice.supportedTags && voice.supportedTags.length > 0 && /* @__PURE__ */ React.createElement("div", null, locale === "ja" ? "\u5BFE\u5FDC\u30BF\u30B0" : "Supported tags", ": ", voice.supportedTags.join(", ")), voice.unsupportedTags && voice.unsupportedTags.length > 0 && /* @__PURE__ */ React.createElement("div", { className: "ssml-editor-voice-unsupported" }, locale === "ja" ? "\u975E\u5BFE\u5FDC\u30BF\u30B0" : "Unsupported tags", ": ", voice.unsupportedTags.join(", ")));
6921
+ const unsupportedTags = [
6922
+ ...voice.unsupportedTags ?? [],
6923
+ ...model && /neural[-_ ]?hd/i.test(model) && !voice.unsupportedTags?.some((tag) => normalizeVisualTagName(tag) === "emphasis") ? ["emphasis"] : []
6924
+ ];
6925
+ return /* @__PURE__ */ React.createElement("div", { className: "ssml-editor-voice-capabilities", "data-voice-capabilities": "" }, /* @__PURE__ */ React.createElement("div", null, locale === "ja" ? "\u30B9\u30C6\u30FC\u30BF\u30B9" : "Status", ": ", status?.toUpperCase() ?? (locale === "ja" ? "GA" : "GA"), status === "preview" || status === "deprecated" ? /* @__PURE__ */ React.createElement("span", { role: "status", "aria-label": status, className: "ssml-editor-voice-warning-badge" }, status === "preview" ? "\u26A0 Preview" : "\u26A0 Deprecated") : null), (voice.regions?.length || voice.region) && /* @__PURE__ */ React.createElement("div", null, locale === "ja" ? "\u30EA\u30FC\u30B8\u30E7\u30F3" : "Regions", ":", " ", [...voice.regions ?? [], ...voice.region ? [voice.region] : []].filter((region, index, all) => all.indexOf(region) === index).join(", ")), voice.supportedTags && voice.supportedTags.length > 0 && /* @__PURE__ */ React.createElement("div", null, locale === "ja" ? "\u5BFE\u5FDC\u30BF\u30B0" : "Supported tags", ": ", voice.supportedTags.join(", ")), unsupportedTags.length > 0 && /* @__PURE__ */ React.createElement("div", { className: "ssml-editor-voice-unsupported" }, locale === "ja" ? "\u975E\u5BFE\u5FDC\u30BF\u30B0" : "Unsupported tags", ": ", unsupportedTags.join(", ")));
6913
6926
  }
6914
6927
  function diagnosticMatchesElement(diagnostic, element) {
6915
- const name = elementLabel(element).toLowerCase().replace("expressas", "mstts:express-as");
6928
+ const name = normalizeVisualTagName(elementLabel(element));
6916
6929
  if (diagnostic.code === "azure-unsupported-style") return name === "mstts:express-as" || name === "express-as";
6917
6930
  if (diagnostic.code === "azure-unsupported-tag-for-voice") {
6918
6931
  return diagnostic.message.toLowerCase().includes(`<${name}>`) || diagnostic.message.toLowerCase().includes(`<${name.replace("mstts:", "")}>`);
@@ -6979,9 +6992,10 @@ function VisualElementInspector({
6979
6992
  voiceRegion,
6980
6993
  voiceStyle,
6981
6994
  diagnostics,
6982
- voiceDefinition
6995
+ voiceDefinition,
6996
+ model
6983
6997
  }) {
6984
- const tagSupported = isVisualTagSupported(elementLabel(element), voiceDefinition);
6998
+ const tagSupported = isVisualTagSupported(elementLabel(element), voiceDefinition, model);
6985
6999
  if (customInspector) {
6986
7000
  return /* @__PURE__ */ React.createElement(React.Fragment, null, customInspector({ document: document2, element, path, readOnly: readOnly || !tagSupported, onChange: commit, locale }));
6987
7001
  }
@@ -7159,22 +7173,28 @@ function VisualSsmlEditor({
7159
7173
  const activeVoice = voiceForPath(document2, selectedPath ?? selectedLeaf?.path, voiceCatalog);
7160
7174
  const staleCatalog = voiceCatalogMetadata?.expiresAt ? Date.parse(voiceCatalogMetadata.expiresAt) <= Date.now() : false;
7161
7175
  const selectedCustomInspector = selectedElement && isElement(selectedElement) ? customInspectors?.[elementLabel(selectedElement)] ?? customInspectors?.[selectedElement.type] : void 0;
7162
- const validationOptions = (0, import_react3.useMemo)(
7163
- () => ({
7164
- model: voiceModel ?? model,
7176
+ const validationOptions = (0, import_react3.useMemo)(() => {
7177
+ const selectedModel = voiceModel ?? model;
7178
+ const hdUnsupportedTags = selectedModel && /neural[-_ ]?hd/i.test(selectedModel) ? ["emphasis"] : [];
7179
+ return {
7180
+ model: selectedModel,
7165
7181
  customVoiceDefinitions: voiceCatalog?.map((voice) => ({
7166
7182
  name: voice.name,
7167
7183
  locale: voice.locale,
7168
7184
  regions: voice.regions ?? (voice.region ? [voice.region] : void 0),
7169
7185
  styles: voice.styles,
7170
7186
  supportedTags: voice.supportedTags,
7171
- unsupportedTags: voice.unsupportedTags,
7187
+ unsupportedTags: [
7188
+ ...voice.unsupportedTags ?? [],
7189
+ ...hdUnsupportedTags.filter(
7190
+ (tag) => !voice.unsupportedTags?.some((candidate) => normalizeVisualTagName(candidate) === tag)
7191
+ )
7192
+ ],
7172
7193
  models: voice.models,
7173
7194
  status: voice.status ?? (voice.preview ? "preview" : "ga")
7174
7195
  }))
7175
- }),
7176
- [model, voiceCatalog, voiceModel]
7177
- );
7196
+ };
7197
+ }, [model, voiceCatalog, voiceModel]);
7178
7198
  const diagnostics = (0, import_react3.useMemo)(
7179
7199
  () => validateAzureSsml(buildSsml(document2), validationOptions),
7180
7200
  [document2, validationOptions]
@@ -7201,14 +7221,14 @@ function VisualSsmlEditor({
7201
7221
  document: document2,
7202
7222
  element: selectedElement,
7203
7223
  path: selectedPath ?? [],
7204
- readOnly: readOnly || !isVisualTagSupported(elementLabel(selectedElement), activeVoice),
7224
+ readOnly: readOnly || !isVisualTagSupported(elementLabel(selectedElement), activeVoice, voiceModel ?? model),
7205
7225
  onChange: commit,
7206
7226
  locale
7207
7227
  }) : selectedElement && isElement(selectedElement) && selectedElement.type === "mstts:dialog" ? /* @__PURE__ */ React.createElement("fieldset", null, /* @__PURE__ */ React.createElement("legend", null, localizedElementLabel(selectedElement, locale)), /* @__PURE__ */ React.createElement("p", null, SSML_ELEMENT_COPY[locale][elementLabel(selectedElement)]?.description), /* @__PURE__ */ React.createElement(
7208
7228
  "button",
7209
7229
  {
7210
7230
  type: "button",
7211
- disabled: readOnly || !isVisualTagSupported("mstts:dialog", activeVoice),
7231
+ disabled: readOnly || !isVisualTagSupported("mstts:dialog", activeVoice, voiceModel ?? model),
7212
7232
  onClick: () => commit(addDialogTurn(document2, selectedPath ?? []))
7213
7233
  },
7214
7234
  locale === "ja" ? "\u30BF\u30FC\u30F3\u3092\u8FFD\u52A0" : "Add turn"
@@ -7291,7 +7311,8 @@ function VisualSsmlEditor({
7291
7311
  voiceRegion,
7292
7312
  voiceStyle,
7293
7313
  diagnostics,
7294
- voiceDefinition: activeVoice
7314
+ voiceDefinition: activeVoice,
7315
+ model: voiceModel ?? model
7295
7316
  }
7296
7317
  ) : selectedLeaf ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("label", null, "Text", /* @__PURE__ */ React.createElement(
7297
7318
  "textarea",
@@ -7305,7 +7326,7 @@ function VisualSsmlEditor({
7305
7326
  "button",
7306
7327
  {
7307
7328
  type: "button",
7308
- disabled: readOnly || !isVisualTagSupported("prosody", activeVoice),
7329
+ disabled: readOnly || !isVisualTagSupported("prosody", activeVoice, voiceModel ?? model),
7309
7330
  onClick: () => applyWrapper("prosody", { rate: "slow" })
7310
7331
  },
7311
7332
  "Rate"
@@ -7313,7 +7334,7 @@ function VisualSsmlEditor({
7313
7334
  "button",
7314
7335
  {
7315
7336
  type: "button",
7316
- disabled: readOnly || !isVisualTagSupported("prosody", activeVoice),
7337
+ disabled: readOnly || !isVisualTagSupported("prosody", activeVoice, voiceModel ?? model),
7317
7338
  onClick: () => applyWrapper("prosody", { pitch: "high" })
7318
7339
  },
7319
7340
  "Pitch"
@@ -7321,7 +7342,7 @@ function VisualSsmlEditor({
7321
7342
  "button",
7322
7343
  {
7323
7344
  type: "button",
7324
- disabled: readOnly || !isVisualTagSupported("mstts:express-as", activeVoice),
7345
+ disabled: readOnly || !isVisualTagSupported("mstts:express-as", activeVoice, voiceModel ?? model),
7325
7346
  onClick: () => applyWrapper("mstts:express-as", { style: "cheerful" })
7326
7347
  },
7327
7348
  "Emotion"
@@ -7329,7 +7350,7 @@ function VisualSsmlEditor({
7329
7350
  "button",
7330
7351
  {
7331
7352
  type: "button",
7332
- disabled: readOnly || !isVisualTagSupported("break", activeVoice),
7353
+ disabled: readOnly || !isVisualTagSupported("break", activeVoice, voiceModel ?? model),
7333
7354
  onClick: () => applyWrapper("break", { time: "500ms" })
7334
7355
  },
7335
7356
  "Pause"
@@ -7337,7 +7358,7 @@ function VisualSsmlEditor({
7337
7358
  "button",
7338
7359
  {
7339
7360
  type: "button",
7340
- disabled: readOnly || !isVisualTagSupported("phoneme", activeVoice),
7361
+ disabled: readOnly || !isVisualTagSupported("phoneme", activeVoice, voiceModel ?? model),
7341
7362
  onClick: () => applyWrapper("phoneme", { alphabet: "ipa", ph: selectedLeaf.value })
7342
7363
  },
7343
7364
  "Pronunciation"