ssml-builder-js 2.11.0 → 2.12.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 +36 -3
- package/dist/{chunk-SNRI43QJ.mjs → chunk-4BVNAUVR.mjs} +123 -3
- package/dist/chunk-4BVNAUVR.mjs.map +1 -0
- package/dist/{chunk-FWWMWI2C.mjs → chunk-FHDFRM2F.mjs} +24 -3
- package/dist/chunk-FHDFRM2F.mjs.map +1 -0
- package/dist/core.d.mts +11 -1
- package/dist/core.d.ts +11 -1
- package/dist/core.js +123 -2
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +3 -1
- package/dist/elements.js +23 -2
- package/dist/elements.js.map +1 -1
- package/dist/elements.mjs +1 -1
- package/dist/index.d.mts +30 -2
- package/dist/index.d.ts +30 -2
- package/dist/index.js +166 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -3
- package/dist/index.mjs.map +1 -1
- package/dist/react.js +163 -4
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +141 -3
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-FWWMWI2C.mjs.map +0 -1
- package/dist/chunk-SNRI43QJ.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-FHDFRM2F.mjs";
|
|
49
49
|
import "./chunk-6S5ODO6A.mjs";
|
|
50
50
|
|
|
51
51
|
// packages/ssml-editor-react/src/SsmlEditor.tsx
|
|
@@ -1871,6 +1871,135 @@ function updateOptionalElementProperty(document2, path, property, value) {
|
|
|
1871
1871
|
return next;
|
|
1872
1872
|
});
|
|
1873
1873
|
}
|
|
1874
|
+
var VISUAL_ELEMENT_FIELDS = {
|
|
1875
|
+
voice: [
|
|
1876
|
+
{ key: "name", label: "Voice name" },
|
|
1877
|
+
{ key: "effect", label: "Effect" }
|
|
1878
|
+
],
|
|
1879
|
+
prosody: [
|
|
1880
|
+
{ key: "rate", label: "Rate" },
|
|
1881
|
+
{ key: "pitch", label: "Pitch" },
|
|
1882
|
+
{ key: "volume", label: "Volume" },
|
|
1883
|
+
{ key: "contour", label: "Contour" },
|
|
1884
|
+
{ key: "range", label: "Range" }
|
|
1885
|
+
],
|
|
1886
|
+
"express-as": [
|
|
1887
|
+
{ key: "style", label: "Style" },
|
|
1888
|
+
{ key: "styleDegree", label: "Style degree" },
|
|
1889
|
+
{ key: "role", label: "Role" }
|
|
1890
|
+
],
|
|
1891
|
+
expressAs: [
|
|
1892
|
+
{ key: "style", label: "Style" },
|
|
1893
|
+
{ key: "styleDegree", label: "Style degree" },
|
|
1894
|
+
{ key: "role", label: "Role" }
|
|
1895
|
+
],
|
|
1896
|
+
"mstts:express-as": [
|
|
1897
|
+
{ key: "style", label: "Style" },
|
|
1898
|
+
{ key: "styleDegree", label: "Style degree" },
|
|
1899
|
+
{ key: "role", label: "Role" }
|
|
1900
|
+
],
|
|
1901
|
+
"say-as": [
|
|
1902
|
+
{ key: "interpretAs", label: "Interpret as" },
|
|
1903
|
+
{ key: "format", label: "Format" },
|
|
1904
|
+
{ key: "detail", label: "Detail" }
|
|
1905
|
+
],
|
|
1906
|
+
sayAs: [
|
|
1907
|
+
{ key: "interpretAs", label: "Interpret as" },
|
|
1908
|
+
{ key: "format", label: "Format" },
|
|
1909
|
+
{ key: "detail", label: "Detail" }
|
|
1910
|
+
],
|
|
1911
|
+
phoneme: [
|
|
1912
|
+
{ key: "alphabet", label: "Alphabet" },
|
|
1913
|
+
{ key: "ph", label: "Pronunciation" }
|
|
1914
|
+
],
|
|
1915
|
+
emphasis: [{ key: "level", label: "Level" }],
|
|
1916
|
+
audio: [
|
|
1917
|
+
{ key: "src", label: "Source URL" },
|
|
1918
|
+
{ key: "desc", label: "Description" },
|
|
1919
|
+
{ key: "clipBegin", label: "Clip begin" },
|
|
1920
|
+
{ key: "clipEnd", label: "Clip end" },
|
|
1921
|
+
{ key: "speed", label: "Speed" },
|
|
1922
|
+
{ key: "repeatCount", label: "Repeat count" },
|
|
1923
|
+
{ key: "repeatDuration", label: "Repeat duration" },
|
|
1924
|
+
{ key: "soundLevel", label: "Sound level" }
|
|
1925
|
+
],
|
|
1926
|
+
mark: [{ key: "name", label: "Mark name" }],
|
|
1927
|
+
bookmark: [{ key: "mark", label: "Bookmark name" }],
|
|
1928
|
+
sub: [{ key: "alias", label: "Alias" }],
|
|
1929
|
+
lang: [{ key: "lang", label: "Language" }],
|
|
1930
|
+
lexicon: [{ key: "uri", label: "Lexicon URI" }],
|
|
1931
|
+
"mstts:silence": [
|
|
1932
|
+
{ key: "typeValue", label: "Silence type" },
|
|
1933
|
+
{ key: "value", label: "Value" }
|
|
1934
|
+
],
|
|
1935
|
+
silence: [
|
|
1936
|
+
{ key: "typeValue", label: "Silence type" },
|
|
1937
|
+
{ key: "value", label: "Value" }
|
|
1938
|
+
],
|
|
1939
|
+
"mstts:audioduration": [{ key: "value", label: "Duration" }],
|
|
1940
|
+
"mstts:ttsembedding": [{ key: "speakerProfileId", label: "Speaker profile ID" }],
|
|
1941
|
+
"mstts:embedding": [
|
|
1942
|
+
{ key: "id", label: "Embedding ID" },
|
|
1943
|
+
{ key: "speakerProfileId", label: "Speaker profile ID" }
|
|
1944
|
+
],
|
|
1945
|
+
"mstts:voiceconversion": [
|
|
1946
|
+
{ key: "url", label: "Source URL" },
|
|
1947
|
+
{ key: "profile", label: "Profile" },
|
|
1948
|
+
{ key: "speakerProfileId", label: "Speaker profile ID" }
|
|
1949
|
+
]
|
|
1950
|
+
};
|
|
1951
|
+
function getElementFields(element) {
|
|
1952
|
+
return VISUAL_ELEMENT_FIELDS[elementLabel(element)] ?? [];
|
|
1953
|
+
}
|
|
1954
|
+
function VisualElementInspector({
|
|
1955
|
+
document: document2,
|
|
1956
|
+
element,
|
|
1957
|
+
path,
|
|
1958
|
+
readOnly,
|
|
1959
|
+
commit
|
|
1960
|
+
}) {
|
|
1961
|
+
const fields = getElementFields(element);
|
|
1962
|
+
return /* @__PURE__ */ React.createElement("fieldset", null, /* @__PURE__ */ React.createElement("legend", null, `<${elementLabel(element)}>`), fields.length === 0 ? /* @__PURE__ */ React.createElement("p", null, "This element is preserved in the visual tree. Edit its attributes in Code mode.") : fields.map((field) => {
|
|
1963
|
+
const value = element[field.key];
|
|
1964
|
+
const inputValue = value === void 0 ? "" : String(value);
|
|
1965
|
+
const inputId = `ssml-visual-${field.key}`;
|
|
1966
|
+
return /* @__PURE__ */ React.createElement("label", { key: field.key, htmlFor: inputId }, field.label, field.multiline ? /* @__PURE__ */ React.createElement(
|
|
1967
|
+
"textarea",
|
|
1968
|
+
{
|
|
1969
|
+
id: inputId,
|
|
1970
|
+
value: inputValue,
|
|
1971
|
+
readOnly,
|
|
1972
|
+
onChange: (event) => commit(updateOptionalElementProperty(document2, path, field.key, event.target.value))
|
|
1973
|
+
}
|
|
1974
|
+
) : /* @__PURE__ */ React.createElement(
|
|
1975
|
+
"input",
|
|
1976
|
+
{
|
|
1977
|
+
id: inputId,
|
|
1978
|
+
value: inputValue,
|
|
1979
|
+
readOnly,
|
|
1980
|
+
onChange: (event) => commit(updateOptionalElementProperty(document2, path, field.key, event.target.value))
|
|
1981
|
+
}
|
|
1982
|
+
));
|
|
1983
|
+
}));
|
|
1984
|
+
}
|
|
1985
|
+
function getElementAncestors(nodes, path, ancestors = []) {
|
|
1986
|
+
const [index, ...rest] = path;
|
|
1987
|
+
const node = nodes[index];
|
|
1988
|
+
if (!node || !isElement(node)) return ancestors;
|
|
1989
|
+
if (rest.length === 0) return ancestors;
|
|
1990
|
+
return getElementAncestors(node.children ?? [], rest, [...ancestors, node]);
|
|
1991
|
+
}
|
|
1992
|
+
function buildVisualPreview(document2, leaf, selection) {
|
|
1993
|
+
const start = Math.max(0, Math.min(selection.start, leaf.value.length));
|
|
1994
|
+
const end = Math.max(start, Math.min(selection.end, leaf.value.length));
|
|
1995
|
+
const value = start === end ? leaf.value : leaf.value.slice(start, end);
|
|
1996
|
+
const ancestors = getElementAncestors(document2.children ?? [], leaf.path);
|
|
1997
|
+
const children = ancestors.reduceRight(
|
|
1998
|
+
(current, ancestor) => [{ ...ancestor, children: current }],
|
|
1999
|
+
[value]
|
|
2000
|
+
);
|
|
2001
|
+
return buildSsml({ ...document2, children });
|
|
2002
|
+
}
|
|
1874
2003
|
function addDialogTurn(document2, path) {
|
|
1875
2004
|
return updateElementAtPath(document2, path, (element) => ({
|
|
1876
2005
|
...element,
|
|
@@ -2012,7 +2141,16 @@ function VisualSsmlEditor({
|
|
|
2012
2141
|
readOnly,
|
|
2013
2142
|
onChange: (event) => commit(updateOptionalElementProperty(document2, selectedPath ?? [], "fadeOut", event.target.value))
|
|
2014
2143
|
}
|
|
2015
|
-
))) :
|
|
2144
|
+
))) : selectedElement && isElement(selectedElement) ? /* @__PURE__ */ React.createElement(
|
|
2145
|
+
VisualElementInspector,
|
|
2146
|
+
{
|
|
2147
|
+
document: document2,
|
|
2148
|
+
element: selectedElement,
|
|
2149
|
+
path: selectedPath ?? [],
|
|
2150
|
+
readOnly,
|
|
2151
|
+
commit
|
|
2152
|
+
}
|
|
2153
|
+
) : selectedLeaf ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("label", null, "Text", /* @__PURE__ */ React.createElement(
|
|
2016
2154
|
"textarea",
|
|
2017
2155
|
{
|
|
2018
2156
|
value: selectedLeaf.value,
|
|
@@ -2040,7 +2178,7 @@ function VisualSsmlEditor({
|
|
|
2040
2178
|
"button",
|
|
2041
2179
|
{
|
|
2042
2180
|
type: "button",
|
|
2043
|
-
onClick: () => onPreviewSelection(
|
|
2181
|
+
onClick: () => onPreviewSelection(buildVisualPreview(document2, selectedLeaf, selection))
|
|
2044
2182
|
},
|
|
2045
2183
|
"Preview selection"
|
|
2046
2184
|
))) : /* @__PURE__ */ React.createElement("p", null, "Select an element or text node to edit it."))));
|