ssml-builder-js 2.9.0 → 2.11.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 +74 -8
- package/bin/sync-voices.js +62 -0
- package/dist/{chunk-JNJVTEL6.mjs → chunk-FWWMWI2C.mjs} +143 -17
- package/dist/chunk-FWWMWI2C.mjs.map +1 -0
- package/dist/{chunk-7LCSH4SZ.mjs → chunk-SNRI43QJ.mjs} +142 -8
- package/dist/chunk-SNRI43QJ.mjs.map +1 -0
- package/dist/core.d.mts +17 -2
- package/dist/core.d.ts +17 -2
- package/dist/core.js +141 -7
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +1 -1
- package/dist/elements.js +142 -16
- package/dist/elements.js.map +1 -1
- package/dist/elements.mjs +1 -1
- package/dist/index.d.mts +26 -1
- package/dist/index.d.ts +26 -1
- package/dist/index.js +221 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +80 -1
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +7 -0
- package/dist/react.d.ts +7 -0
- package/dist/react.js +247 -17
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +106 -2
- package/dist/react.mjs.map +1 -1
- package/package.json +5 -1
- package/dist/chunk-7LCSH4SZ.mjs.map +0 -1
- package/dist/chunk-JNJVTEL6.mjs.map +0 -1
package/dist/react.mjs
CHANGED
|
@@ -45,7 +45,7 @@ import {
|
|
|
45
45
|
updateTagAttribute,
|
|
46
46
|
validateAzureSsml,
|
|
47
47
|
validateSsml
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-FWWMWI2C.mjs";
|
|
49
49
|
import "./chunk-6S5ODO6A.mjs";
|
|
50
50
|
|
|
51
51
|
// packages/ssml-editor-react/src/SsmlEditor.tsx
|
|
@@ -1840,6 +1840,46 @@ function updateNodesAtPath(nodes, path, update) {
|
|
|
1840
1840
|
function updateTextAtPath(document2, path, value) {
|
|
1841
1841
|
return { ...document2, children: updateNodesAtPath(document2.children ?? [], path, () => value) };
|
|
1842
1842
|
}
|
|
1843
|
+
function getNodeAtPath(nodes, path) {
|
|
1844
|
+
let current;
|
|
1845
|
+
let currentNodes = nodes;
|
|
1846
|
+
for (const index of path) {
|
|
1847
|
+
current = currentNodes[index];
|
|
1848
|
+
if (current === void 0) return void 0;
|
|
1849
|
+
if (!isElement(current)) {
|
|
1850
|
+
currentNodes = [];
|
|
1851
|
+
} else {
|
|
1852
|
+
currentNodes = current.children ?? [];
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
return current;
|
|
1856
|
+
}
|
|
1857
|
+
function updateElementAtPath(document2, path, update) {
|
|
1858
|
+
return {
|
|
1859
|
+
...document2,
|
|
1860
|
+
children: updateNodesAtPath(document2.children ?? [], path, (node) => isElement(node) ? update(node) : node)
|
|
1861
|
+
};
|
|
1862
|
+
}
|
|
1863
|
+
function updateElementText(element, value) {
|
|
1864
|
+
return { ...element, children: [value] };
|
|
1865
|
+
}
|
|
1866
|
+
function updateOptionalElementProperty(document2, path, property, value) {
|
|
1867
|
+
return updateElementAtPath(document2, path, (element) => {
|
|
1868
|
+
const next = { ...element };
|
|
1869
|
+
if (value.trim()) next[property] = value;
|
|
1870
|
+
else delete next[property];
|
|
1871
|
+
return next;
|
|
1872
|
+
});
|
|
1873
|
+
}
|
|
1874
|
+
function addDialogTurn(document2, path) {
|
|
1875
|
+
return updateElementAtPath(document2, path, (element) => ({
|
|
1876
|
+
...element,
|
|
1877
|
+
children: [
|
|
1878
|
+
...element.children ?? [],
|
|
1879
|
+
{ type: "mstts:turn", voice: "en-US-JennyNeural", children: ["New dialog turn"] }
|
|
1880
|
+
]
|
|
1881
|
+
}));
|
|
1882
|
+
}
|
|
1843
1883
|
function wrapTextAtPath(document2, path, start, end, tag, attributes) {
|
|
1844
1884
|
return {
|
|
1845
1885
|
...document2,
|
|
@@ -1891,6 +1931,7 @@ function VisualSsmlEditor({
|
|
|
1891
1931
|
const [selection, setSelection] = useState2({ start: 0, end: 0 });
|
|
1892
1932
|
const textLeaves = useMemo(() => collectTextLeaves(document2.children ?? []), [document2]);
|
|
1893
1933
|
const selectedLeaf = textLeaves.find((leaf) => leaf.path.join(".") === selectedPath?.join(".")) ?? textLeaves[0];
|
|
1934
|
+
const selectedElement = selectedPath ? getNodeAtPath(document2.children ?? [], selectedPath) : void 0;
|
|
1894
1935
|
const diagnostics = useMemo(() => validateAzureSsml(buildSsml(document2)), [document2]);
|
|
1895
1936
|
const commit = (nextDocument) => onChange?.(nextDocument);
|
|
1896
1937
|
const applyWrapper = (tag, attributes) => {
|
|
@@ -1908,7 +1949,70 @@ function VisualSsmlEditor({
|
|
|
1908
1949
|
selectedPath,
|
|
1909
1950
|
onSelect: setSelectedPath
|
|
1910
1951
|
}
|
|
1911
|
-
)))), /* @__PURE__ */ React.createElement("div", { className: "ssml-editor-visual-form" },
|
|
1952
|
+
)))), /* @__PURE__ */ React.createElement("div", { className: "ssml-editor-visual-form" }, selectedElement && isElement(selectedElement) && selectedElement.type === "mstts:dialog" ? /* @__PURE__ */ React.createElement("fieldset", null, /* @__PURE__ */ React.createElement("legend", null, "Dialog"), /* @__PURE__ */ React.createElement("p", null, "Add and edit speaker turns in this dialog."), /* @__PURE__ */ React.createElement(
|
|
1953
|
+
"button",
|
|
1954
|
+
{
|
|
1955
|
+
type: "button",
|
|
1956
|
+
disabled: readOnly,
|
|
1957
|
+
onClick: () => commit(addDialogTurn(document2, selectedPath ?? []))
|
|
1958
|
+
},
|
|
1959
|
+
"Add turn"
|
|
1960
|
+
)) : selectedElement && isElement(selectedElement) && selectedElement.type === "mstts:turn" ? /* @__PURE__ */ React.createElement("fieldset", null, /* @__PURE__ */ React.createElement("legend", null, "Dialog turn"), /* @__PURE__ */ React.createElement("label", null, "Voice", /* @__PURE__ */ React.createElement(
|
|
1961
|
+
"input",
|
|
1962
|
+
{
|
|
1963
|
+
value: selectedElement.voice ?? "",
|
|
1964
|
+
readOnly,
|
|
1965
|
+
onChange: (event) => commit(updateOptionalElementProperty(document2, selectedPath ?? [], "voice", event.target.value))
|
|
1966
|
+
}
|
|
1967
|
+
)), /* @__PURE__ */ React.createElement("label", null, "Speaker", /* @__PURE__ */ React.createElement(
|
|
1968
|
+
"input",
|
|
1969
|
+
{
|
|
1970
|
+
value: selectedElement.speaker ?? "",
|
|
1971
|
+
readOnly,
|
|
1972
|
+
onChange: (event) => commit(updateOptionalElementProperty(document2, selectedPath ?? [], "speaker", event.target.value))
|
|
1973
|
+
}
|
|
1974
|
+
)), /* @__PURE__ */ React.createElement("label", null, "Turn text", /* @__PURE__ */ React.createElement(
|
|
1975
|
+
"textarea",
|
|
1976
|
+
{
|
|
1977
|
+
value: selectedElement.children?.filter((child) => typeof child === "string").join("") ?? "",
|
|
1978
|
+
readOnly,
|
|
1979
|
+
onChange: (event) => commit(
|
|
1980
|
+
updateElementAtPath(
|
|
1981
|
+
document2,
|
|
1982
|
+
selectedPath ?? [],
|
|
1983
|
+
(element) => updateElementText(element, event.target.value)
|
|
1984
|
+
)
|
|
1985
|
+
)
|
|
1986
|
+
}
|
|
1987
|
+
))) : selectedElement && isElement(selectedElement) && selectedElement.type === "mstts:backgroundaudio" ? /* @__PURE__ */ React.createElement("fieldset", null, /* @__PURE__ */ React.createElement("legend", null, "Background audio"), /* @__PURE__ */ React.createElement("label", null, "Source URL", /* @__PURE__ */ React.createElement(
|
|
1988
|
+
"input",
|
|
1989
|
+
{
|
|
1990
|
+
value: selectedElement.src ?? "",
|
|
1991
|
+
readOnly,
|
|
1992
|
+
onChange: (event) => commit(updateOptionalElementProperty(document2, selectedPath ?? [], "src", event.target.value))
|
|
1993
|
+
}
|
|
1994
|
+
)), /* @__PURE__ */ React.createElement("label", null, "Volume", /* @__PURE__ */ React.createElement(
|
|
1995
|
+
"input",
|
|
1996
|
+
{
|
|
1997
|
+
value: selectedElement.volume === void 0 ? "" : String(selectedElement.volume),
|
|
1998
|
+
readOnly,
|
|
1999
|
+
onChange: (event) => commit(updateOptionalElementProperty(document2, selectedPath ?? [], "volume", event.target.value))
|
|
2000
|
+
}
|
|
2001
|
+
)), /* @__PURE__ */ React.createElement("label", null, "Fade in", /* @__PURE__ */ React.createElement(
|
|
2002
|
+
"input",
|
|
2003
|
+
{
|
|
2004
|
+
value: selectedElement.fadeIn === void 0 ? "" : String(selectedElement.fadeIn),
|
|
2005
|
+
readOnly,
|
|
2006
|
+
onChange: (event) => commit(updateOptionalElementProperty(document2, selectedPath ?? [], "fadeIn", event.target.value))
|
|
2007
|
+
}
|
|
2008
|
+
)), /* @__PURE__ */ React.createElement("label", null, "Fade out", /* @__PURE__ */ React.createElement(
|
|
2009
|
+
"input",
|
|
2010
|
+
{
|
|
2011
|
+
value: selectedElement.fadeOut === void 0 ? "" : String(selectedElement.fadeOut),
|
|
2012
|
+
readOnly,
|
|
2013
|
+
onChange: (event) => commit(updateOptionalElementProperty(document2, selectedPath ?? [], "fadeOut", event.target.value))
|
|
2014
|
+
}
|
|
2015
|
+
))) : selectedLeaf ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("label", null, "Text", /* @__PURE__ */ React.createElement(
|
|
1912
2016
|
"textarea",
|
|
1913
2017
|
{
|
|
1914
2018
|
value: selectedLeaf.value,
|