ssml-builder-js 2.1.0 → 2.2.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 +77 -8
- package/dist/chunk-2XJER2BG.mjs +3486 -0
- package/dist/chunk-2XJER2BG.mjs.map +1 -0
- package/dist/elements.d.mts +72 -0
- package/dist/elements.d.ts +72 -0
- package/dist/elements.js +4577 -0
- package/dist/elements.js.map +1 -0
- package/dist/elements.mjs +1234 -0
- package/dist/elements.mjs.map +1 -0
- package/dist/react.d.mts +5 -0
- package/dist/react.d.ts +5 -0
- package/dist/react.js +558 -236
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +212 -3288
- package/dist/react.mjs.map +1 -1
- package/package.json +11 -2
|
@@ -0,0 +1,3486 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./chunk-6S5ODO6A.mjs";
|
|
4
|
+
|
|
5
|
+
// packages/ssml-editor-react/src/locales.ts
|
|
6
|
+
var EDITOR_COPY = {
|
|
7
|
+
ja: {
|
|
8
|
+
editorAriaLabel: "SSML\u30A8\u30C7\u30A3\u30BF\u30FC",
|
|
9
|
+
toolbarAriaLabel: "SSML\u30C4\u30FC\u30EB\u30D0\u30FC",
|
|
10
|
+
clearAll: "\u5168\u3066\u30AF\u30EA\u30A2",
|
|
11
|
+
clearAllTitle: "\u97F3\u58F0\u8A2D\u5B9A\u3092\u4FDD\u6301\u3057\u3066XML\u8981\u7D20\u3092\u524A\u9664\u3057\u672C\u6587\u3092\u6B8B\u3059",
|
|
12
|
+
undo: "\u5143\u306B\u623B\u3059",
|
|
13
|
+
undoTitle: "\u76F4\u524D\u306E\u5909\u66F4\u3092\u5143\u306B\u623B\u3059",
|
|
14
|
+
redo: "\u3084\u308A\u76F4\u3059",
|
|
15
|
+
redoTitle: "\u5143\u306B\u623B\u3057\u305F\u5909\u66F4\u3092\u3084\u308A\u76F4\u3059",
|
|
16
|
+
help: "\u8AAC\u660E",
|
|
17
|
+
helpTitle: "\u30DC\u30BF\u30F3\u3068\u30D1\u30E9\u30E1\u30FC\u30BF\u306E\u8AAC\u660E\u3092\u8868\u793A",
|
|
18
|
+
helpHeading: "\u30DC\u30BF\u30F3\u3068\u30D1\u30E9\u30E1\u30FC\u30BF\u306E\u8AAC\u660E",
|
|
19
|
+
helpDescription: "\u5404\u30B3\u30F3\u30C8\u30ED\u30FC\u30EB\u306E\u6A5F\u80FD\u3068\u30D1\u30E9\u30E1\u30FC\u30BF\u3092\u78BA\u8A8D\u3067\u304D\u307E\u3059\u3002",
|
|
20
|
+
parameters: "\u30D1\u30E9\u30E1\u30FC\u30BF",
|
|
21
|
+
format: "\u30D5\u30A9\u30FC\u30DE\u30C3\u30C8",
|
|
22
|
+
formatTitle: "\u672C\u6587\u306EXML\u3092\u6539\u884C\u3057\u3066\u898B\u3084\u3059\u304F\u8868\u793A",
|
|
23
|
+
decorations: "\u88C5\u98FE",
|
|
24
|
+
decorationsShowTitle: "\u30A4\u30F3\u30E9\u30A4\u30F3\u88C5\u98FE\u3092\u8868\u793A",
|
|
25
|
+
decorationsHideTitle: "\u30A4\u30F3\u30E9\u30A4\u30F3\u88C5\u98FE\u3092\u975E\u8868\u793A",
|
|
26
|
+
syntaxError: "\u69CB\u6587\u30A8\u30E9\u30FC",
|
|
27
|
+
selectionActions: "\u9078\u629E\u7BC4\u56F2\u306E\u64CD\u4F5C",
|
|
28
|
+
selectionCountSuffix: "\u6587\u5B57",
|
|
29
|
+
previewSelection: "\u9078\u629E\u90E8\u5206\u3092\u8A66\u8074",
|
|
30
|
+
previewSelectionTitle: "\u9078\u629E\u90E8\u5206\u306ESSML\u3092\u8A66\u8074",
|
|
31
|
+
noAvailableOptions: "\u5229\u7528\u53EF\u80FD\u306A\u9078\u629E\u80A2\u304C\u3042\u308A\u307E\u305B\u3093\u3002",
|
|
32
|
+
styleNotSupported: "\u3053\u306E\u97F3\u58F0\u306F\u30B9\u30BF\u30A4\u30EB\u6307\u5B9A\u306B\u5BFE\u5FDC\u3057\u3066\u3044\u307E\u305B\u3093",
|
|
33
|
+
categoryEmotions: "\u611F\u60C5\u30FB\u30C8\u30FC\u30F3",
|
|
34
|
+
categoryScenarios: "\u4F1A\u8A71\u30FB\u30B7\u30CA\u30EA\u30AA",
|
|
35
|
+
categoryMedia: "\u30E1\u30C7\u30A3\u30A2\u30FB\u30CA\u30EC\u30FC\u30B7\u30E7\u30F3",
|
|
36
|
+
categoryOther: "\u305D\u306E\u4ED6"
|
|
37
|
+
},
|
|
38
|
+
en: {
|
|
39
|
+
editorAriaLabel: "SSML editor",
|
|
40
|
+
toolbarAriaLabel: "SSML toolbar",
|
|
41
|
+
clearAll: "Clear all",
|
|
42
|
+
clearAllTitle: "Remove non-voice XML elements and keep the text and voice settings",
|
|
43
|
+
undo: "Undo",
|
|
44
|
+
undoTitle: "Undo the last change",
|
|
45
|
+
redo: "Redo",
|
|
46
|
+
redoTitle: "Redo the last undone change",
|
|
47
|
+
help: "Help",
|
|
48
|
+
helpTitle: "Show button and parameter descriptions",
|
|
49
|
+
helpHeading: "Button and parameter descriptions",
|
|
50
|
+
helpDescription: "Review what each control does and its parameters.",
|
|
51
|
+
parameters: "Parameters",
|
|
52
|
+
format: "Format",
|
|
53
|
+
formatTitle: "Format the XML in the editor",
|
|
54
|
+
decorations: "Decorations",
|
|
55
|
+
decorationsShowTitle: "Show inline decorations",
|
|
56
|
+
decorationsHideTitle: "Hide inline decorations",
|
|
57
|
+
syntaxError: "Syntax error",
|
|
58
|
+
selectionActions: "Selection actions",
|
|
59
|
+
selectionCountSuffix: " characters",
|
|
60
|
+
previewSelection: "Preview selection",
|
|
61
|
+
previewSelectionTitle: "Preview the selected SSML",
|
|
62
|
+
noAvailableOptions: "No options are available.",
|
|
63
|
+
styleNotSupported: "This voice does not support style selection.",
|
|
64
|
+
categoryEmotions: "Emotions / Tone",
|
|
65
|
+
categoryScenarios: "Conversations / Scenarios",
|
|
66
|
+
categoryMedia: "Media / Broadcast",
|
|
67
|
+
categoryOther: "Other"
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
var INLINE_BADGE_COPY = {
|
|
71
|
+
ja: {
|
|
72
|
+
pause: "\u9593",
|
|
73
|
+
pitch: "\u30D4\u30C3\u30C1\u5909\u5316",
|
|
74
|
+
prosody: "\u58F0\u306E\u8ABF\u6574"
|
|
75
|
+
},
|
|
76
|
+
en: {
|
|
77
|
+
pause: "Pause",
|
|
78
|
+
pitch: "Pitch change",
|
|
79
|
+
prosody: "Prosody"
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
var SSML_HOVER_COPY = {
|
|
83
|
+
ja: {
|
|
84
|
+
parameterHeading: "\u30D1\u30E9\u30E1\u30FC\u30BF",
|
|
85
|
+
parametersHeading: "\u30D1\u30E9\u30E1\u30FC\u30BF",
|
|
86
|
+
allowedValues: "\u4F7F\u7528\u3067\u304D\u308B\u5024",
|
|
87
|
+
example: "\u4F8B",
|
|
88
|
+
noParameters: "\u3053\u306E\u8981\u7D20\u306B\u30D1\u30E9\u30E1\u30FC\u30BF\u306F\u3042\u308A\u307E\u305B\u3093\u3002",
|
|
89
|
+
tags: {
|
|
90
|
+
voice: {
|
|
91
|
+
title: "\u97F3\u58F0",
|
|
92
|
+
description: "\u56F2\u307E\u308C\u305F\u30C6\u30AD\u30B9\u30C8\u306E\u5408\u6210\u306B\u4F7F\u7528\u3059\u308B\u97F3\u58F0\u3068\u3001\u4EFB\u610F\u306E\u97F3\u58F0\u52B9\u679C\u3092\u9078\u629E\u3057\u307E\u3059\u3002",
|
|
93
|
+
parameters: {
|
|
94
|
+
name: { title: "name", description: "\u97F3\u58F0\u540D\u3002\u4F8B: `en-US-JennyNeural`\u3002" },
|
|
95
|
+
effect: { title: "effect", description: "\u4EFB\u610F\u306E\u97F3\u58F0\u52B9\u679C\u3002\u4F8B: `eq_car`\u3002" }
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
prosody: {
|
|
99
|
+
title: "\u97FB\u5F8B",
|
|
100
|
+
description: "\u56F2\u307E\u308C\u305F\u30C6\u30AD\u30B9\u30C8\u306E\u901F\u5EA6\u3001\u30D4\u30C3\u30C1\u3001\u97F3\u91CF\u3001\u307E\u305F\u306F\u30D4\u30C3\u30C1\u66F2\u7DDA\u3092\u5909\u66F4\u3057\u307E\u3059\u3002",
|
|
101
|
+
parameters: {
|
|
102
|
+
rate: { title: "rate", description: "\u767A\u8A71\u901F\u5EA6\u3092\u6307\u5B9A\u3057\u307E\u3059\u3002" },
|
|
103
|
+
pitch: { title: "pitch", description: "\u540D\u524D\u4ED8\u304D\u306E\u5024\u3001\u5272\u5408\u3001\u5468\u6CE2\u6570\u3001\u307E\u305F\u306F\u534A\u97F3\u3067\u30D4\u30C3\u30C1\u3092\u8ABF\u6574\u3057\u307E\u3059\u3002" },
|
|
104
|
+
volume: { title: "volume", description: "\u540D\u524D\u4ED8\u304D\u306E\u5024\u3001\u5272\u5408\u3001\u307E\u305F\u306F\u30C7\u30B7\u30D9\u30EB\u5024\u3067\u97F3\u91CF\u3092\u6307\u5B9A\u3057\u307E\u3059\u3002" },
|
|
105
|
+
contour: { title: "contour", description: "\u30C6\u30AD\u30B9\u30C8\u5185\u306E\u4F4D\u7F6E\u3054\u3068\u306E\u76F8\u5BFE\u7684\u306A\u30D4\u30C3\u30C1\u5909\u5316\u3092\u5B9A\u7FA9\u3057\u307E\u3059\u3002" },
|
|
106
|
+
range: { title: "range", description: "\u97F3\u58F0\u306E\u30D4\u30C3\u30C1\u7BC4\u56F2\u3092\u8ABF\u6574\u3057\u307E\u3059\u3002" }
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
break: {
|
|
110
|
+
title: "\u9593",
|
|
111
|
+
description: "\u5358\u8A9E\u3084\u305D\u306E\u4ED6\u306E\u97F3\u58F0\u30B3\u30F3\u30C6\u30F3\u30C4\u306E\u9593\u306B\u30DD\u30FC\u30BA\u3092\u633F\u5165\u3057\u307E\u3059\u3002",
|
|
112
|
+
parameters: {
|
|
113
|
+
time: { title: "time", description: "\u30DD\u30FC\u30BA\u306E\u9577\u3055\u3002\u4F8B: `500ms` \u307E\u305F\u306F `1s`\u3002" },
|
|
114
|
+
strength: { title: "strength", description: "\u76F8\u5BFE\u7684\u306A\u30DD\u30FC\u30BA\u306E\u5F37\u3055\u3002" }
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
"mstts:express-as": {
|
|
118
|
+
title: "\u8868\u73FE",
|
|
119
|
+
description: "\u56F2\u307E\u308C\u305F\u30C6\u30AD\u30B9\u30C8\u306B\u97F3\u58F0\u30B9\u30BF\u30A4\u30EB\u3001\u30B9\u30BF\u30A4\u30EB\u306E\u5F37\u3055\u3001\u307E\u305F\u306F\u5F79\u5272\u3092\u9069\u7528\u3057\u307E\u3059\u3002",
|
|
120
|
+
parameters: {
|
|
121
|
+
style: { title: "style", description: "\u9078\u629E\u3057\u305F\u97F3\u58F0\u304C\u5BFE\u5FDC\u3059\u308B\u97F3\u58F0\u30B9\u30BF\u30A4\u30EB\u3002\u4F8B: `cheerful`\u3002" },
|
|
122
|
+
styledegree: { title: "styledegree", description: "\u9078\u629E\u3057\u305F\u97F3\u58F0\u30B9\u30BF\u30A4\u30EB\u306E\u5F37\u3055\u3092\u6307\u5B9A\u3057\u307E\u3059\u3002" },
|
|
123
|
+
role: { title: "role", description: "\u5BFE\u5FDC\u3057\u3066\u3044\u308B\u5834\u5408\u306B\u97F3\u58F0\u306E\u5F79\u5272\u3092\u5909\u66F4\u3057\u307E\u3059\u3002" }
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
"say-as": {
|
|
127
|
+
title: "\u8AAD\u307F\u4E0A\u3052\u65B9",
|
|
128
|
+
description: "\u56F2\u307E\u308C\u305F\u30C6\u30AD\u30B9\u30C8\u306E\u89E3\u91C8\u65B9\u6CD5\u3068\u8AAD\u307F\u4E0A\u3052\u65B9\u3092\u6307\u5B9A\u3057\u307E\u3059\u3002",
|
|
129
|
+
parameters: {
|
|
130
|
+
"interpret-as": { title: "interpret-as", description: "\u6587\u5B57\u3001\u6570\u5B57\u3001\u65E5\u4ED8\u3001\u6642\u523B\u306A\u3069\u306E\u89E3\u91C8\u3092\u6307\u5B9A\u3057\u307E\u3059\u3002" },
|
|
131
|
+
format: { title: "format", description: "\u9078\u629E\u3057\u305F\u89E3\u91C8\u306E\u5F62\u5F0F\u3092\u88DC\u8DB3\u3057\u307E\u3059\u3002" },
|
|
132
|
+
detail: { title: "detail", description: "\u9078\u629E\u3057\u305F\u89E3\u91C8\u306E\u8A73\u7D30\u3092\u88DC\u8DB3\u3057\u307E\u3059\u3002" }
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
phoneme: {
|
|
136
|
+
title: "\u97F3\u7D20",
|
|
137
|
+
description: "\u6307\u5B9A\u3057\u305F\u97F3\u7D20\u8868\u8A18\u3067\u901A\u5E38\u306E\u767A\u97F3\u3092\u7F6E\u304D\u63DB\u3048\u307E\u3059\u3002",
|
|
138
|
+
parameters: {
|
|
139
|
+
alphabet: { title: "alphabet", description: "`ph` \u5024\u306B\u4F7F\u7528\u3059\u308B\u97F3\u7D20\u30A2\u30EB\u30D5\u30A1\u30D9\u30C3\u30C8\u3002" },
|
|
140
|
+
ph: { title: "ph", description: "\u56F2\u307E\u308C\u305F\u30C6\u30AD\u30B9\u30C8\u306E\u97F3\u7D20\u8868\u8A18\u3002" }
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
emphasis: {
|
|
144
|
+
title: "\u5F37\u8ABF",
|
|
145
|
+
description: "\u56F2\u307E\u308C\u305F\u30C6\u30AD\u30B9\u30C8\u3092\u5F37\u8ABF\u3057\u307E\u3059\u3002",
|
|
146
|
+
parameters: {
|
|
147
|
+
level: { title: "level", description: "\u5F37\u8ABF\u306E\u5EA6\u5408\u3044\u3092\u6307\u5B9A\u3057\u307E\u3059\u3002" }
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
audio: {
|
|
151
|
+
title: "\u97F3\u58F0\u30D5\u30A1\u30A4\u30EB",
|
|
152
|
+
description: "\u5408\u6210\u7D50\u679C\u306E\u4E00\u90E8\u3068\u3057\u3066\u97F3\u58F0\u30D5\u30A1\u30A4\u30EB\u3092\u518D\u751F\u3057\u307E\u3059\u3002",
|
|
153
|
+
parameters: {
|
|
154
|
+
src: { title: "src", description: "\u97F3\u58F0\u30D5\u30A1\u30A4\u30EB\u306E URI\u3002" },
|
|
155
|
+
desc: { title: "desc", description: "\u97F3\u58F0\u3092\u518D\u751F\u3067\u304D\u306A\u3044\u5834\u5408\u306B\u4F7F\u7528\u3059\u308B\u4EE3\u66FF\u30C6\u30AD\u30B9\u30C8\u3002" },
|
|
156
|
+
clipBegin: { title: "clipBegin", description: "\u97F3\u58F0\u30D5\u30A1\u30A4\u30EB\u5185\u306E\u958B\u59CB\u4F4D\u7F6E\u3002\u4F8B: `0s`\u3002" },
|
|
157
|
+
clipEnd: { title: "clipEnd", description: "\u97F3\u58F0\u30D5\u30A1\u30A4\u30EB\u5185\u306E\u7D42\u4E86\u4F4D\u7F6E\u3002\u4F8B: `5s`\u3002" },
|
|
158
|
+
speed: { title: "speed", description: "\u97F3\u58F0\u30D5\u30A1\u30A4\u30EB\u306E\u518D\u751F\u901F\u5EA6\u3002\u4F8B: `1.0`\u3002" },
|
|
159
|
+
repeatCount: { title: "repeatCount", description: "\u97F3\u58F0\u3092\u7E70\u308A\u8FD4\u3059\u56DE\u6570\u3002\u4F8B: `2`\u3002" },
|
|
160
|
+
repeatDuration: { title: "repeatDuration", description: "\u97F3\u58F0\u3092\u7E70\u308A\u8FD4\u3059\u5408\u8A08\u6642\u9593\u3002\u4F8B: `10s`\u3002" },
|
|
161
|
+
soundLevel: { title: "soundLevel", description: "\u30C7\u30B7\u30D9\u30EB\u5358\u4F4D\u306E\u97F3\u91CF\u8ABF\u6574\u3002\u4F8B: `-3dB`\u3002" }
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
sub: {
|
|
165
|
+
title: "\u7F6E\u63DB",
|
|
166
|
+
description: "\u56F2\u307E\u308C\u305F\u30C6\u30AD\u30B9\u30C8\u306E\u4EE3\u308F\u308A\u306B\u5225\u540D\u30C6\u30AD\u30B9\u30C8\u3092\u8AAD\u307F\u4E0A\u3052\u307E\u3059\u3002",
|
|
167
|
+
parameters: {
|
|
168
|
+
alias: { title: "alias", description: "\u5143\u306E\u30C6\u30AD\u30B9\u30C8\u306E\u4EE3\u308F\u308A\u306B\u8AAD\u307F\u4E0A\u3052\u308B\u30C6\u30AD\u30B9\u30C8\u3002\u4F8B: `World Wide Web`\u3002" }
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
lang: {
|
|
172
|
+
title: "\u8A00\u8A9E",
|
|
173
|
+
description: "\u56F2\u307E\u308C\u305F\u30C6\u30AD\u30B9\u30C8\u306E\u8AAD\u307F\u4E0A\u3052\u8A00\u8A9E\u3092\u5909\u66F4\u3057\u307E\u3059\u3002",
|
|
174
|
+
parameters: {
|
|
175
|
+
"xml:lang": { title: "xml:lang", description: "BCP-47 \u8A00\u8A9E\u30BF\u30B0\u3002\u4F8B: `ja-JP`\u3002" }
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
mark: {
|
|
179
|
+
title: "\u30DE\u30FC\u30AB\u30FC",
|
|
180
|
+
description: "\u5408\u6210\u97F3\u58F0\u30B9\u30C8\u30EA\u30FC\u30E0\u306B\u30AB\u30B9\u30BF\u30E0\u30DE\u30FC\u30AB\u30FC\u3092\u633F\u5165\u3057\u307E\u3059\u3002",
|
|
181
|
+
parameters: {
|
|
182
|
+
name: { title: "name", description: "\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u3067\u5B9A\u7FA9\u3057\u305F\u30DE\u30FC\u30AB\u30FC\u540D\u3002\u4F8B: `chapter-1`\u3002" }
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
bookmark: {
|
|
186
|
+
title: "\u30D6\u30C3\u30AF\u30DE\u30FC\u30AF",
|
|
187
|
+
description: "\u5408\u6210\u97F3\u58F0\u30B9\u30C8\u30EA\u30FC\u30E0\u306B\u30D6\u30C3\u30AF\u30DE\u30FC\u30AF\u30DE\u30FC\u30AB\u30FC\u3092\u633F\u5165\u3057\u307E\u3059\u3002",
|
|
188
|
+
parameters: {
|
|
189
|
+
mark: { title: "mark", description: "\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u3067\u5B9A\u7FA9\u3057\u305F\u30D6\u30C3\u30AF\u30DE\u30FC\u30AF\u540D\u3002\u4F8B: `chapter-1`\u3002" }
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
lexicon: {
|
|
193
|
+
title: "\u767A\u97F3\u8F9E\u66F8",
|
|
194
|
+
description: "\u5408\u6210\u6587\u66F8\u306B\u767A\u97F3\u8F9E\u66F8\u3092\u95A2\u9023\u4ED8\u3051\u307E\u3059\u3002",
|
|
195
|
+
parameters: {
|
|
196
|
+
uri: { title: "uri", description: "\u767A\u97F3\u8F9E\u66F8\u306E URI\u3002" }
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
p: { title: "\u6BB5\u843D", description: "\u30C6\u30AD\u30B9\u30C8\u3092\u6BB5\u843D\u3068\u3057\u3066\u307E\u3068\u3081\u307E\u3059\u3002", parameters: {} },
|
|
200
|
+
s: { title: "\u6587", description: "\u30C6\u30AD\u30B9\u30C8\u3092\u6587\u3068\u3057\u3066\u307E\u3068\u3081\u307E\u3059\u3002", parameters: {} },
|
|
201
|
+
w: { title: "\u5358\u8A9E", description: "\u30C6\u30AD\u30B9\u30C8\u3092\u5358\u8A9E\u3068\u3057\u3066\u307E\u3068\u3081\u307E\u3059\u3002", parameters: {} },
|
|
202
|
+
"mstts:silence": {
|
|
203
|
+
title: "\u7121\u97F3",
|
|
204
|
+
description: "\u30C6\u30AD\u30B9\u30C8\u306E\u524D\u5F8C\u3001\u307E\u305F\u306F\u53E5\u8AAD\u70B9\u306E\u5883\u754C\u306B\u6307\u5B9A\u3057\u305F\u7121\u97F3\u3092\u8FFD\u52A0\u3057\u307E\u3059\u3002",
|
|
205
|
+
parameters: {
|
|
206
|
+
type: { title: "type", description: "\u7121\u97F3\u306E\u4F4D\u7F6E\u307E\u305F\u306F\u53E5\u8AAD\u70B9\u306E\u5883\u754C\u3002" },
|
|
207
|
+
value: { title: "value", description: "\u7121\u97F3\u306E\u9577\u3055\u3002\u4F8B: `300ms`\u3002" }
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
"mstts:viseme": {
|
|
211
|
+
title: "\u30D3\u30BC\u30FC\u30E0",
|
|
212
|
+
description: "\u5408\u6210\u97F3\u58F0\u306E\u30D3\u30BC\u30FC\u30E0\u30A4\u30D9\u30F3\u30C8\u3092\u8981\u6C42\u3057\u307E\u3059\u3002",
|
|
213
|
+
parameters: {
|
|
214
|
+
type: { title: "type", description: "\u30D3\u30BC\u30FC\u30E0\u30A4\u30D9\u30F3\u30C8\u306E\u5F62\u5F0F\u3002" }
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
en: {
|
|
220
|
+
parameterHeading: "Parameter",
|
|
221
|
+
parametersHeading: "Parameters",
|
|
222
|
+
allowedValues: "Allowed values",
|
|
223
|
+
example: "Example",
|
|
224
|
+
noParameters: "This element has no parameters.",
|
|
225
|
+
tags: {
|
|
226
|
+
voice: {
|
|
227
|
+
title: "Voice",
|
|
228
|
+
description: "Selects the voice and optional voice effect used to synthesize the enclosed text.",
|
|
229
|
+
parameters: {
|
|
230
|
+
name: { title: "name", description: "The voice name, such as `en-US-JennyNeural`." },
|
|
231
|
+
effect: { title: "effect", description: "An optional voice effect, such as `eq_car`." }
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
prosody: {
|
|
235
|
+
title: "Prosody",
|
|
236
|
+
description: "Changes the speaking rate, pitch, volume, or pitch contour of the enclosed text.",
|
|
237
|
+
parameters: {
|
|
238
|
+
rate: { title: "rate", description: "Controls speaking speed." },
|
|
239
|
+
pitch: {
|
|
240
|
+
title: "pitch",
|
|
241
|
+
description: "Adjusts pitch using a named value, percentage, frequency, or semitone value."
|
|
242
|
+
},
|
|
243
|
+
volume: {
|
|
244
|
+
title: "volume",
|
|
245
|
+
description: "Controls loudness using a named value, percentage, or decibel value."
|
|
246
|
+
},
|
|
247
|
+
contour: {
|
|
248
|
+
title: "contour",
|
|
249
|
+
description: "Defines a sequence of relative pitch changes at positions in the text."
|
|
250
|
+
},
|
|
251
|
+
range: { title: "range", description: "Adjusts the pitch range of the voice." }
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
break: {
|
|
255
|
+
title: "Break",
|
|
256
|
+
description: "Inserts a pause between words or other spoken content.",
|
|
257
|
+
parameters: {
|
|
258
|
+
time: { title: "time", description: "The pause duration, for example `500ms` or `1s`." },
|
|
259
|
+
strength: { title: "strength", description: "The relative pause strength." }
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
"mstts:express-as": {
|
|
263
|
+
title: "Express-as",
|
|
264
|
+
description: "Applies a speaking style, style degree, or role to the enclosed text.",
|
|
265
|
+
parameters: {
|
|
266
|
+
style: {
|
|
267
|
+
title: "style",
|
|
268
|
+
description: "The speaking style supported by the selected voice, such as `cheerful`."
|
|
269
|
+
},
|
|
270
|
+
styledegree: { title: "styledegree", description: "Controls the intensity of the selected speaking style." },
|
|
271
|
+
role: { title: "role", description: "Changes the speaking role when supported by the selected voice." }
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
"say-as": {
|
|
275
|
+
title: "Say-as",
|
|
276
|
+
description: "Controls how the enclosed text is interpreted and spoken.",
|
|
277
|
+
parameters: {
|
|
278
|
+
"interpret-as": {
|
|
279
|
+
title: "interpret-as",
|
|
280
|
+
description: "Specifies the interpretation, such as characters, digits, date, or time."
|
|
281
|
+
},
|
|
282
|
+
format: { title: "format", description: "Provides a format hint for the selected interpretation." },
|
|
283
|
+
detail: {
|
|
284
|
+
title: "detail",
|
|
285
|
+
description: "Provides an additional detail hint for the selected interpretation."
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
phoneme: {
|
|
290
|
+
title: "Phoneme",
|
|
291
|
+
description: "Replaces normal pronunciation with the supplied phonetic pronunciation.",
|
|
292
|
+
parameters: {
|
|
293
|
+
alphabet: { title: "alphabet", description: "The phonetic alphabet used by the `ph` value." },
|
|
294
|
+
ph: { title: "ph", description: "The phonetic pronunciation for the enclosed text." }
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
emphasis: {
|
|
298
|
+
title: "Emphasis",
|
|
299
|
+
description: "Adds emphasis to the enclosed text.",
|
|
300
|
+
parameters: {
|
|
301
|
+
level: { title: "level", description: "Controls the amount of emphasis." }
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
audio: {
|
|
305
|
+
title: "Audio",
|
|
306
|
+
description: "Plays an audio file as part of the synthesized output.",
|
|
307
|
+
parameters: {
|
|
308
|
+
src: { title: "src", description: "The URI of the audio file." },
|
|
309
|
+
desc: { title: "desc", description: "Alternative text to use if the audio cannot be played." },
|
|
310
|
+
clipBegin: { title: "clipBegin", description: "The starting offset within the audio file." },
|
|
311
|
+
clipEnd: { title: "clipEnd", description: "The ending offset within the audio file." },
|
|
312
|
+
speed: { title: "speed", description: "The playback speed of the audio file." },
|
|
313
|
+
repeatCount: { title: "repeatCount", description: "The number of times to repeat the audio." },
|
|
314
|
+
repeatDuration: {
|
|
315
|
+
title: "repeatDuration",
|
|
316
|
+
description: "The total duration for which the audio may repeat."
|
|
317
|
+
},
|
|
318
|
+
soundLevel: { title: "soundLevel", description: "The audio volume adjustment in decibels." }
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
sub: {
|
|
322
|
+
title: "Substitution",
|
|
323
|
+
description: "Substitutes the alias text when speaking the enclosed text.",
|
|
324
|
+
parameters: {
|
|
325
|
+
alias: { title: "alias", description: "The text to speak instead of the enclosed text." }
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
lang: {
|
|
329
|
+
title: "Language",
|
|
330
|
+
description: "Changes the language used for the enclosed text.",
|
|
331
|
+
parameters: {
|
|
332
|
+
"xml:lang": { title: "xml:lang", description: "The BCP-47 language tag." }
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
mark: {
|
|
336
|
+
title: "Mark",
|
|
337
|
+
description: "Inserts a custom marker into the synthesized audio stream.",
|
|
338
|
+
parameters: {
|
|
339
|
+
name: { title: "name", description: "The application-defined marker name." }
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
bookmark: {
|
|
343
|
+
title: "Bookmark",
|
|
344
|
+
description: "Inserts a bookmark marker into the synthesized audio stream.",
|
|
345
|
+
parameters: {
|
|
346
|
+
mark: { title: "mark", description: "The application-defined bookmark name." }
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
lexicon: {
|
|
350
|
+
title: "Lexicon",
|
|
351
|
+
description: "Associates a pronunciation lexicon with the synthesized document.",
|
|
352
|
+
parameters: {
|
|
353
|
+
uri: { title: "uri", description: "The URI of the pronunciation lexicon." }
|
|
354
|
+
}
|
|
355
|
+
},
|
|
356
|
+
p: { title: "Paragraph", description: "Groups text into a paragraph.", parameters: {} },
|
|
357
|
+
s: { title: "Sentence", description: "Groups text into a sentence.", parameters: {} },
|
|
358
|
+
w: { title: "Word", description: "Groups text into a word.", parameters: {} },
|
|
359
|
+
"mstts:silence": {
|
|
360
|
+
title: "Silence",
|
|
361
|
+
description: "Adds a specified silence before or after text or at a punctuation boundary.",
|
|
362
|
+
parameters: {
|
|
363
|
+
type: { title: "type", description: "The silence position or punctuation boundary." },
|
|
364
|
+
value: { title: "value", description: "The silence duration, for example `300ms`." }
|
|
365
|
+
}
|
|
366
|
+
},
|
|
367
|
+
"mstts:viseme": {
|
|
368
|
+
title: "Viseme",
|
|
369
|
+
description: "Requests viseme events for the synthesized audio.",
|
|
370
|
+
parameters: {
|
|
371
|
+
type: { title: "type", description: "The viseme event format." }
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
// packages/ssml-editor-react/src/constants/ssmlPresets.ts
|
|
379
|
+
var ssmlPresets_exports = {};
|
|
380
|
+
__export(ssmlPresets_exports, {
|
|
381
|
+
BREAK_STRENGTH_PRESETS: () => BREAK_STRENGTH_PRESETS,
|
|
382
|
+
BREAK_TIME_DESCRIPTIONS: () => BREAK_TIME_DESCRIPTIONS,
|
|
383
|
+
BREAK_TIME_PRESETS: () => BREAK_TIME_PRESETS,
|
|
384
|
+
EMPHASIS_LEVEL_DESCRIPTIONS: () => EMPHASIS_LEVEL_DESCRIPTIONS,
|
|
385
|
+
EMPHASIS_LEVEL_PRESETS: () => EMPHASIS_LEVEL_PRESETS,
|
|
386
|
+
EXPRESS_AS_ROLE_PRESETS: () => EXPRESS_AS_ROLE_PRESETS,
|
|
387
|
+
EXPRESS_AS_STYLE_CATEGORIES: () => EXPRESS_AS_STYLE_CATEGORIES,
|
|
388
|
+
EXPRESS_AS_STYLE_DESCRIPTIONS: () => EXPRESS_AS_STYLE_DESCRIPTIONS,
|
|
389
|
+
EXPRESS_AS_STYLE_PRESETS: () => EXPRESS_AS_STYLE_PRESETS,
|
|
390
|
+
LANGUAGE_DESCRIPTIONS: () => LANGUAGE_DESCRIPTIONS,
|
|
391
|
+
LANGUAGE_PRESETS: () => LANGUAGE_PRESETS,
|
|
392
|
+
PHONEME_ALPHABET_PRESETS: () => PHONEME_ALPHABET_PRESETS,
|
|
393
|
+
PROSODY_PITCH_DESCRIPTIONS: () => PROSODY_PITCH_DESCRIPTIONS,
|
|
394
|
+
PROSODY_PITCH_PRESETS: () => PROSODY_PITCH_PRESETS,
|
|
395
|
+
PROSODY_RATE_DESCRIPTIONS: () => PROSODY_RATE_DESCRIPTIONS,
|
|
396
|
+
PROSODY_RATE_PRESETS: () => PROSODY_RATE_PRESETS,
|
|
397
|
+
PROSODY_RATE_VALUES: () => PROSODY_RATE_VALUES,
|
|
398
|
+
PROSODY_VOLUME_DESCRIPTIONS: () => PROSODY_VOLUME_DESCRIPTIONS,
|
|
399
|
+
PROSODY_VOLUME_PRESETS: () => PROSODY_VOLUME_PRESETS,
|
|
400
|
+
SAY_AS_DESCRIPTIONS: () => SAY_AS_DESCRIPTIONS,
|
|
401
|
+
SAY_AS_PRESETS: () => SAY_AS_PRESETS,
|
|
402
|
+
SILENCE_TYPE_PRESETS: () => SILENCE_TYPE_PRESETS,
|
|
403
|
+
SILENCE_VALUE_DESCRIPTIONS: () => SILENCE_VALUE_DESCRIPTIONS,
|
|
404
|
+
SILENCE_VALUE_PRESETS: () => SILENCE_VALUE_PRESETS,
|
|
405
|
+
SSML_ATTRIBUTE_PRESETS: () => SSML_ATTRIBUTE_PRESETS,
|
|
406
|
+
SSML_PRESETS: () => SSML_PRESETS,
|
|
407
|
+
SSML_PRESET_EXAMPLES: () => SSML_PRESET_EXAMPLES,
|
|
408
|
+
VISEME_TYPE_PRESETS: () => VISEME_TYPE_PRESETS,
|
|
409
|
+
VOICE_STYLE_MAP: () => VOICE_STYLE_MAP,
|
|
410
|
+
getExpressAsStyleCategory: () => getExpressAsStyleCategory,
|
|
411
|
+
resolveExpressAsStyles: () => resolveExpressAsStyles
|
|
412
|
+
});
|
|
413
|
+
var SSML_PRESETS = [
|
|
414
|
+
{
|
|
415
|
+
id: "basic",
|
|
416
|
+
label: "Basic speech",
|
|
417
|
+
ssml: '<speak version="1.0" xml:lang="en-US">Hello, world!</speak>',
|
|
418
|
+
description: "A minimal SSML document."
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
id: "voice",
|
|
422
|
+
label: "Voice selection",
|
|
423
|
+
ssml: '<speak version="1.0" xml:lang="en-US"><voice name="en-US-JennyNeural">Hello, world!</voice></speak>',
|
|
424
|
+
description: "Speaks text with a selected voice."
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
id: "prosody",
|
|
428
|
+
label: "Prosody",
|
|
429
|
+
ssml: '<speak version="1.0" xml:lang="en-US"><prosody rate="fast" pitch="+2st">Hello, world!</prosody></speak>',
|
|
430
|
+
description: "Adjusts the speech rate and pitch."
|
|
431
|
+
}
|
|
432
|
+
];
|
|
433
|
+
var BREAK_TIME_PRESETS = ["500ms", "1s", "2s", "3s"];
|
|
434
|
+
var BREAK_STRENGTH_PRESETS = ["none", "x-weak", "weak", "medium", "strong", "x-strong"];
|
|
435
|
+
var PROSODY_RATE_PRESETS = ["x-slow", "slow", "medium", "fast", "x-fast"];
|
|
436
|
+
var PROSODY_RATE_VALUES = [...PROSODY_RATE_PRESETS, "percentage"];
|
|
437
|
+
var PROSODY_PITCH_PRESETS = ["+2st", "-2st", "0st", "+4st", "-4st", "+8st", "-8st", "+12st", "-12st"];
|
|
438
|
+
var PROSODY_VOLUME_PRESETS = ["silent", "x-soft", "soft", "medium", "loud", "x-loud"];
|
|
439
|
+
var EXPRESS_AS_STYLE_PRESETS = [
|
|
440
|
+
"cheerful",
|
|
441
|
+
"friendly",
|
|
442
|
+
"calm",
|
|
443
|
+
"sad",
|
|
444
|
+
"angry",
|
|
445
|
+
"excited",
|
|
446
|
+
"serious",
|
|
447
|
+
"assistant",
|
|
448
|
+
"chat",
|
|
449
|
+
"customerservice",
|
|
450
|
+
"hopeful",
|
|
451
|
+
"newscast",
|
|
452
|
+
"shouting",
|
|
453
|
+
"terrified",
|
|
454
|
+
"unfriendly",
|
|
455
|
+
"whispering",
|
|
456
|
+
"empathetic",
|
|
457
|
+
"relieved",
|
|
458
|
+
"fearful",
|
|
459
|
+
"depressed",
|
|
460
|
+
"disgruntled",
|
|
461
|
+
"embarrassed",
|
|
462
|
+
"narration-relaxed",
|
|
463
|
+
"poetry-reading",
|
|
464
|
+
"sports_commentary",
|
|
465
|
+
"sports_commentary_excited",
|
|
466
|
+
"story"
|
|
467
|
+
];
|
|
468
|
+
var EXPRESS_AS_STYLE_CATEGORIES = {
|
|
469
|
+
emotions: [
|
|
470
|
+
"cheerful",
|
|
471
|
+
"sad",
|
|
472
|
+
"angry",
|
|
473
|
+
"calm",
|
|
474
|
+
"fearful",
|
|
475
|
+
"depressed",
|
|
476
|
+
"disgruntled",
|
|
477
|
+
"embarrassed",
|
|
478
|
+
"empathetic",
|
|
479
|
+
"envious",
|
|
480
|
+
"excited",
|
|
481
|
+
"friendly",
|
|
482
|
+
"gentle",
|
|
483
|
+
"hopeful",
|
|
484
|
+
"relieved",
|
|
485
|
+
"serious",
|
|
486
|
+
"shouting",
|
|
487
|
+
"terrified",
|
|
488
|
+
"unfriendly",
|
|
489
|
+
"whispering"
|
|
490
|
+
],
|
|
491
|
+
scenarios: ["chat", "customerservice", "assistant", "livecommercial", "poetry-reading", "story"],
|
|
492
|
+
media: [
|
|
493
|
+
"newscast",
|
|
494
|
+
"newscast-casual",
|
|
495
|
+
"newscast-formal",
|
|
496
|
+
"narration-professional",
|
|
497
|
+
"narration-relaxed",
|
|
498
|
+
"documentary-narration",
|
|
499
|
+
"advertisement_upbeat",
|
|
500
|
+
"sports_commentary",
|
|
501
|
+
"sports_commentary_excited"
|
|
502
|
+
]
|
|
503
|
+
};
|
|
504
|
+
function getExpressAsStyleCategory(style) {
|
|
505
|
+
for (const [category, styles] of Object.entries(EXPRESS_AS_STYLE_CATEGORIES)) {
|
|
506
|
+
if (styles.includes(style)) {
|
|
507
|
+
return category;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
return "other";
|
|
511
|
+
}
|
|
512
|
+
var VOICE_STYLE_MAP = {
|
|
513
|
+
"ja-JP-MayuNeural": ["calm", "cheerful", "sad"],
|
|
514
|
+
"ja-JP-KeitaNeural": ["chat"],
|
|
515
|
+
"ja-JP-NanamiNeural": ["chat", "customerservice", "cheerful", "whispering", "sad"],
|
|
516
|
+
"en-US-JennyMultilingualNeural": [
|
|
517
|
+
"cheerful",
|
|
518
|
+
"empathetic",
|
|
519
|
+
"excited",
|
|
520
|
+
"friendly",
|
|
521
|
+
"hopeful",
|
|
522
|
+
"sad",
|
|
523
|
+
"shouting",
|
|
524
|
+
"terrified",
|
|
525
|
+
"unfriendly",
|
|
526
|
+
"whispering"
|
|
527
|
+
],
|
|
528
|
+
"en-US-AndrewNeural": ["empathetic", "relieved"],
|
|
529
|
+
"en-US-JennyNeural": [
|
|
530
|
+
"assistant",
|
|
531
|
+
"chat",
|
|
532
|
+
"customerservice",
|
|
533
|
+
"newscast",
|
|
534
|
+
"cheerful",
|
|
535
|
+
"empathetic",
|
|
536
|
+
"excited",
|
|
537
|
+
"friendly",
|
|
538
|
+
"hopeful",
|
|
539
|
+
"sad",
|
|
540
|
+
"shouting",
|
|
541
|
+
"terrified",
|
|
542
|
+
"unfriendly",
|
|
543
|
+
"whispering"
|
|
544
|
+
],
|
|
545
|
+
"en-US-GuyNeural": [
|
|
546
|
+
"angry",
|
|
547
|
+
"cheerful",
|
|
548
|
+
"excited",
|
|
549
|
+
"friendly",
|
|
550
|
+
"hopeful",
|
|
551
|
+
"newscast",
|
|
552
|
+
"sad",
|
|
553
|
+
"shouting",
|
|
554
|
+
"terrified",
|
|
555
|
+
"unfriendly",
|
|
556
|
+
"whispering"
|
|
557
|
+
],
|
|
558
|
+
"ko-KR-SunHiNeural": ["cheerful", "sad"],
|
|
559
|
+
"zh-CN-XiaoxiaoNeural": [
|
|
560
|
+
"assistant",
|
|
561
|
+
"chat",
|
|
562
|
+
"customerservice",
|
|
563
|
+
"newscast",
|
|
564
|
+
"cheerful",
|
|
565
|
+
"empathetic",
|
|
566
|
+
"excited",
|
|
567
|
+
"friendly",
|
|
568
|
+
"hopeful",
|
|
569
|
+
"sad",
|
|
570
|
+
"terrified",
|
|
571
|
+
"whispering",
|
|
572
|
+
"poetry-reading",
|
|
573
|
+
"sports_commentary",
|
|
574
|
+
"sports_commentary_excited",
|
|
575
|
+
"story"
|
|
576
|
+
],
|
|
577
|
+
"zh-CN-YunxiNeural": [
|
|
578
|
+
"narration-relaxed",
|
|
579
|
+
"embarrassed",
|
|
580
|
+
"fearful",
|
|
581
|
+
"sad",
|
|
582
|
+
"disgruntled",
|
|
583
|
+
"serious",
|
|
584
|
+
"angry",
|
|
585
|
+
"depressed",
|
|
586
|
+
"chat",
|
|
587
|
+
"cheerful",
|
|
588
|
+
"assistant"
|
|
589
|
+
],
|
|
590
|
+
"fr-FR-DeniseNeural": ["cheerful", "sad"],
|
|
591
|
+
"fr-FR-HenriNeural": ["cheerful", "sad"],
|
|
592
|
+
"pt-BR-FranciscaNeural": ["calm"],
|
|
593
|
+
"it-IT-ElsaNeural": ["cheerful", "sad"],
|
|
594
|
+
"de-DE-KatjaNeural": ["cheerful", "sad"],
|
|
595
|
+
"de-DE-ConradNeural": ["cheerful", "sad"],
|
|
596
|
+
"ru-RU-SvetlanaNeural": ["cheerful", "sad", "angry", "disgruntled", "embarrassed", "fearful"]
|
|
597
|
+
};
|
|
598
|
+
var VOICE_STYLE_MAP_BY_NORMALIZED_NAME = new Map(
|
|
599
|
+
Object.entries(VOICE_STYLE_MAP).map(([voiceName, styles]) => [voiceName.toLowerCase(), styles])
|
|
600
|
+
);
|
|
601
|
+
function resolveExpressAsStyles(voiceName, candidates = EXPRESS_AS_STYLE_PRESETS) {
|
|
602
|
+
const normalizedVoiceName = voiceName?.trim().toLowerCase();
|
|
603
|
+
if (!normalizedVoiceName) {
|
|
604
|
+
return candidates;
|
|
605
|
+
}
|
|
606
|
+
const supportedStyles = VOICE_STYLE_MAP_BY_NORMALIZED_NAME.get(normalizedVoiceName);
|
|
607
|
+
if (supportedStyles === void 0) {
|
|
608
|
+
return [];
|
|
609
|
+
}
|
|
610
|
+
const supportedStyleSet = new Set(supportedStyles);
|
|
611
|
+
return candidates.filter((style) => supportedStyleSet.has(style));
|
|
612
|
+
}
|
|
613
|
+
var EXPRESS_AS_ROLE_PRESETS = [
|
|
614
|
+
"Girl",
|
|
615
|
+
"Boy",
|
|
616
|
+
"YoungAdultFemale",
|
|
617
|
+
"YoungAdultMale",
|
|
618
|
+
"OlderAdultFemale",
|
|
619
|
+
"OlderAdultMale",
|
|
620
|
+
"SeniorFemale",
|
|
621
|
+
"SeniorMale"
|
|
622
|
+
];
|
|
623
|
+
var EMPHASIS_LEVEL_PRESETS = ["strong", "moderate", "reduced", "none"];
|
|
624
|
+
var SAY_AS_PRESETS = [
|
|
625
|
+
"characters",
|
|
626
|
+
"spell-out",
|
|
627
|
+
"cardinal",
|
|
628
|
+
"ordinal",
|
|
629
|
+
"number",
|
|
630
|
+
"date",
|
|
631
|
+
"time",
|
|
632
|
+
"telephone",
|
|
633
|
+
"fraction",
|
|
634
|
+
"address",
|
|
635
|
+
"name",
|
|
636
|
+
"currency"
|
|
637
|
+
];
|
|
638
|
+
var LANGUAGE_PRESETS = ["ja-JP", "en-US", "de-DE", "fr-FR"];
|
|
639
|
+
var SILENCE_VALUE_PRESETS = ["300ms", "500ms", "1s"];
|
|
640
|
+
var SILENCE_TYPE_PRESETS = [
|
|
641
|
+
"Leading",
|
|
642
|
+
"Tailing",
|
|
643
|
+
"Sentenceboundary",
|
|
644
|
+
"Comma",
|
|
645
|
+
"Semicolon",
|
|
646
|
+
"Enumerationcomma"
|
|
647
|
+
];
|
|
648
|
+
var PHONEME_ALPHABET_PRESETS = ["ipa", "sapi", "ups", "x-sampa"];
|
|
649
|
+
var VISEME_TYPE_PRESETS = ["redlips_front", "FacialExpression"];
|
|
650
|
+
var SSML_ATTRIBUTE_PRESETS = {
|
|
651
|
+
break: {
|
|
652
|
+
strength: BREAK_STRENGTH_PRESETS,
|
|
653
|
+
time: BREAK_TIME_PRESETS
|
|
654
|
+
},
|
|
655
|
+
prosody: {
|
|
656
|
+
rate: PROSODY_RATE_PRESETS,
|
|
657
|
+
pitch: PROSODY_PITCH_PRESETS,
|
|
658
|
+
volume: PROSODY_VOLUME_PRESETS
|
|
659
|
+
},
|
|
660
|
+
"mstts:express-as": {
|
|
661
|
+
style: EXPRESS_AS_STYLE_PRESETS,
|
|
662
|
+
role: EXPRESS_AS_ROLE_PRESETS
|
|
663
|
+
},
|
|
664
|
+
"express-as": {
|
|
665
|
+
style: EXPRESS_AS_STYLE_PRESETS,
|
|
666
|
+
role: EXPRESS_AS_ROLE_PRESETS
|
|
667
|
+
},
|
|
668
|
+
expressAs: {
|
|
669
|
+
style: EXPRESS_AS_STYLE_PRESETS,
|
|
670
|
+
role: EXPRESS_AS_ROLE_PRESETS
|
|
671
|
+
},
|
|
672
|
+
"say-as": {
|
|
673
|
+
"interpret-as": SAY_AS_PRESETS
|
|
674
|
+
},
|
|
675
|
+
sayAs: {
|
|
676
|
+
"interpret-as": SAY_AS_PRESETS
|
|
677
|
+
},
|
|
678
|
+
emphasis: {
|
|
679
|
+
level: EMPHASIS_LEVEL_PRESETS
|
|
680
|
+
},
|
|
681
|
+
lang: {
|
|
682
|
+
"xml:lang": LANGUAGE_PRESETS
|
|
683
|
+
},
|
|
684
|
+
phoneme: {
|
|
685
|
+
alphabet: PHONEME_ALPHABET_PRESETS
|
|
686
|
+
},
|
|
687
|
+
"mstts:silence": {
|
|
688
|
+
type: SILENCE_TYPE_PRESETS,
|
|
689
|
+
value: SILENCE_VALUE_PRESETS
|
|
690
|
+
},
|
|
691
|
+
silence: {
|
|
692
|
+
type: SILENCE_TYPE_PRESETS,
|
|
693
|
+
value: SILENCE_VALUE_PRESETS
|
|
694
|
+
},
|
|
695
|
+
"mstts:viseme": {
|
|
696
|
+
type: VISEME_TYPE_PRESETS
|
|
697
|
+
},
|
|
698
|
+
viseme: {
|
|
699
|
+
type: VISEME_TYPE_PRESETS
|
|
700
|
+
}
|
|
701
|
+
};
|
|
702
|
+
var SSML_PRESET_EXAMPLES = {
|
|
703
|
+
breakTime: "500ms",
|
|
704
|
+
prosodyRate: "fast",
|
|
705
|
+
prosodyPitch: "+2st",
|
|
706
|
+
prosodyVolume: "loud",
|
|
707
|
+
expressAsStyle: "cheerful",
|
|
708
|
+
phonemeAlphabet: "ipa",
|
|
709
|
+
silenceValue: "300ms"
|
|
710
|
+
};
|
|
711
|
+
var BREAK_TIME_DESCRIPTIONS = {
|
|
712
|
+
"500ms": {
|
|
713
|
+
ja: "500\u30DF\u30EA\u79D2\u306E\u7121\u97F3",
|
|
714
|
+
en: "Inserts 500 milliseconds of silence."
|
|
715
|
+
},
|
|
716
|
+
"1s": {
|
|
717
|
+
ja: "1\u79D2\u306E\u7121\u97F3",
|
|
718
|
+
en: "Inserts one second of silence."
|
|
719
|
+
},
|
|
720
|
+
"2s": {
|
|
721
|
+
ja: "2\u79D2\u306E\u7121\u97F3",
|
|
722
|
+
en: "Inserts two seconds of silence."
|
|
723
|
+
},
|
|
724
|
+
"3s": {
|
|
725
|
+
ja: "3\u79D2\u306E\u7121\u97F3",
|
|
726
|
+
en: "Inserts three seconds of silence."
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
var EMPHASIS_LEVEL_DESCRIPTIONS = {
|
|
730
|
+
strong: {
|
|
731
|
+
ja: "\u5F37\u3044\u5F37\u8ABF",
|
|
732
|
+
en: "Applies strong emphasis."
|
|
733
|
+
},
|
|
734
|
+
moderate: {
|
|
735
|
+
ja: "\u4E2D\u7A0B\u5EA6\u306E\u5F37\u8ABF",
|
|
736
|
+
en: "Applies moderate emphasis."
|
|
737
|
+
},
|
|
738
|
+
reduced: {
|
|
739
|
+
ja: "\u5F31\u3081\u306E\u5F37\u8ABF",
|
|
740
|
+
en: "Applies reduced emphasis."
|
|
741
|
+
},
|
|
742
|
+
none: {
|
|
743
|
+
ja: "\u5F37\u8ABF\u306A\u3057",
|
|
744
|
+
en: "Applies no emphasis."
|
|
745
|
+
}
|
|
746
|
+
};
|
|
747
|
+
var PROSODY_RATE_DESCRIPTIONS = {
|
|
748
|
+
"x-slow": {
|
|
749
|
+
ja: "\u6700\u3082\u9045\u3044\u901F\u5EA6",
|
|
750
|
+
en: "Uses the slowest speech rate."
|
|
751
|
+
},
|
|
752
|
+
slow: {
|
|
753
|
+
ja: "\u9045\u3044\u901F\u5EA6",
|
|
754
|
+
en: "Uses a slow speech rate."
|
|
755
|
+
},
|
|
756
|
+
medium: {
|
|
757
|
+
ja: "\u6A19\u6E96\u7684\u306A\u901F\u5EA6",
|
|
758
|
+
en: "Uses the standard speech rate."
|
|
759
|
+
},
|
|
760
|
+
fast: {
|
|
761
|
+
ja: "\u901F\u3044\u901F\u5EA6",
|
|
762
|
+
en: "Uses a fast speech rate."
|
|
763
|
+
},
|
|
764
|
+
"x-fast": {
|
|
765
|
+
ja: "\u6700\u3082\u901F\u3044\u901F\u5EA6",
|
|
766
|
+
en: "Uses the fastest speech rate."
|
|
767
|
+
}
|
|
768
|
+
};
|
|
769
|
+
var PROSODY_PITCH_DESCRIPTIONS = {
|
|
770
|
+
"+2st": {
|
|
771
|
+
ja: "\u57FA\u6E96\u306E\u58F0\u306E\u9AD8\u3055\u3088\u308A2\u534A\u97F3\u4E0A",
|
|
772
|
+
en: "Raises the pitch by two semitones."
|
|
773
|
+
},
|
|
774
|
+
"-2st": {
|
|
775
|
+
ja: "\u57FA\u6E96\u306E\u58F0\u306E\u9AD8\u3055\u3088\u308A2\u534A\u97F3\u4E0B",
|
|
776
|
+
en: "Lowers the pitch by two semitones."
|
|
777
|
+
},
|
|
778
|
+
"0st": {
|
|
779
|
+
ja: "\u57FA\u6E96\u306E\u58F0\u306E\u9AD8\u3055",
|
|
780
|
+
en: "Keeps the baseline pitch."
|
|
781
|
+
},
|
|
782
|
+
"+4st": {
|
|
783
|
+
ja: "\u57FA\u6E96\u306E\u58F0\u306E\u9AD8\u3055\u3088\u308A4\u534A\u97F3\u4E0A",
|
|
784
|
+
en: "Raises the pitch by four semitones."
|
|
785
|
+
},
|
|
786
|
+
"-4st": {
|
|
787
|
+
ja: "\u57FA\u6E96\u306E\u58F0\u306E\u9AD8\u3055\u3088\u308A4\u534A\u97F3\u4E0B",
|
|
788
|
+
en: "Lowers the pitch by four semitones."
|
|
789
|
+
},
|
|
790
|
+
"+8st": {
|
|
791
|
+
ja: "\u57FA\u6E96\u306E\u58F0\u306E\u9AD8\u3055\u3088\u308A8\u534A\u97F3\u4E0A",
|
|
792
|
+
en: "Raises the pitch by eight semitones."
|
|
793
|
+
},
|
|
794
|
+
"-8st": {
|
|
795
|
+
ja: "\u57FA\u6E96\u306E\u58F0\u306E\u9AD8\u3055\u3088\u308A8\u534A\u97F3\u4E0B",
|
|
796
|
+
en: "Lowers the pitch by eight semitones."
|
|
797
|
+
},
|
|
798
|
+
"+12st": {
|
|
799
|
+
ja: "\u57FA\u6E96\u306E\u58F0\u306E\u9AD8\u3055\u3088\u308A12\u534A\u97F3\u4E0A",
|
|
800
|
+
en: "Raises the pitch by twelve semitones."
|
|
801
|
+
},
|
|
802
|
+
"-12st": {
|
|
803
|
+
ja: "\u57FA\u6E96\u306E\u58F0\u306E\u9AD8\u3055\u3088\u308A12\u534A\u97F3\u4E0B",
|
|
804
|
+
en: "Lowers the pitch by twelve semitones."
|
|
805
|
+
}
|
|
806
|
+
};
|
|
807
|
+
var PROSODY_VOLUME_DESCRIPTIONS = {
|
|
808
|
+
silent: {
|
|
809
|
+
ja: "\u7121\u97F3",
|
|
810
|
+
en: "Makes the selected text silent."
|
|
811
|
+
},
|
|
812
|
+
"x-soft": {
|
|
813
|
+
ja: "\u6700\u3082\u5C0F\u3055\u3044\u97F3\u91CF",
|
|
814
|
+
en: "Uses the quietest volume."
|
|
815
|
+
},
|
|
816
|
+
soft: {
|
|
817
|
+
ja: "\u5C0F\u3055\u3044\u97F3\u91CF",
|
|
818
|
+
en: "Uses a soft volume."
|
|
819
|
+
},
|
|
820
|
+
medium: {
|
|
821
|
+
ja: "\u6A19\u6E96\u7684\u306A\u97F3\u91CF",
|
|
822
|
+
en: "Uses the standard volume."
|
|
823
|
+
},
|
|
824
|
+
loud: {
|
|
825
|
+
ja: "\u5927\u304D\u3044\u97F3\u91CF",
|
|
826
|
+
en: "Uses a loud volume."
|
|
827
|
+
},
|
|
828
|
+
"x-loud": {
|
|
829
|
+
ja: "\u6700\u3082\u5927\u304D\u3044\u97F3\u91CF",
|
|
830
|
+
en: "Uses the loudest volume."
|
|
831
|
+
}
|
|
832
|
+
};
|
|
833
|
+
var EXPRESS_AS_STYLE_DESCRIPTIONS = {
|
|
834
|
+
cheerful: {
|
|
835
|
+
ja: "\u660E\u308B\u304F\u5143\u6C17\u306A\u30B9\u30BF\u30A4\u30EB",
|
|
836
|
+
en: "Uses a cheerful style."
|
|
837
|
+
},
|
|
838
|
+
friendly: {
|
|
839
|
+
ja: "\u89AA\u3057\u307F\u3084\u3059\u3044\u30B9\u30BF\u30A4\u30EB",
|
|
840
|
+
en: "Uses a friendly style."
|
|
841
|
+
},
|
|
842
|
+
calm: {
|
|
843
|
+
ja: "\u7A4F\u3084\u304B\u306A\u30B9\u30BF\u30A4\u30EB",
|
|
844
|
+
en: "Uses a calm style."
|
|
845
|
+
},
|
|
846
|
+
sad: {
|
|
847
|
+
ja: "\u60B2\u3057\u3052\u306A\u30B9\u30BF\u30A4\u30EB",
|
|
848
|
+
en: "Uses a sad style."
|
|
849
|
+
},
|
|
850
|
+
angry: {
|
|
851
|
+
ja: "\u6012\u3063\u305F\u3088\u3046\u306A\u30B9\u30BF\u30A4\u30EB",
|
|
852
|
+
en: "Uses an angry style."
|
|
853
|
+
},
|
|
854
|
+
excited: {
|
|
855
|
+
ja: "\u8208\u596E\u3057\u305F\u30B9\u30BF\u30A4\u30EB",
|
|
856
|
+
en: "Uses an excited style."
|
|
857
|
+
},
|
|
858
|
+
empathetic: {
|
|
859
|
+
ja: "\u5171\u611F\u3092\u793A\u3059\u30B9\u30BF\u30A4\u30EB",
|
|
860
|
+
en: "Uses an empathetic style."
|
|
861
|
+
},
|
|
862
|
+
relieved: {
|
|
863
|
+
ja: "\u5B89\u5FC3\u3057\u305F\u30B9\u30BF\u30A4\u30EB",
|
|
864
|
+
en: "Uses a relieved style."
|
|
865
|
+
},
|
|
866
|
+
fearful: {
|
|
867
|
+
ja: "\u6050\u308C\u3092\u611F\u3058\u3055\u305B\u308B\u30B9\u30BF\u30A4\u30EB",
|
|
868
|
+
en: "Uses a fearful style."
|
|
869
|
+
},
|
|
870
|
+
depressed: {
|
|
871
|
+
ja: "\u843D\u3061\u8FBC\u3093\u3060\u30B9\u30BF\u30A4\u30EB",
|
|
872
|
+
en: "Uses a depressed style."
|
|
873
|
+
},
|
|
874
|
+
disgruntled: {
|
|
875
|
+
ja: "\u4E0D\u6E80\u3092\u611F\u3058\u3055\u305B\u308B\u30B9\u30BF\u30A4\u30EB",
|
|
876
|
+
en: "Uses a disgruntled style."
|
|
877
|
+
},
|
|
878
|
+
embarrassed: {
|
|
879
|
+
ja: "\u6065\u305A\u304B\u3057\u305D\u3046\u306A\u30B9\u30BF\u30A4\u30EB",
|
|
880
|
+
en: "Uses an embarrassed style."
|
|
881
|
+
},
|
|
882
|
+
serious: {
|
|
883
|
+
ja: "\u771F\u5263\u306A\u30B9\u30BF\u30A4\u30EB",
|
|
884
|
+
en: "Uses a serious style."
|
|
885
|
+
},
|
|
886
|
+
assistant: {
|
|
887
|
+
ja: "\u30C7\u30B8\u30BF\u30EB\u30A2\u30B7\u30B9\u30BF\u30F3\u30C8\u5411\u3051\u306E\u30B9\u30BF\u30A4\u30EB",
|
|
888
|
+
en: "Uses a digital assistant style."
|
|
889
|
+
},
|
|
890
|
+
chat: {
|
|
891
|
+
ja: "\u4F1A\u8A71\u5411\u3051\u306E\u30B9\u30BF\u30A4\u30EB",
|
|
892
|
+
en: "Uses a conversational style."
|
|
893
|
+
},
|
|
894
|
+
customerservice: {
|
|
895
|
+
ja: "\u30AB\u30B9\u30BF\u30DE\u30FC\u30B5\u30FC\u30D3\u30B9\u5411\u3051\u306E\u30B9\u30BF\u30A4\u30EB",
|
|
896
|
+
en: "Uses a customer service style."
|
|
897
|
+
},
|
|
898
|
+
hopeful: {
|
|
899
|
+
ja: "\u5E0C\u671B\u306B\u6E80\u3061\u305F\u30B9\u30BF\u30A4\u30EB",
|
|
900
|
+
en: "Uses a hopeful style."
|
|
901
|
+
},
|
|
902
|
+
newscast: {
|
|
903
|
+
ja: "\u30CB\u30E5\u30FC\u30B9\u8AAD\u307F\u4E0A\u3052\u5411\u3051\u306E\u30B9\u30BF\u30A4\u30EB",
|
|
904
|
+
en: "Uses a newscast style."
|
|
905
|
+
},
|
|
906
|
+
shouting: {
|
|
907
|
+
ja: "\u53EB\u3076\u3088\u3046\u306A\u30B9\u30BF\u30A4\u30EB",
|
|
908
|
+
en: "Uses a shouting style."
|
|
909
|
+
},
|
|
910
|
+
terrified: {
|
|
911
|
+
ja: "\u6050\u6016\u306B\u6E80\u3061\u305F\u30B9\u30BF\u30A4\u30EB",
|
|
912
|
+
en: "Uses a terrified style."
|
|
913
|
+
},
|
|
914
|
+
unfriendly: {
|
|
915
|
+
ja: "\u7121\u611B\u60F3\u306A\u30B9\u30BF\u30A4\u30EB",
|
|
916
|
+
en: "Uses an unfriendly style."
|
|
917
|
+
},
|
|
918
|
+
whispering: {
|
|
919
|
+
ja: "\u3055\u3055\u3084\u304F\u3088\u3046\u306A\u30B9\u30BF\u30A4\u30EB",
|
|
920
|
+
en: "Uses a whispering style."
|
|
921
|
+
},
|
|
922
|
+
"narration-relaxed": {
|
|
923
|
+
ja: "\u30EA\u30E9\u30C3\u30AF\u30B9\u3057\u305F\u30CA\u30EC\u30FC\u30B7\u30E7\u30F3\u5411\u3051\u306E\u30B9\u30BF\u30A4\u30EB",
|
|
924
|
+
en: "Uses a relaxed narration style."
|
|
925
|
+
},
|
|
926
|
+
"poetry-reading": {
|
|
927
|
+
ja: "\u8A69\u306E\u6717\u8AAD\u5411\u3051\u306E\u30B9\u30BF\u30A4\u30EB",
|
|
928
|
+
en: "Uses a poetry-reading style."
|
|
929
|
+
},
|
|
930
|
+
sports_commentary: {
|
|
931
|
+
ja: "\u30B9\u30DD\u30FC\u30C4\u5B9F\u6CC1\u5411\u3051\u306E\u30B9\u30BF\u30A4\u30EB",
|
|
932
|
+
en: "Uses a sports commentary style."
|
|
933
|
+
},
|
|
934
|
+
sports_commentary_excited: {
|
|
935
|
+
ja: "\u8208\u596E\u3057\u305F\u30B9\u30DD\u30FC\u30C4\u5B9F\u6CC1\u5411\u3051\u306E\u30B9\u30BF\u30A4\u30EB",
|
|
936
|
+
en: "Uses an excited sports commentary style."
|
|
937
|
+
},
|
|
938
|
+
story: {
|
|
939
|
+
ja: "\u7269\u8A9E\u306E\u6717\u8AAD\u5411\u3051\u306E\u30B9\u30BF\u30A4\u30EB",
|
|
940
|
+
en: "Uses a storytelling style."
|
|
941
|
+
}
|
|
942
|
+
};
|
|
943
|
+
var SAY_AS_DESCRIPTIONS = {
|
|
944
|
+
characters: {
|
|
945
|
+
ja: "1\u6587\u5B57\u305A\u3064\u306E\u8AAD\u307F\u4E0A\u3052",
|
|
946
|
+
en: "Speaks the characters one by one."
|
|
947
|
+
},
|
|
948
|
+
"spell-out": {
|
|
949
|
+
ja: "\u7DB4\u308A\u306E\u8AAD\u307F\u4E0A\u3052\uFF081\u6587\u5B57\u305A\u3064\uFF09",
|
|
950
|
+
en: "Spells out the text character by character."
|
|
951
|
+
},
|
|
952
|
+
cardinal: {
|
|
953
|
+
ja: "\u57FA\u6570\u3068\u3057\u3066\u306E\u8AAD\u307F\u4E0A\u3052",
|
|
954
|
+
en: "Speaks the value as a cardinal number."
|
|
955
|
+
},
|
|
956
|
+
ordinal: {
|
|
957
|
+
ja: "\u5E8F\u6570\u3068\u3057\u3066\u306E\u8AAD\u307F\u4E0A\u3052",
|
|
958
|
+
en: "Speaks the value as an ordinal number."
|
|
959
|
+
},
|
|
960
|
+
number: {
|
|
961
|
+
ja: "\u6570\u5024\u3068\u3057\u3066\u306E\u8AAD\u307F\u4E0A\u3052",
|
|
962
|
+
en: "Speaks the value as a number."
|
|
963
|
+
},
|
|
964
|
+
date: {
|
|
965
|
+
ja: "\u65E5\u4ED8\u3068\u3057\u3066\u306E\u8AAD\u307F\u4E0A\u3052",
|
|
966
|
+
en: "Speaks the value as a date."
|
|
967
|
+
},
|
|
968
|
+
time: {
|
|
969
|
+
ja: "\u6642\u523B\u3068\u3057\u3066\u306E\u8AAD\u307F\u4E0A\u3052",
|
|
970
|
+
en: "Speaks the value as a time."
|
|
971
|
+
},
|
|
972
|
+
telephone: {
|
|
973
|
+
ja: "\u96FB\u8A71\u756A\u53F7\u3068\u3057\u3066\u306E\u8AAD\u307F\u4E0A\u3052",
|
|
974
|
+
en: "Speaks the value as a telephone number."
|
|
975
|
+
},
|
|
976
|
+
fraction: {
|
|
977
|
+
ja: "\u5206\u6570\u3068\u3057\u3066\u306E\u8AAD\u307F\u4E0A\u3052",
|
|
978
|
+
en: "Speaks the value as a fraction."
|
|
979
|
+
},
|
|
980
|
+
address: {
|
|
981
|
+
ja: "\u4F4F\u6240\u3068\u3057\u3066\u306E\u8AAD\u307F\u4E0A\u3052",
|
|
982
|
+
en: "Speaks the value as an address."
|
|
983
|
+
},
|
|
984
|
+
name: {
|
|
985
|
+
ja: "\u540D\u524D\u3068\u3057\u3066\u306E\u8AAD\u307F\u4E0A\u3052",
|
|
986
|
+
en: "Speaks the value as a name."
|
|
987
|
+
},
|
|
988
|
+
currency: {
|
|
989
|
+
ja: "\u901A\u8CA8\u3068\u3057\u3066\u306E\u8AAD\u307F\u4E0A\u3052",
|
|
990
|
+
en: "Speaks the value as currency."
|
|
991
|
+
}
|
|
992
|
+
};
|
|
993
|
+
var LANGUAGE_DESCRIPTIONS = {
|
|
994
|
+
"ja-JP": {
|
|
995
|
+
ja: "\u65E5\u672C\u8A9E\uFF08\u65E5\u672C\uFF09\u3067\u8AAD\u307F\u4E0A\u3052\u307E\u3059\u3002",
|
|
996
|
+
en: "Speaks the text in Japanese (Japan)."
|
|
997
|
+
},
|
|
998
|
+
"en-US": {
|
|
999
|
+
ja: "\u82F1\u8A9E\uFF08\u7C73\u56FD\uFF09\u3067\u8AAD\u307F\u4E0A\u3052\u307E\u3059\u3002",
|
|
1000
|
+
en: "Speaks the text in English (United States)."
|
|
1001
|
+
},
|
|
1002
|
+
"de-DE": {
|
|
1003
|
+
ja: "\u30C9\u30A4\u30C4\u8A9E\uFF08\u30C9\u30A4\u30C4\uFF09\u3067\u8AAD\u307F\u4E0A\u3052\u307E\u3059\u3002",
|
|
1004
|
+
en: "Speaks the text in German (Germany)."
|
|
1005
|
+
},
|
|
1006
|
+
"fr-FR": {
|
|
1007
|
+
ja: "\u30D5\u30E9\u30F3\u30B9\u8A9E\uFF08\u30D5\u30E9\u30F3\u30B9\uFF09\u3067\u8AAD\u307F\u4E0A\u3052\u307E\u3059\u3002",
|
|
1008
|
+
en: "Speaks the text in French (France)."
|
|
1009
|
+
}
|
|
1010
|
+
};
|
|
1011
|
+
var SILENCE_VALUE_DESCRIPTIONS = {
|
|
1012
|
+
"300ms": {
|
|
1013
|
+
ja: "\u5148\u982D\u306B300\u30DF\u30EA\u79D2\u306E\u7121\u97F3\u3092\u633F\u5165\u3057\u307E\u3059\u3002",
|
|
1014
|
+
en: "Inserts 300 milliseconds of leading silence."
|
|
1015
|
+
},
|
|
1016
|
+
"500ms": {
|
|
1017
|
+
ja: "\u5148\u982D\u306B500\u30DF\u30EA\u79D2\u306E\u7121\u97F3\u3092\u633F\u5165\u3057\u307E\u3059\u3002",
|
|
1018
|
+
en: "Inserts 500 milliseconds of leading silence."
|
|
1019
|
+
},
|
|
1020
|
+
"1s": {
|
|
1021
|
+
ja: "\u5148\u982D\u306B1\u79D2\u306E\u7121\u97F3\u3092\u633F\u5165\u3057\u307E\u3059\u3002",
|
|
1022
|
+
en: "Inserts one second of leading silence."
|
|
1023
|
+
}
|
|
1024
|
+
};
|
|
1025
|
+
|
|
1026
|
+
// packages/ssml-editor-react/src/constants/ui.ts
|
|
1027
|
+
var DEFAULT_LOCALE = "ja";
|
|
1028
|
+
var OVERLAY_Z_INDEX = 9999;
|
|
1029
|
+
var SELECTION_OVERLAY_ABOVE_THRESHOLD_LINES = 4;
|
|
1030
|
+
var SSML_INSERTION_MODES = {
|
|
1031
|
+
insert: "insert",
|
|
1032
|
+
wrap: "wrap"
|
|
1033
|
+
};
|
|
1034
|
+
|
|
1035
|
+
// packages/ssml-core/dist/index.mjs
|
|
1036
|
+
var __typeError = (msg) => {
|
|
1037
|
+
throw TypeError(msg);
|
|
1038
|
+
};
|
|
1039
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
1040
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
1041
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1042
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
1043
|
+
var SYNTHESIS_NAMESPACE = "http://www.w3.org/2001/10/synthesis";
|
|
1044
|
+
var MSTTS_NAMESPACE = "http://www.w3.org/2001/mstts";
|
|
1045
|
+
var DEFAULT_SSML_VERSION = "1.0";
|
|
1046
|
+
var DEFAULT_SSML_LANGUAGE = "en-US";
|
|
1047
|
+
var MAX_NESTING_DEPTH = 1e3;
|
|
1048
|
+
var XML_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_.:-]*$/;
|
|
1049
|
+
var MSTTS_TAG_PREFIX = "mstts:";
|
|
1050
|
+
var SSML_TAGS = {
|
|
1051
|
+
SPEAK: "speak",
|
|
1052
|
+
VOICE: "voice",
|
|
1053
|
+
PROSODY: "prosody",
|
|
1054
|
+
BREAK: "break",
|
|
1055
|
+
EXPRESS_AS: "express-as",
|
|
1056
|
+
EXPRESS_AS_CAMEL: "expressAs",
|
|
1057
|
+
MSTTS_EXPRESS_AS: "mstts:express-as",
|
|
1058
|
+
SAY_AS: "say-as",
|
|
1059
|
+
SAY_AS_CAMEL: "sayAs",
|
|
1060
|
+
PHONEME: "phoneme",
|
|
1061
|
+
EMPHASIS: "emphasis",
|
|
1062
|
+
AUDIO: "audio",
|
|
1063
|
+
SUB: "sub",
|
|
1064
|
+
LANG: "lang",
|
|
1065
|
+
MARK: "mark",
|
|
1066
|
+
BOOKMARK: "bookmark",
|
|
1067
|
+
LEXICON: "lexicon",
|
|
1068
|
+
PARAGRAPH: "p",
|
|
1069
|
+
SENTENCE: "s",
|
|
1070
|
+
WORD: "w",
|
|
1071
|
+
MSTTS_SILENCE: "mstts:silence",
|
|
1072
|
+
SILENCE: "silence",
|
|
1073
|
+
MSTTS_VISEME: "mstts:viseme",
|
|
1074
|
+
VISEME: "viseme"
|
|
1075
|
+
};
|
|
1076
|
+
var SSML_ATTRS = {
|
|
1077
|
+
VERSION: "version",
|
|
1078
|
+
XMLNS: "xmlns",
|
|
1079
|
+
XML_LANG: "xml:lang",
|
|
1080
|
+
LANG: "lang",
|
|
1081
|
+
MSTTS_XMLNS: "xmlns:mstts",
|
|
1082
|
+
NAME: "name",
|
|
1083
|
+
EFFECT: "effect",
|
|
1084
|
+
RATE: "rate",
|
|
1085
|
+
PITCH: "pitch",
|
|
1086
|
+
VOLUME: "volume",
|
|
1087
|
+
CONTOUR: "contour",
|
|
1088
|
+
RANGE: "range",
|
|
1089
|
+
TIME: "time",
|
|
1090
|
+
STRENGTH: "strength",
|
|
1091
|
+
STYLE: "style",
|
|
1092
|
+
STYLE_DEGREE: "styledegree",
|
|
1093
|
+
STYLE_DEGREE_CAMEL: "styleDegree",
|
|
1094
|
+
ROLE: "role",
|
|
1095
|
+
INTERPRET_AS: "interpret-as",
|
|
1096
|
+
FORMAT: "format",
|
|
1097
|
+
DETAIL: "detail",
|
|
1098
|
+
ALPHABET: "alphabet",
|
|
1099
|
+
PH: "ph",
|
|
1100
|
+
LEVEL: "level",
|
|
1101
|
+
SRC: "src",
|
|
1102
|
+
DESC: "desc",
|
|
1103
|
+
CLIP_BEGIN: "clipBegin",
|
|
1104
|
+
CLIP_END: "clipEnd",
|
|
1105
|
+
SPEED: "speed",
|
|
1106
|
+
REPEAT_COUNT: "repeatCount",
|
|
1107
|
+
REPEAT_DURATION: "repeatDuration",
|
|
1108
|
+
SOUND_LEVEL: "soundLevel",
|
|
1109
|
+
ALIAS: "alias",
|
|
1110
|
+
MARK: "mark",
|
|
1111
|
+
URI: "uri",
|
|
1112
|
+
TYPE: "type",
|
|
1113
|
+
VALUE: "value"
|
|
1114
|
+
};
|
|
1115
|
+
function escapeText(value) {
|
|
1116
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1117
|
+
}
|
|
1118
|
+
function escapeAttribute(value) {
|
|
1119
|
+
return escapeText(value).replace(/"/g, """).replace(/'/g, "'");
|
|
1120
|
+
}
|
|
1121
|
+
function addAttribute(attributes, name, value) {
|
|
1122
|
+
if (value !== void 0) {
|
|
1123
|
+
attributes[name] = value;
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
function getAttributes(element) {
|
|
1127
|
+
const attributes = {
|
|
1128
|
+
...element.attributes ?? {}
|
|
1129
|
+
};
|
|
1130
|
+
switch (element.type) {
|
|
1131
|
+
case SSML_TAGS.VOICE:
|
|
1132
|
+
addAttribute(attributes, SSML_ATTRS.NAME, element.name);
|
|
1133
|
+
addAttribute(attributes, SSML_ATTRS.EFFECT, element.effect);
|
|
1134
|
+
break;
|
|
1135
|
+
case SSML_TAGS.PROSODY:
|
|
1136
|
+
addAttribute(attributes, SSML_ATTRS.RATE, element.rate);
|
|
1137
|
+
addAttribute(attributes, SSML_ATTRS.PITCH, element.pitch);
|
|
1138
|
+
addAttribute(attributes, SSML_ATTRS.VOLUME, element.volume);
|
|
1139
|
+
addAttribute(attributes, SSML_ATTRS.CONTOUR, element.contour);
|
|
1140
|
+
addAttribute(attributes, SSML_ATTRS.RANGE, element.range);
|
|
1141
|
+
break;
|
|
1142
|
+
case SSML_TAGS.BREAK:
|
|
1143
|
+
addAttribute(attributes, SSML_ATTRS.TIME, element.time);
|
|
1144
|
+
addAttribute(attributes, SSML_ATTRS.STRENGTH, element.strength);
|
|
1145
|
+
break;
|
|
1146
|
+
case SSML_TAGS.EXPRESS_AS:
|
|
1147
|
+
case SSML_TAGS.EXPRESS_AS_CAMEL:
|
|
1148
|
+
case SSML_TAGS.MSTTS_EXPRESS_AS:
|
|
1149
|
+
addAttribute(attributes, SSML_ATTRS.STYLE, element.style);
|
|
1150
|
+
addAttribute(attributes, SSML_ATTRS.STYLE_DEGREE, element.styleDegree);
|
|
1151
|
+
addAttribute(attributes, SSML_ATTRS.ROLE, element.role);
|
|
1152
|
+
break;
|
|
1153
|
+
case SSML_TAGS.SAY_AS:
|
|
1154
|
+
case SSML_TAGS.SAY_AS_CAMEL:
|
|
1155
|
+
addAttribute(attributes, SSML_ATTRS.INTERPRET_AS, element.interpretAs);
|
|
1156
|
+
addAttribute(attributes, SSML_ATTRS.FORMAT, element.format);
|
|
1157
|
+
addAttribute(attributes, SSML_ATTRS.DETAIL, element.detail);
|
|
1158
|
+
break;
|
|
1159
|
+
case SSML_TAGS.PHONEME:
|
|
1160
|
+
addAttribute(attributes, SSML_ATTRS.ALPHABET, element.alphabet);
|
|
1161
|
+
addAttribute(attributes, SSML_ATTRS.PH, element.ph);
|
|
1162
|
+
break;
|
|
1163
|
+
case SSML_TAGS.EMPHASIS:
|
|
1164
|
+
addAttribute(attributes, SSML_ATTRS.LEVEL, element.level);
|
|
1165
|
+
break;
|
|
1166
|
+
case SSML_TAGS.AUDIO:
|
|
1167
|
+
addAttribute(attributes, SSML_ATTRS.SRC, element.src);
|
|
1168
|
+
addAttribute(attributes, SSML_ATTRS.DESC, element.desc);
|
|
1169
|
+
addAttribute(attributes, SSML_ATTRS.CLIP_BEGIN, element.clipBegin);
|
|
1170
|
+
addAttribute(attributes, SSML_ATTRS.CLIP_END, element.clipEnd);
|
|
1171
|
+
addAttribute(attributes, SSML_ATTRS.SPEED, element.speed);
|
|
1172
|
+
addAttribute(attributes, SSML_ATTRS.REPEAT_COUNT, element.repeatCount);
|
|
1173
|
+
addAttribute(attributes, SSML_ATTRS.REPEAT_DURATION, element.repeatDuration);
|
|
1174
|
+
addAttribute(attributes, SSML_ATTRS.SOUND_LEVEL, element.soundLevel);
|
|
1175
|
+
break;
|
|
1176
|
+
case SSML_TAGS.SUB:
|
|
1177
|
+
addAttribute(attributes, SSML_ATTRS.ALIAS, element.alias);
|
|
1178
|
+
break;
|
|
1179
|
+
case SSML_TAGS.LANG:
|
|
1180
|
+
addAttribute(attributes, SSML_ATTRS.XML_LANG, element.lang);
|
|
1181
|
+
break;
|
|
1182
|
+
case SSML_TAGS.MARK:
|
|
1183
|
+
addAttribute(attributes, SSML_ATTRS.NAME, element.name);
|
|
1184
|
+
break;
|
|
1185
|
+
case SSML_TAGS.BOOKMARK:
|
|
1186
|
+
addAttribute(attributes, SSML_ATTRS.MARK, element.mark);
|
|
1187
|
+
break;
|
|
1188
|
+
case SSML_TAGS.LEXICON:
|
|
1189
|
+
addAttribute(attributes, SSML_ATTRS.URI, element.uri);
|
|
1190
|
+
break;
|
|
1191
|
+
case SSML_TAGS.MSTTS_SILENCE:
|
|
1192
|
+
case SSML_TAGS.SILENCE:
|
|
1193
|
+
addAttribute(attributes, SSML_ATTRS.TYPE, element.typeValue ?? element.silenceType);
|
|
1194
|
+
addAttribute(attributes, SSML_ATTRS.VALUE, element.value);
|
|
1195
|
+
break;
|
|
1196
|
+
case SSML_TAGS.MSTTS_VISEME:
|
|
1197
|
+
case SSML_TAGS.VISEME:
|
|
1198
|
+
addAttribute(attributes, SSML_ATTRS.TYPE, element.typeValue ?? element.visemeType);
|
|
1199
|
+
break;
|
|
1200
|
+
case SSML_TAGS.PARAGRAPH:
|
|
1201
|
+
case SSML_TAGS.SENTENCE:
|
|
1202
|
+
case SSML_TAGS.WORD:
|
|
1203
|
+
case "element":
|
|
1204
|
+
case "custom":
|
|
1205
|
+
break;
|
|
1206
|
+
}
|
|
1207
|
+
return attributes;
|
|
1208
|
+
}
|
|
1209
|
+
function getTagName(element) {
|
|
1210
|
+
switch (element.type) {
|
|
1211
|
+
case SSML_TAGS.EXPRESS_AS:
|
|
1212
|
+
case SSML_TAGS.EXPRESS_AS_CAMEL:
|
|
1213
|
+
case SSML_TAGS.MSTTS_EXPRESS_AS:
|
|
1214
|
+
return SSML_TAGS.MSTTS_EXPRESS_AS;
|
|
1215
|
+
case SSML_TAGS.SAY_AS:
|
|
1216
|
+
case SSML_TAGS.SAY_AS_CAMEL:
|
|
1217
|
+
return SSML_TAGS.SAY_AS;
|
|
1218
|
+
case SSML_TAGS.SILENCE:
|
|
1219
|
+
case SSML_TAGS.MSTTS_SILENCE:
|
|
1220
|
+
return SSML_TAGS.MSTTS_SILENCE;
|
|
1221
|
+
case SSML_TAGS.VISEME:
|
|
1222
|
+
case SSML_TAGS.MSTTS_VISEME:
|
|
1223
|
+
return SSML_TAGS.MSTTS_VISEME;
|
|
1224
|
+
case "element":
|
|
1225
|
+
case "custom":
|
|
1226
|
+
return element.name;
|
|
1227
|
+
default:
|
|
1228
|
+
return element.type;
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
function getChildren(element) {
|
|
1232
|
+
return element.children ?? [];
|
|
1233
|
+
}
|
|
1234
|
+
function validateName(name, kind) {
|
|
1235
|
+
if (!XML_NAME_PATTERN.test(name)) {
|
|
1236
|
+
throw new Error(`Invalid XML ${kind} name: ${name}`);
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
function serializeAttributes(attributes) {
|
|
1240
|
+
return Object.entries(attributes).map(([name, value]) => {
|
|
1241
|
+
validateName(name, "attribute");
|
|
1242
|
+
return ` ${name}="${escapeAttribute(String(value))}"`;
|
|
1243
|
+
}).join("");
|
|
1244
|
+
}
|
|
1245
|
+
function serializeNode(node) {
|
|
1246
|
+
if (typeof node === "string") {
|
|
1247
|
+
return escapeText(node);
|
|
1248
|
+
}
|
|
1249
|
+
if (node.type === "text") {
|
|
1250
|
+
return escapeText(node.value);
|
|
1251
|
+
}
|
|
1252
|
+
const tagName = getTagName(node);
|
|
1253
|
+
validateName(tagName, "element");
|
|
1254
|
+
const attributes = serializeAttributes(getAttributes(node));
|
|
1255
|
+
const children = getChildren(node);
|
|
1256
|
+
if (children.length === 0) {
|
|
1257
|
+
return `<${tagName}${attributes}/>`;
|
|
1258
|
+
}
|
|
1259
|
+
return `<${tagName}${attributes}>${children.map(serializeNode).join("")}</${tagName}>`;
|
|
1260
|
+
}
|
|
1261
|
+
function usesMsttsNamespace(nodes) {
|
|
1262
|
+
return nodes.some((node) => {
|
|
1263
|
+
if (typeof node === "string" || node.type === "text") {
|
|
1264
|
+
return false;
|
|
1265
|
+
}
|
|
1266
|
+
const tagName = getTagName(node);
|
|
1267
|
+
return tagName.startsWith(MSTTS_TAG_PREFIX) || usesMsttsNamespace(getChildren(node));
|
|
1268
|
+
});
|
|
1269
|
+
}
|
|
1270
|
+
function serializeDocument(document) {
|
|
1271
|
+
const children = document.children ?? (document.content === void 0 ? [] : [document.content]);
|
|
1272
|
+
const attributes = {
|
|
1273
|
+
...document.attributes ?? {},
|
|
1274
|
+
[SSML_ATTRS.VERSION]: document.version,
|
|
1275
|
+
[SSML_ATTRS.XMLNS]: SYNTHESIS_NAMESPACE,
|
|
1276
|
+
[SSML_ATTRS.XML_LANG]: document.lang
|
|
1277
|
+
};
|
|
1278
|
+
if (usesMsttsNamespace(children) && attributes[SSML_ATTRS.MSTTS_XMLNS] === void 0) {
|
|
1279
|
+
attributes[SSML_ATTRS.MSTTS_XMLNS] = MSTTS_NAMESPACE;
|
|
1280
|
+
}
|
|
1281
|
+
return `<${SSML_TAGS.SPEAK}${serializeAttributes(attributes)}>${children.map(serializeNode).join("")}</${SSML_TAGS.SPEAK}>`;
|
|
1282
|
+
}
|
|
1283
|
+
function buildSsml(documentOrContent, lang = DEFAULT_SSML_LANGUAGE) {
|
|
1284
|
+
if (typeof documentOrContent === "string") {
|
|
1285
|
+
return {
|
|
1286
|
+
version: DEFAULT_SSML_VERSION,
|
|
1287
|
+
lang,
|
|
1288
|
+
content: documentOrContent
|
|
1289
|
+
};
|
|
1290
|
+
}
|
|
1291
|
+
return serializeDocument(documentOrContent);
|
|
1292
|
+
}
|
|
1293
|
+
var XML_ENTITIES = {
|
|
1294
|
+
amp: "&",
|
|
1295
|
+
apos: "'",
|
|
1296
|
+
gt: ">",
|
|
1297
|
+
lt: "<",
|
|
1298
|
+
quot: '"'
|
|
1299
|
+
};
|
|
1300
|
+
function hasOwn(object, property) {
|
|
1301
|
+
return Object.getOwnPropertyDescriptor(object, property) !== void 0;
|
|
1302
|
+
}
|
|
1303
|
+
function setAttribute(attributes, name, value) {
|
|
1304
|
+
Object.defineProperty(attributes, name, {
|
|
1305
|
+
configurable: true,
|
|
1306
|
+
enumerable: true,
|
|
1307
|
+
value,
|
|
1308
|
+
writable: true
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1311
|
+
function decodeEntity(entity) {
|
|
1312
|
+
const namedValue = hasOwn(XML_ENTITIES, entity) ? XML_ENTITIES[entity] : void 0;
|
|
1313
|
+
if (namedValue !== void 0) {
|
|
1314
|
+
return namedValue;
|
|
1315
|
+
}
|
|
1316
|
+
const isHexadecimal = entity.startsWith("#x") || entity.startsWith("#X");
|
|
1317
|
+
const isDecimal = entity.startsWith("#");
|
|
1318
|
+
if (!isHexadecimal && !isDecimal) {
|
|
1319
|
+
throw new Error(`Unknown XML entity: &${entity};`);
|
|
1320
|
+
}
|
|
1321
|
+
const digits = entity.slice(isHexadecimal ? 2 : 1);
|
|
1322
|
+
const codePoint = Number.parseInt(digits, isHexadecimal ? 16 : 10);
|
|
1323
|
+
if (!digits || !Number.isInteger(codePoint) || codePoint < 0 || codePoint > 1114111 || codePoint >= 55296 && codePoint <= 57343 || codePoint < 32 && ![9, 10, 13].includes(codePoint)) {
|
|
1324
|
+
throw new Error(`Invalid XML character reference: &${entity};`);
|
|
1325
|
+
}
|
|
1326
|
+
return String.fromCodePoint(codePoint);
|
|
1327
|
+
}
|
|
1328
|
+
function decodeXmlEntities(value) {
|
|
1329
|
+
let result = "";
|
|
1330
|
+
let start = 0;
|
|
1331
|
+
while (true) {
|
|
1332
|
+
const ampersand = value.indexOf("&", start);
|
|
1333
|
+
if (ampersand === -1) {
|
|
1334
|
+
return result + value.slice(start);
|
|
1335
|
+
}
|
|
1336
|
+
result += value.slice(start, ampersand);
|
|
1337
|
+
const semicolon = value.indexOf(";", ampersand + 1);
|
|
1338
|
+
if (semicolon === -1) {
|
|
1339
|
+
throw new Error("Unterminated XML entity reference");
|
|
1340
|
+
}
|
|
1341
|
+
result += decodeEntity(value.slice(ampersand + 1, semicolon));
|
|
1342
|
+
start = semicolon + 1;
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
function isXmlNameStart(value) {
|
|
1346
|
+
return value !== void 0 && /[A-Za-z_]/.test(value);
|
|
1347
|
+
}
|
|
1348
|
+
function isXmlNameCharacter(value) {
|
|
1349
|
+
return value !== void 0 && /[A-Za-z0-9_.:-]/.test(value);
|
|
1350
|
+
}
|
|
1351
|
+
function isXmlWhitespace(value) {
|
|
1352
|
+
return value === " " || value === " " || value === "\r" || value === "\n";
|
|
1353
|
+
}
|
|
1354
|
+
function removeStandardNamespaceAttributes(attributes) {
|
|
1355
|
+
if (attributes[SSML_ATTRS.XMLNS] === SYNTHESIS_NAMESPACE) {
|
|
1356
|
+
delete attributes[SSML_ATTRS.XMLNS];
|
|
1357
|
+
}
|
|
1358
|
+
if (attributes[SSML_ATTRS.MSTTS_XMLNS] === MSTTS_NAMESPACE) {
|
|
1359
|
+
delete attributes[SSML_ATTRS.MSTTS_XMLNS];
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
var _index;
|
|
1363
|
+
var XmlParser = class {
|
|
1364
|
+
constructor(source) {
|
|
1365
|
+
__privateAdd(this, _index, 0);
|
|
1366
|
+
this.source = source;
|
|
1367
|
+
}
|
|
1368
|
+
parse() {
|
|
1369
|
+
if (this.source.charCodeAt(0) === 65279) {
|
|
1370
|
+
__privateSet(this, _index, __privateGet(this, _index) + 1);
|
|
1371
|
+
}
|
|
1372
|
+
this.skipMisc();
|
|
1373
|
+
if (__privateGet(this, _index) >= this.source.length) {
|
|
1374
|
+
this.fail("SSML input is empty");
|
|
1375
|
+
}
|
|
1376
|
+
if (this.source[__privateGet(this, _index)] !== "<") {
|
|
1377
|
+
this.fail("SSML input must start with an XML element");
|
|
1378
|
+
}
|
|
1379
|
+
const root = this.parseElement(0);
|
|
1380
|
+
this.skipMisc();
|
|
1381
|
+
if (__privateGet(this, _index) !== this.source.length) {
|
|
1382
|
+
this.fail("Unexpected content after the root XML element");
|
|
1383
|
+
}
|
|
1384
|
+
return root;
|
|
1385
|
+
}
|
|
1386
|
+
parseElement(depth) {
|
|
1387
|
+
if (depth > MAX_NESTING_DEPTH) {
|
|
1388
|
+
this.fail("XML nesting depth exceeds the supported limit");
|
|
1389
|
+
}
|
|
1390
|
+
this.expect("<");
|
|
1391
|
+
if (this.source[__privateGet(this, _index)] === "/") {
|
|
1392
|
+
this.fail("Unexpected closing XML element");
|
|
1393
|
+
}
|
|
1394
|
+
const name = this.parseName();
|
|
1395
|
+
const { attributes, selfClosing } = this.parseStartTag();
|
|
1396
|
+
if (selfClosing) {
|
|
1397
|
+
return { name, attributes, children: [] };
|
|
1398
|
+
}
|
|
1399
|
+
const children = [];
|
|
1400
|
+
while (__privateGet(this, _index) < this.source.length) {
|
|
1401
|
+
if (this.source.startsWith("</", __privateGet(this, _index))) {
|
|
1402
|
+
__privateSet(this, _index, __privateGet(this, _index) + 2);
|
|
1403
|
+
const closingName = this.parseName();
|
|
1404
|
+
this.skipWhitespace();
|
|
1405
|
+
this.expect(">");
|
|
1406
|
+
if (closingName !== name) {
|
|
1407
|
+
this.fail(`Mismatched closing element: expected </${name}> but found </${closingName}>`);
|
|
1408
|
+
}
|
|
1409
|
+
return { name, attributes, children };
|
|
1410
|
+
}
|
|
1411
|
+
if (this.source.startsWith("<!--", __privateGet(this, _index))) {
|
|
1412
|
+
this.skipComment();
|
|
1413
|
+
continue;
|
|
1414
|
+
}
|
|
1415
|
+
if (this.source.startsWith("<![CDATA[", __privateGet(this, _index))) {
|
|
1416
|
+
this.appendText(children, this.parseCdata());
|
|
1417
|
+
continue;
|
|
1418
|
+
}
|
|
1419
|
+
if (this.source.startsWith("<?", __privateGet(this, _index))) {
|
|
1420
|
+
this.skipProcessingInstruction();
|
|
1421
|
+
continue;
|
|
1422
|
+
}
|
|
1423
|
+
if (this.source.startsWith("<!", __privateGet(this, _index))) {
|
|
1424
|
+
this.fail("Unsupported XML declaration inside an element");
|
|
1425
|
+
}
|
|
1426
|
+
if (this.source[__privateGet(this, _index)] === "<") {
|
|
1427
|
+
children.push(this.parseElement(depth + 1));
|
|
1428
|
+
} else {
|
|
1429
|
+
this.appendText(children, this.parseText());
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
this.fail(`Unclosed XML element: <${name}>`);
|
|
1433
|
+
}
|
|
1434
|
+
parseStartTag() {
|
|
1435
|
+
const attributes = {};
|
|
1436
|
+
while (__privateGet(this, _index) < this.source.length) {
|
|
1437
|
+
this.skipWhitespace();
|
|
1438
|
+
if (this.source.startsWith("/>", __privateGet(this, _index))) {
|
|
1439
|
+
__privateSet(this, _index, __privateGet(this, _index) + 2);
|
|
1440
|
+
return { attributes, selfClosing: true };
|
|
1441
|
+
}
|
|
1442
|
+
if (this.source[__privateGet(this, _index)] === ">") {
|
|
1443
|
+
__privateSet(this, _index, __privateGet(this, _index) + 1);
|
|
1444
|
+
return { attributes, selfClosing: false };
|
|
1445
|
+
}
|
|
1446
|
+
const name = this.parseName();
|
|
1447
|
+
this.skipWhitespace();
|
|
1448
|
+
this.expect("=");
|
|
1449
|
+
this.skipWhitespace();
|
|
1450
|
+
const quote = this.source[__privateGet(this, _index)];
|
|
1451
|
+
if (quote !== '"' && quote !== "'") {
|
|
1452
|
+
this.fail(`XML attribute ${name} must use a quoted value`);
|
|
1453
|
+
}
|
|
1454
|
+
__privateSet(this, _index, __privateGet(this, _index) + 1);
|
|
1455
|
+
const valueStart = __privateGet(this, _index);
|
|
1456
|
+
while (__privateGet(this, _index) < this.source.length && this.source[__privateGet(this, _index)] !== quote) {
|
|
1457
|
+
if (this.source[__privateGet(this, _index)] === "<") {
|
|
1458
|
+
this.fail(`Invalid "<" in XML attribute ${name}`);
|
|
1459
|
+
}
|
|
1460
|
+
__privateSet(this, _index, __privateGet(this, _index) + 1);
|
|
1461
|
+
}
|
|
1462
|
+
if (__privateGet(this, _index) >= this.source.length) {
|
|
1463
|
+
this.fail(`Unclosed XML attribute ${name}`);
|
|
1464
|
+
}
|
|
1465
|
+
const value = decodeXmlEntities(this.source.slice(valueStart, __privateGet(this, _index)));
|
|
1466
|
+
__privateSet(this, _index, __privateGet(this, _index) + 1);
|
|
1467
|
+
if (hasOwn(attributes, name)) {
|
|
1468
|
+
this.fail(`Duplicate XML attribute: ${name}`);
|
|
1469
|
+
}
|
|
1470
|
+
setAttribute(attributes, name, value);
|
|
1471
|
+
}
|
|
1472
|
+
this.fail("Unclosed XML start tag");
|
|
1473
|
+
}
|
|
1474
|
+
parseText() {
|
|
1475
|
+
const start = __privateGet(this, _index);
|
|
1476
|
+
while (__privateGet(this, _index) < this.source.length && this.source[__privateGet(this, _index)] !== "<") {
|
|
1477
|
+
__privateSet(this, _index, __privateGet(this, _index) + 1);
|
|
1478
|
+
}
|
|
1479
|
+
const value = this.source.slice(start, __privateGet(this, _index));
|
|
1480
|
+
if (value.includes("]]>")) {
|
|
1481
|
+
this.fail("CDATA termination is not valid in ordinary XML text");
|
|
1482
|
+
}
|
|
1483
|
+
return decodeXmlEntities(value);
|
|
1484
|
+
}
|
|
1485
|
+
parseCdata() {
|
|
1486
|
+
__privateSet(this, _index, __privateGet(this, _index) + "<![CDATA[".length);
|
|
1487
|
+
const end = this.source.indexOf("]]>", __privateGet(this, _index));
|
|
1488
|
+
if (end === -1) {
|
|
1489
|
+
this.fail("Unclosed XML CDATA section");
|
|
1490
|
+
}
|
|
1491
|
+
const value = this.source.slice(__privateGet(this, _index), end);
|
|
1492
|
+
__privateSet(this, _index, end + 3);
|
|
1493
|
+
return value;
|
|
1494
|
+
}
|
|
1495
|
+
skipComment() {
|
|
1496
|
+
__privateSet(this, _index, __privateGet(this, _index) + "<!--".length);
|
|
1497
|
+
const end = this.source.indexOf("-->", __privateGet(this, _index));
|
|
1498
|
+
if (end === -1) {
|
|
1499
|
+
this.fail("Unclosed XML comment");
|
|
1500
|
+
}
|
|
1501
|
+
if (this.source.slice(__privateGet(this, _index), end).includes("--")) {
|
|
1502
|
+
this.fail("XML comments cannot contain consecutive hyphens");
|
|
1503
|
+
}
|
|
1504
|
+
__privateSet(this, _index, end + 3);
|
|
1505
|
+
}
|
|
1506
|
+
skipProcessingInstruction() {
|
|
1507
|
+
__privateSet(this, _index, __privateGet(this, _index) + "<?".length);
|
|
1508
|
+
this.parseName();
|
|
1509
|
+
const end = this.source.indexOf("?>", __privateGet(this, _index));
|
|
1510
|
+
if (end === -1) {
|
|
1511
|
+
this.fail("Unclosed XML processing instruction");
|
|
1512
|
+
}
|
|
1513
|
+
__privateSet(this, _index, end + 2);
|
|
1514
|
+
}
|
|
1515
|
+
skipMisc() {
|
|
1516
|
+
while (__privateGet(this, _index) < this.source.length) {
|
|
1517
|
+
this.skipWhitespace();
|
|
1518
|
+
if (this.source.startsWith("<!--", __privateGet(this, _index))) {
|
|
1519
|
+
this.skipComment();
|
|
1520
|
+
continue;
|
|
1521
|
+
}
|
|
1522
|
+
if (this.source.startsWith("<?", __privateGet(this, _index))) {
|
|
1523
|
+
this.skipProcessingInstruction();
|
|
1524
|
+
continue;
|
|
1525
|
+
}
|
|
1526
|
+
if (this.source.startsWith("<!DOCTYPE", __privateGet(this, _index))) {
|
|
1527
|
+
this.fail("DOCTYPE declarations are not supported");
|
|
1528
|
+
}
|
|
1529
|
+
break;
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
parseName() {
|
|
1533
|
+
const first = this.source[__privateGet(this, _index)];
|
|
1534
|
+
if (!isXmlNameStart(first)) {
|
|
1535
|
+
this.fail("Invalid XML name");
|
|
1536
|
+
}
|
|
1537
|
+
const start = __privateGet(this, _index);
|
|
1538
|
+
__privateSet(this, _index, __privateGet(this, _index) + 1);
|
|
1539
|
+
while (isXmlNameCharacter(this.source[__privateGet(this, _index)])) {
|
|
1540
|
+
__privateSet(this, _index, __privateGet(this, _index) + 1);
|
|
1541
|
+
}
|
|
1542
|
+
return this.source.slice(start, __privateGet(this, _index));
|
|
1543
|
+
}
|
|
1544
|
+
appendText(children, value) {
|
|
1545
|
+
if (!value) {
|
|
1546
|
+
return;
|
|
1547
|
+
}
|
|
1548
|
+
const previous = children[children.length - 1];
|
|
1549
|
+
if (typeof previous === "string") {
|
|
1550
|
+
children[children.length - 1] = previous + value;
|
|
1551
|
+
} else {
|
|
1552
|
+
children.push(value);
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
skipWhitespace() {
|
|
1556
|
+
while (isXmlWhitespace(this.source[__privateGet(this, _index)])) {
|
|
1557
|
+
__privateSet(this, _index, __privateGet(this, _index) + 1);
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
expect(value) {
|
|
1561
|
+
if (!this.source.startsWith(value, __privateGet(this, _index))) {
|
|
1562
|
+
this.fail(`Expected "${value}"`);
|
|
1563
|
+
}
|
|
1564
|
+
__privateSet(this, _index, __privateGet(this, _index) + value.length);
|
|
1565
|
+
}
|
|
1566
|
+
fail(message) {
|
|
1567
|
+
throw new Error(`${message} at position ${__privateGet(this, _index)}`);
|
|
1568
|
+
}
|
|
1569
|
+
};
|
|
1570
|
+
_index = /* @__PURE__ */ new WeakMap();
|
|
1571
|
+
function readAttribute(attributes, ...names) {
|
|
1572
|
+
let found = false;
|
|
1573
|
+
let value;
|
|
1574
|
+
for (const name of names) {
|
|
1575
|
+
if (hasOwn(attributes, name)) {
|
|
1576
|
+
if (!found) {
|
|
1577
|
+
value = String(attributes[name]);
|
|
1578
|
+
found = true;
|
|
1579
|
+
}
|
|
1580
|
+
delete attributes[name];
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
return value;
|
|
1584
|
+
}
|
|
1585
|
+
function getElementAttributes(node) {
|
|
1586
|
+
const attributes = { ...node.attributes };
|
|
1587
|
+
removeStandardNamespaceAttributes(attributes);
|
|
1588
|
+
return attributes;
|
|
1589
|
+
}
|
|
1590
|
+
function finishElement(element, node, attributes) {
|
|
1591
|
+
if (node.children.length > 0) {
|
|
1592
|
+
element.children = node.children.map(convertNode);
|
|
1593
|
+
}
|
|
1594
|
+
if (Object.keys(attributes).length > 0) {
|
|
1595
|
+
element.attributes = attributes;
|
|
1596
|
+
}
|
|
1597
|
+
return element;
|
|
1598
|
+
}
|
|
1599
|
+
function convertElement(node) {
|
|
1600
|
+
const attributes = getElementAttributes(node);
|
|
1601
|
+
switch (node.name) {
|
|
1602
|
+
case SSML_TAGS.VOICE: {
|
|
1603
|
+
const element = { type: SSML_TAGS.VOICE };
|
|
1604
|
+
const name = readAttribute(attributes, SSML_ATTRS.NAME);
|
|
1605
|
+
const effect = readAttribute(attributes, SSML_ATTRS.EFFECT);
|
|
1606
|
+
if (name !== void 0) element.name = name;
|
|
1607
|
+
if (effect !== void 0) element.effect = effect;
|
|
1608
|
+
return finishElement(element, node, attributes);
|
|
1609
|
+
}
|
|
1610
|
+
case SSML_TAGS.PROSODY: {
|
|
1611
|
+
const element = { type: SSML_TAGS.PROSODY };
|
|
1612
|
+
const rate = readAttribute(attributes, SSML_ATTRS.RATE);
|
|
1613
|
+
const pitch = readAttribute(attributes, SSML_ATTRS.PITCH);
|
|
1614
|
+
const volume = readAttribute(attributes, SSML_ATTRS.VOLUME);
|
|
1615
|
+
const contour = readAttribute(attributes, SSML_ATTRS.CONTOUR);
|
|
1616
|
+
const range = readAttribute(attributes, SSML_ATTRS.RANGE);
|
|
1617
|
+
if (rate !== void 0) element.rate = rate;
|
|
1618
|
+
if (pitch !== void 0) element.pitch = pitch;
|
|
1619
|
+
if (volume !== void 0) element.volume = volume;
|
|
1620
|
+
if (contour !== void 0) element.contour = contour;
|
|
1621
|
+
if (range !== void 0) element.range = range;
|
|
1622
|
+
return finishElement(element, node, attributes);
|
|
1623
|
+
}
|
|
1624
|
+
case SSML_TAGS.BREAK: {
|
|
1625
|
+
const element = { type: SSML_TAGS.BREAK };
|
|
1626
|
+
const time = readAttribute(attributes, SSML_ATTRS.TIME);
|
|
1627
|
+
const strength = readAttribute(attributes, SSML_ATTRS.STRENGTH);
|
|
1628
|
+
if (time !== void 0) element.time = time;
|
|
1629
|
+
if (strength !== void 0) element.strength = strength;
|
|
1630
|
+
return finishElement(element, node, attributes);
|
|
1631
|
+
}
|
|
1632
|
+
case SSML_TAGS.EXPRESS_AS:
|
|
1633
|
+
case SSML_TAGS.EXPRESS_AS_CAMEL:
|
|
1634
|
+
case SSML_TAGS.MSTTS_EXPRESS_AS: {
|
|
1635
|
+
const element = { type: node.name };
|
|
1636
|
+
const style = readAttribute(attributes, SSML_ATTRS.STYLE);
|
|
1637
|
+
const styleDegree = readAttribute(attributes, SSML_ATTRS.STYLE_DEGREE, SSML_ATTRS.STYLE_DEGREE_CAMEL);
|
|
1638
|
+
const role = readAttribute(attributes, SSML_ATTRS.ROLE);
|
|
1639
|
+
if (style !== void 0) element.style = style;
|
|
1640
|
+
if (styleDegree !== void 0) element.styleDegree = styleDegree;
|
|
1641
|
+
if (role !== void 0) element.role = role;
|
|
1642
|
+
return finishElement(element, node, attributes);
|
|
1643
|
+
}
|
|
1644
|
+
case SSML_TAGS.SAY_AS:
|
|
1645
|
+
case SSML_TAGS.SAY_AS_CAMEL: {
|
|
1646
|
+
const element = { type: node.name };
|
|
1647
|
+
const interpretAs = readAttribute(attributes, SSML_ATTRS.INTERPRET_AS);
|
|
1648
|
+
const format = readAttribute(attributes, SSML_ATTRS.FORMAT);
|
|
1649
|
+
const detail = readAttribute(attributes, SSML_ATTRS.DETAIL);
|
|
1650
|
+
if (interpretAs !== void 0) element.interpretAs = interpretAs;
|
|
1651
|
+
if (format !== void 0) element.format = format;
|
|
1652
|
+
if (detail !== void 0) element.detail = detail;
|
|
1653
|
+
return finishElement(element, node, attributes);
|
|
1654
|
+
}
|
|
1655
|
+
case SSML_TAGS.PHONEME: {
|
|
1656
|
+
const element = { type: SSML_TAGS.PHONEME };
|
|
1657
|
+
const alphabet = readAttribute(attributes, SSML_ATTRS.ALPHABET);
|
|
1658
|
+
const ph = readAttribute(attributes, SSML_ATTRS.PH);
|
|
1659
|
+
if (alphabet !== void 0) element.alphabet = alphabet;
|
|
1660
|
+
if (ph !== void 0) element.ph = ph;
|
|
1661
|
+
return finishElement(element, node, attributes);
|
|
1662
|
+
}
|
|
1663
|
+
case SSML_TAGS.EMPHASIS: {
|
|
1664
|
+
const element = { type: SSML_TAGS.EMPHASIS };
|
|
1665
|
+
const level = readAttribute(attributes, SSML_ATTRS.LEVEL);
|
|
1666
|
+
if (level !== void 0) element.level = level;
|
|
1667
|
+
return finishElement(element, node, attributes);
|
|
1668
|
+
}
|
|
1669
|
+
case SSML_TAGS.AUDIO: {
|
|
1670
|
+
const element = { type: SSML_TAGS.AUDIO };
|
|
1671
|
+
const src = readAttribute(attributes, SSML_ATTRS.SRC);
|
|
1672
|
+
const desc = readAttribute(attributes, SSML_ATTRS.DESC);
|
|
1673
|
+
const clipBegin = readAttribute(attributes, SSML_ATTRS.CLIP_BEGIN);
|
|
1674
|
+
const clipEnd = readAttribute(attributes, SSML_ATTRS.CLIP_END);
|
|
1675
|
+
const speed = readAttribute(attributes, SSML_ATTRS.SPEED);
|
|
1676
|
+
const repeatCount = readAttribute(attributes, SSML_ATTRS.REPEAT_COUNT);
|
|
1677
|
+
const repeatDuration = readAttribute(attributes, SSML_ATTRS.REPEAT_DURATION);
|
|
1678
|
+
const soundLevel = readAttribute(attributes, SSML_ATTRS.SOUND_LEVEL);
|
|
1679
|
+
if (src !== void 0) element.src = src;
|
|
1680
|
+
if (desc !== void 0) element.desc = desc;
|
|
1681
|
+
if (clipBegin !== void 0) element.clipBegin = clipBegin;
|
|
1682
|
+
if (clipEnd !== void 0) element.clipEnd = clipEnd;
|
|
1683
|
+
if (speed !== void 0) element.speed = speed;
|
|
1684
|
+
if (repeatCount !== void 0) element.repeatCount = repeatCount;
|
|
1685
|
+
if (repeatDuration !== void 0) element.repeatDuration = repeatDuration;
|
|
1686
|
+
if (soundLevel !== void 0) element.soundLevel = soundLevel;
|
|
1687
|
+
return finishElement(element, node, attributes);
|
|
1688
|
+
}
|
|
1689
|
+
case SSML_TAGS.SUB: {
|
|
1690
|
+
const element = { type: SSML_TAGS.SUB };
|
|
1691
|
+
const alias = readAttribute(attributes, SSML_ATTRS.ALIAS);
|
|
1692
|
+
if (alias !== void 0) element.alias = alias;
|
|
1693
|
+
return finishElement(element, node, attributes);
|
|
1694
|
+
}
|
|
1695
|
+
case SSML_TAGS.LANG: {
|
|
1696
|
+
const element = { type: SSML_TAGS.LANG };
|
|
1697
|
+
const lang = readAttribute(attributes, SSML_ATTRS.XML_LANG, SSML_ATTRS.LANG);
|
|
1698
|
+
if (lang !== void 0) element.lang = lang;
|
|
1699
|
+
return finishElement(element, node, attributes);
|
|
1700
|
+
}
|
|
1701
|
+
case SSML_TAGS.MARK: {
|
|
1702
|
+
const element = { type: SSML_TAGS.MARK };
|
|
1703
|
+
const name = readAttribute(attributes, SSML_ATTRS.NAME);
|
|
1704
|
+
if (name !== void 0) element.name = name;
|
|
1705
|
+
return finishElement(element, node, attributes);
|
|
1706
|
+
}
|
|
1707
|
+
case SSML_TAGS.BOOKMARK: {
|
|
1708
|
+
const element = { type: SSML_TAGS.BOOKMARK };
|
|
1709
|
+
const mark = readAttribute(attributes, SSML_ATTRS.MARK);
|
|
1710
|
+
if (mark !== void 0) element.mark = mark;
|
|
1711
|
+
return finishElement(element, node, attributes);
|
|
1712
|
+
}
|
|
1713
|
+
case SSML_TAGS.LEXICON: {
|
|
1714
|
+
const element = { type: SSML_TAGS.LEXICON };
|
|
1715
|
+
const uri = readAttribute(attributes, SSML_ATTRS.URI);
|
|
1716
|
+
if (uri !== void 0) element.uri = uri;
|
|
1717
|
+
return finishElement(element, node, attributes);
|
|
1718
|
+
}
|
|
1719
|
+
case SSML_TAGS.PARAGRAPH: {
|
|
1720
|
+
const element = { type: SSML_TAGS.PARAGRAPH };
|
|
1721
|
+
return finishElement(element, node, attributes);
|
|
1722
|
+
}
|
|
1723
|
+
case SSML_TAGS.SENTENCE: {
|
|
1724
|
+
const element = { type: SSML_TAGS.SENTENCE };
|
|
1725
|
+
return finishElement(element, node, attributes);
|
|
1726
|
+
}
|
|
1727
|
+
case SSML_TAGS.WORD: {
|
|
1728
|
+
const element = { type: SSML_TAGS.WORD };
|
|
1729
|
+
return finishElement(element, node, attributes);
|
|
1730
|
+
}
|
|
1731
|
+
case SSML_TAGS.MSTTS_SILENCE:
|
|
1732
|
+
case SSML_TAGS.SILENCE: {
|
|
1733
|
+
const element = {
|
|
1734
|
+
type: node.name === SSML_TAGS.MSTTS_SILENCE ? SSML_TAGS.MSTTS_SILENCE : SSML_TAGS.SILENCE
|
|
1735
|
+
};
|
|
1736
|
+
const typeValue = readAttribute(attributes, SSML_ATTRS.TYPE);
|
|
1737
|
+
const value = readAttribute(attributes, SSML_ATTRS.VALUE);
|
|
1738
|
+
if (typeValue !== void 0) element.typeValue = typeValue;
|
|
1739
|
+
if (value !== void 0) element.value = value;
|
|
1740
|
+
return finishElement(element, node, attributes);
|
|
1741
|
+
}
|
|
1742
|
+
case SSML_TAGS.MSTTS_VISEME:
|
|
1743
|
+
case SSML_TAGS.VISEME: {
|
|
1744
|
+
const element = {
|
|
1745
|
+
type: node.name === SSML_TAGS.MSTTS_VISEME ? SSML_TAGS.MSTTS_VISEME : SSML_TAGS.VISEME
|
|
1746
|
+
};
|
|
1747
|
+
const typeValue = readAttribute(attributes, SSML_ATTRS.TYPE);
|
|
1748
|
+
if (typeValue !== void 0) element.typeValue = typeValue;
|
|
1749
|
+
return finishElement(element, node, attributes);
|
|
1750
|
+
}
|
|
1751
|
+
default: {
|
|
1752
|
+
const element = {
|
|
1753
|
+
name: node.name,
|
|
1754
|
+
type: "custom"
|
|
1755
|
+
};
|
|
1756
|
+
return finishElement(element, node, attributes);
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
function convertNode(node) {
|
|
1761
|
+
return typeof node === "string" ? node : convertElement(node);
|
|
1762
|
+
}
|
|
1763
|
+
function parseSsml(xmlString) {
|
|
1764
|
+
if (typeof xmlString !== "string") {
|
|
1765
|
+
throw new TypeError("SSML input must be a string");
|
|
1766
|
+
}
|
|
1767
|
+
const root = new XmlParser(xmlString).parse();
|
|
1768
|
+
if (root.name !== SSML_TAGS.SPEAK) {
|
|
1769
|
+
throw new Error(`SSML root element must be <${SSML_TAGS.SPEAK}>, found <${root.name}>`);
|
|
1770
|
+
}
|
|
1771
|
+
const attributes = { ...root.attributes };
|
|
1772
|
+
const version = readAttribute(attributes, SSML_ATTRS.VERSION);
|
|
1773
|
+
const lang = readAttribute(attributes, SSML_ATTRS.XML_LANG, SSML_ATTRS.LANG);
|
|
1774
|
+
if (version === void 0) {
|
|
1775
|
+
throw new Error(`SSML <${SSML_TAGS.SPEAK}> element is missing the "${SSML_ATTRS.VERSION}" attribute`);
|
|
1776
|
+
}
|
|
1777
|
+
if (lang === void 0) {
|
|
1778
|
+
throw new Error(`SSML <${SSML_TAGS.SPEAK}> element is missing the "${SSML_ATTRS.XML_LANG}" attribute`);
|
|
1779
|
+
}
|
|
1780
|
+
removeStandardNamespaceAttributes(attributes);
|
|
1781
|
+
const document = {
|
|
1782
|
+
children: root.children.map(convertNode),
|
|
1783
|
+
lang,
|
|
1784
|
+
type: SSML_TAGS.SPEAK,
|
|
1785
|
+
version
|
|
1786
|
+
};
|
|
1787
|
+
if (Object.keys(attributes).length > 0) {
|
|
1788
|
+
document.attributes = attributes;
|
|
1789
|
+
}
|
|
1790
|
+
return document;
|
|
1791
|
+
}
|
|
1792
|
+
function escapeAttribute2(value) {
|
|
1793
|
+
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">").replace(/'/g, "'");
|
|
1794
|
+
}
|
|
1795
|
+
function getPartialTextNodes(text, version, lang) {
|
|
1796
|
+
if (!text.includes("<")) {
|
|
1797
|
+
return [text];
|
|
1798
|
+
}
|
|
1799
|
+
try {
|
|
1800
|
+
const openingTag = `<${SSML_TAGS.SPEAK} ${SSML_ATTRS.VERSION}="${escapeAttribute2(version)}" ${SSML_ATTRS.XMLNS}="${SYNTHESIS_NAMESPACE}" ${SSML_ATTRS.XML_LANG}="${escapeAttribute2(lang)}">`;
|
|
1801
|
+
return parseSsml(`${openingTag}${text}</${SSML_TAGS.SPEAK}>`).children ?? [];
|
|
1802
|
+
} catch {
|
|
1803
|
+
return [{ type: "text", value: text }];
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
function getVoiceContext(context) {
|
|
1807
|
+
const voice = context.voice;
|
|
1808
|
+
if (typeof voice === "object" && voice !== null) {
|
|
1809
|
+
return voice;
|
|
1810
|
+
}
|
|
1811
|
+
if (context.voiceName === void 0 && context.voiceEffect === void 0 && typeof voice !== "string") {
|
|
1812
|
+
return void 0;
|
|
1813
|
+
}
|
|
1814
|
+
return {
|
|
1815
|
+
name: context.voiceName ?? voice,
|
|
1816
|
+
effect: context.voiceEffect
|
|
1817
|
+
};
|
|
1818
|
+
}
|
|
1819
|
+
function serializePartialSsml(text, context) {
|
|
1820
|
+
const version = context.version ?? DEFAULT_SSML_VERSION;
|
|
1821
|
+
const lang = context.lang ?? DEFAULT_SSML_LANGUAGE;
|
|
1822
|
+
let children = getPartialTextNodes(text, version, lang);
|
|
1823
|
+
if (context.prosody) {
|
|
1824
|
+
children = [
|
|
1825
|
+
{
|
|
1826
|
+
type: SSML_TAGS.PROSODY,
|
|
1827
|
+
...context.prosody,
|
|
1828
|
+
children
|
|
1829
|
+
}
|
|
1830
|
+
];
|
|
1831
|
+
}
|
|
1832
|
+
const voice = getVoiceContext(context);
|
|
1833
|
+
if (voice) {
|
|
1834
|
+
children = [
|
|
1835
|
+
{
|
|
1836
|
+
type: SSML_TAGS.VOICE,
|
|
1837
|
+
...voice,
|
|
1838
|
+
children
|
|
1839
|
+
}
|
|
1840
|
+
];
|
|
1841
|
+
}
|
|
1842
|
+
const document = {
|
|
1843
|
+
type: SSML_TAGS.SPEAK,
|
|
1844
|
+
version,
|
|
1845
|
+
lang,
|
|
1846
|
+
attributes: context.attributes,
|
|
1847
|
+
children
|
|
1848
|
+
};
|
|
1849
|
+
return buildSsml(document);
|
|
1850
|
+
}
|
|
1851
|
+
function buildPartialSsml(textOrOptions, context) {
|
|
1852
|
+
if (typeof textOrOptions === "string") {
|
|
1853
|
+
return serializePartialSsml(textOrOptions, context ?? {});
|
|
1854
|
+
}
|
|
1855
|
+
return serializePartialSsml(textOrOptions.text, textOrOptions);
|
|
1856
|
+
}
|
|
1857
|
+
var PARSER_POSITION_SUFFIX = / at position (\d+)$/;
|
|
1858
|
+
function validateSsml(xmlString) {
|
|
1859
|
+
try {
|
|
1860
|
+
parseSsml(xmlString);
|
|
1861
|
+
return null;
|
|
1862
|
+
} catch (error) {
|
|
1863
|
+
const rawMessage = error instanceof Error ? error.message : String(error);
|
|
1864
|
+
const positionMatch = PARSER_POSITION_SUFFIX.exec(rawMessage);
|
|
1865
|
+
return {
|
|
1866
|
+
message: positionMatch ? rawMessage.slice(0, positionMatch.index) : rawMessage,
|
|
1867
|
+
position: positionMatch ? Number.parseInt(positionMatch[1], 10) : 0
|
|
1868
|
+
};
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
// packages/ssml-editor-react/src/clearSsmlDocument.ts
|
|
1873
|
+
function getDocumentChildren(document) {
|
|
1874
|
+
return document.children ?? (document.content === void 0 ? [] : [document.content]);
|
|
1875
|
+
}
|
|
1876
|
+
function appendNode(nodes, node) {
|
|
1877
|
+
if (typeof node === "string") {
|
|
1878
|
+
const lastNode = nodes[nodes.length - 1];
|
|
1879
|
+
if (typeof lastNode === "string") {
|
|
1880
|
+
nodes[nodes.length - 1] = lastNode + node;
|
|
1881
|
+
} else if (node !== "") {
|
|
1882
|
+
nodes.push(node);
|
|
1883
|
+
}
|
|
1884
|
+
return;
|
|
1885
|
+
}
|
|
1886
|
+
nodes.push(node);
|
|
1887
|
+
}
|
|
1888
|
+
function clearNodes(nodes) {
|
|
1889
|
+
const clearedNodes = [];
|
|
1890
|
+
for (const node of nodes) {
|
|
1891
|
+
if (typeof node === "string") {
|
|
1892
|
+
appendNode(clearedNodes, node);
|
|
1893
|
+
continue;
|
|
1894
|
+
}
|
|
1895
|
+
if (node.type === "text") {
|
|
1896
|
+
appendNode(clearedNodes, node.value);
|
|
1897
|
+
continue;
|
|
1898
|
+
}
|
|
1899
|
+
const children = clearNodes(node.children ?? []);
|
|
1900
|
+
if (node.type === "voice") {
|
|
1901
|
+
appendNode(clearedNodes, { ...node, children });
|
|
1902
|
+
continue;
|
|
1903
|
+
}
|
|
1904
|
+
for (const child of children) {
|
|
1905
|
+
appendNode(clearedNodes, child);
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
return clearedNodes;
|
|
1909
|
+
}
|
|
1910
|
+
function clearSsmlDocument(document) {
|
|
1911
|
+
const nextDocument = {
|
|
1912
|
+
...document,
|
|
1913
|
+
children: clearNodes(getDocumentChildren(document))
|
|
1914
|
+
};
|
|
1915
|
+
if (nextDocument.content !== void 0) {
|
|
1916
|
+
delete nextDocument.content;
|
|
1917
|
+
}
|
|
1918
|
+
return nextDocument;
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
// packages/ssml-editor-react/src/formatXml.ts
|
|
1922
|
+
var INDENT = " ";
|
|
1923
|
+
var FRAGMENT_ROOT = "ssml-builder-fragment";
|
|
1924
|
+
var XML_ENTITY_NAMES = /* @__PURE__ */ new Set(["amp", "apos", "gt", "lt", "quot"]);
|
|
1925
|
+
var INTRINSICALLY_EMPTY_ELEMENTS = /* @__PURE__ */ new Set([
|
|
1926
|
+
"break",
|
|
1927
|
+
"bookmark",
|
|
1928
|
+
"lexicon",
|
|
1929
|
+
"mark",
|
|
1930
|
+
"mstts:silence",
|
|
1931
|
+
"mstts:viseme",
|
|
1932
|
+
"silence",
|
|
1933
|
+
"viseme"
|
|
1934
|
+
]);
|
|
1935
|
+
function isXmlNameStart2(value) {
|
|
1936
|
+
return value !== void 0 && /[A-Za-z_]/.test(value);
|
|
1937
|
+
}
|
|
1938
|
+
function isXmlNameCharacter2(value) {
|
|
1939
|
+
return value !== void 0 && /[A-Za-z0-9_.:-]/.test(value);
|
|
1940
|
+
}
|
|
1941
|
+
function isXmlWhitespace2(value) {
|
|
1942
|
+
return value === " " || value === " " || value === "\r" || value === "\n";
|
|
1943
|
+
}
|
|
1944
|
+
function fail(message) {
|
|
1945
|
+
throw new Error(message);
|
|
1946
|
+
}
|
|
1947
|
+
function skipWhitespace(source, index) {
|
|
1948
|
+
while (isXmlWhitespace2(source[index])) {
|
|
1949
|
+
index += 1;
|
|
1950
|
+
}
|
|
1951
|
+
return index;
|
|
1952
|
+
}
|
|
1953
|
+
function readName(source, start, end) {
|
|
1954
|
+
if (!isXmlNameStart2(source[start])) {
|
|
1955
|
+
fail("Invalid XML name");
|
|
1956
|
+
}
|
|
1957
|
+
let index = start + 1;
|
|
1958
|
+
while (index < end && isXmlNameCharacter2(source[index])) {
|
|
1959
|
+
index += 1;
|
|
1960
|
+
}
|
|
1961
|
+
return { name: source.slice(start, index), index };
|
|
1962
|
+
}
|
|
1963
|
+
function validateCharacterReference(entity) {
|
|
1964
|
+
const isHexadecimal = entity.startsWith("#x") || entity.startsWith("#X");
|
|
1965
|
+
const isDecimal = entity.startsWith("#");
|
|
1966
|
+
if (!isHexadecimal && !isDecimal) {
|
|
1967
|
+
if (!XML_ENTITY_NAMES.has(entity)) {
|
|
1968
|
+
fail(`Unknown XML entity: &${entity};`);
|
|
1969
|
+
}
|
|
1970
|
+
return;
|
|
1971
|
+
}
|
|
1972
|
+
const digits = entity.slice(isHexadecimal ? 2 : 1);
|
|
1973
|
+
const validDigits = isHexadecimal ? /^[0-9A-Fa-f]+$/.test(digits) : /^[0-9]+$/.test(digits);
|
|
1974
|
+
const codePoint = Number.parseInt(digits, isHexadecimal ? 16 : 10);
|
|
1975
|
+
if (!validDigits || !Number.isInteger(codePoint) || codePoint < 0 || codePoint > 1114111 || codePoint >= 55296 && codePoint <= 57343 || codePoint < 32 && ![9, 10, 13].includes(codePoint)) {
|
|
1976
|
+
fail(`Invalid XML character reference: &${entity};`);
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
function validateEntityReferences(value) {
|
|
1980
|
+
let index = 0;
|
|
1981
|
+
while (true) {
|
|
1982
|
+
const ampersand = value.indexOf("&", index);
|
|
1983
|
+
if (ampersand === -1) {
|
|
1984
|
+
return;
|
|
1985
|
+
}
|
|
1986
|
+
const semicolon = value.indexOf(";", ampersand + 1);
|
|
1987
|
+
if (semicolon === -1) {
|
|
1988
|
+
fail("Unterminated XML entity reference");
|
|
1989
|
+
}
|
|
1990
|
+
validateCharacterReference(value.slice(ampersand + 1, semicolon));
|
|
1991
|
+
index = semicolon + 1;
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
function findTagEnd(source, start, hasInternalSubset = false) {
|
|
1995
|
+
let quote;
|
|
1996
|
+
let subsetDepth = 0;
|
|
1997
|
+
for (let index = start + 1; index < source.length; index += 1) {
|
|
1998
|
+
const character = source[index];
|
|
1999
|
+
if (quote !== void 0) {
|
|
2000
|
+
if (character === quote) {
|
|
2001
|
+
quote = void 0;
|
|
2002
|
+
}
|
|
2003
|
+
continue;
|
|
2004
|
+
}
|
|
2005
|
+
if (character === '"' || character === "'") {
|
|
2006
|
+
quote = character;
|
|
2007
|
+
continue;
|
|
2008
|
+
}
|
|
2009
|
+
if (hasInternalSubset) {
|
|
2010
|
+
if (character === "[") {
|
|
2011
|
+
subsetDepth += 1;
|
|
2012
|
+
continue;
|
|
2013
|
+
}
|
|
2014
|
+
if (character === "]" && subsetDepth > 0) {
|
|
2015
|
+
subsetDepth -= 1;
|
|
2016
|
+
continue;
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
if (character === ">" && subsetDepth === 0) {
|
|
2020
|
+
return index;
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
fail("Unclosed XML markup");
|
|
2024
|
+
}
|
|
2025
|
+
function parseStartTag(source, start, end) {
|
|
2026
|
+
const nameResult = readName(source, start + 1, end);
|
|
2027
|
+
let index = nameResult.index;
|
|
2028
|
+
let hasAttribute = false;
|
|
2029
|
+
const attributeNames = /* @__PURE__ */ new Set();
|
|
2030
|
+
while (index < end) {
|
|
2031
|
+
const beforeWhitespace = index;
|
|
2032
|
+
index = skipWhitespace(source, index);
|
|
2033
|
+
if (index === end) {
|
|
2034
|
+
break;
|
|
2035
|
+
}
|
|
2036
|
+
if (source[index] === "/") {
|
|
2037
|
+
if (index + 1 !== end) {
|
|
2038
|
+
fail("Invalid XML self-closing tag");
|
|
2039
|
+
}
|
|
2040
|
+
return { name: nameResult.name, selfClosing: true };
|
|
2041
|
+
}
|
|
2042
|
+
if (hasAttribute && beforeWhitespace === index) {
|
|
2043
|
+
fail("XML attributes must be separated by whitespace");
|
|
2044
|
+
}
|
|
2045
|
+
const attribute = readName(source, index, end);
|
|
2046
|
+
index = skipWhitespace(source, attribute.index);
|
|
2047
|
+
if (source[index] !== "=") {
|
|
2048
|
+
fail(`XML attribute ${attribute.name} must have a value`);
|
|
2049
|
+
}
|
|
2050
|
+
index = skipWhitespace(source, index + 1);
|
|
2051
|
+
const quote = source[index];
|
|
2052
|
+
if (quote !== '"' && quote !== "'") {
|
|
2053
|
+
fail(`XML attribute ${attribute.name} must use a quoted value`);
|
|
2054
|
+
}
|
|
2055
|
+
index += 1;
|
|
2056
|
+
const valueStart = index;
|
|
2057
|
+
while (index < end && source[index] !== quote) {
|
|
2058
|
+
if (source[index] === "<") {
|
|
2059
|
+
fail(`Invalid "<" in XML attribute ${attribute.name}`);
|
|
2060
|
+
}
|
|
2061
|
+
index += 1;
|
|
2062
|
+
}
|
|
2063
|
+
if (index === end) {
|
|
2064
|
+
fail(`Unclosed XML attribute ${attribute.name}`);
|
|
2065
|
+
}
|
|
2066
|
+
if (attributeNames.has(attribute.name)) {
|
|
2067
|
+
fail(`Duplicate XML attribute: ${attribute.name}`);
|
|
2068
|
+
}
|
|
2069
|
+
attributeNames.add(attribute.name);
|
|
2070
|
+
validateEntityReferences(source.slice(valueStart, index));
|
|
2071
|
+
index += 1;
|
|
2072
|
+
hasAttribute = true;
|
|
2073
|
+
}
|
|
2074
|
+
return { name: nameResult.name, selfClosing: false };
|
|
2075
|
+
}
|
|
2076
|
+
function parseClosingTag(source, start, end) {
|
|
2077
|
+
const nameResult = readName(source, start + 2, end);
|
|
2078
|
+
if (skipWhitespace(source, nameResult.index) !== end) {
|
|
2079
|
+
fail("Invalid XML closing tag");
|
|
2080
|
+
}
|
|
2081
|
+
return nameResult.name;
|
|
2082
|
+
}
|
|
2083
|
+
function parseProcessingInstruction(source, start, end) {
|
|
2084
|
+
readName(source, start + 2, end);
|
|
2085
|
+
}
|
|
2086
|
+
function parseDeclaration(source, start, end) {
|
|
2087
|
+
readName(source, start + 2, end);
|
|
2088
|
+
}
|
|
2089
|
+
function appendNode2(nodes, node) {
|
|
2090
|
+
const previous = nodes[nodes.length - 1];
|
|
2091
|
+
if (node.kind === "text" && previous?.kind === "text") {
|
|
2092
|
+
previous.value += node.value;
|
|
2093
|
+
return;
|
|
2094
|
+
}
|
|
2095
|
+
nodes.push(node);
|
|
2096
|
+
}
|
|
2097
|
+
function currentElement(stack) {
|
|
2098
|
+
return stack[stack.length - 1];
|
|
2099
|
+
}
|
|
2100
|
+
function parseXml(source) {
|
|
2101
|
+
const children = [];
|
|
2102
|
+
const stack = [];
|
|
2103
|
+
let root;
|
|
2104
|
+
let index = 0;
|
|
2105
|
+
while (index < source.length) {
|
|
2106
|
+
if (source[index] !== "<") {
|
|
2107
|
+
const textStart = index;
|
|
2108
|
+
while (index < source.length && source[index] !== "<") {
|
|
2109
|
+
index += 1;
|
|
2110
|
+
}
|
|
2111
|
+
const value = source.slice(textStart, index);
|
|
2112
|
+
if (value.includes("]]>")) {
|
|
2113
|
+
fail("CDATA termination is not valid in ordinary XML text");
|
|
2114
|
+
}
|
|
2115
|
+
validateEntityReferences(value);
|
|
2116
|
+
if (stack.length === 0 && value.trim() !== "") {
|
|
2117
|
+
fail("Unexpected text outside the root XML element");
|
|
2118
|
+
}
|
|
2119
|
+
appendNode2(currentElement(stack)?.children ?? children, { kind: "text", value });
|
|
2120
|
+
continue;
|
|
2121
|
+
}
|
|
2122
|
+
if (source.startsWith("<!--", index)) {
|
|
2123
|
+
const end2 = source.indexOf("-->", index + 4);
|
|
2124
|
+
if (end2 === -1) {
|
|
2125
|
+
fail("Unclosed XML comment");
|
|
2126
|
+
}
|
|
2127
|
+
const content = source.slice(index + 4, end2);
|
|
2128
|
+
if (content.includes("--") || content.endsWith("-")) {
|
|
2129
|
+
fail("Invalid XML comment");
|
|
2130
|
+
}
|
|
2131
|
+
appendNode2(currentElement(stack)?.children ?? children, {
|
|
2132
|
+
kind: "comment",
|
|
2133
|
+
raw: source.slice(index, end2 + 3)
|
|
2134
|
+
});
|
|
2135
|
+
index = end2 + 3;
|
|
2136
|
+
continue;
|
|
2137
|
+
}
|
|
2138
|
+
if (source.startsWith("<![CDATA[", index)) {
|
|
2139
|
+
const end2 = source.indexOf("]]>", index + "<![CDATA[".length);
|
|
2140
|
+
if (end2 === -1) {
|
|
2141
|
+
fail("Unclosed XML CDATA section");
|
|
2142
|
+
}
|
|
2143
|
+
if (stack.length === 0) {
|
|
2144
|
+
fail("CDATA is not allowed outside the root XML element");
|
|
2145
|
+
}
|
|
2146
|
+
appendNode2(currentElement(stack)?.children ?? children, {
|
|
2147
|
+
kind: "cdata",
|
|
2148
|
+
raw: source.slice(index, end2 + 3)
|
|
2149
|
+
});
|
|
2150
|
+
index = end2 + 3;
|
|
2151
|
+
continue;
|
|
2152
|
+
}
|
|
2153
|
+
if (source.startsWith("<?", index)) {
|
|
2154
|
+
const end2 = source.indexOf("?>", index + 2);
|
|
2155
|
+
if (end2 === -1) {
|
|
2156
|
+
fail("Unclosed XML processing instruction");
|
|
2157
|
+
}
|
|
2158
|
+
parseProcessingInstruction(source, index, end2);
|
|
2159
|
+
appendNode2(currentElement(stack)?.children ?? children, {
|
|
2160
|
+
kind: "processing-instruction",
|
|
2161
|
+
raw: source.slice(index, end2 + 2)
|
|
2162
|
+
});
|
|
2163
|
+
index = end2 + 2;
|
|
2164
|
+
continue;
|
|
2165
|
+
}
|
|
2166
|
+
if (source.startsWith("</", index)) {
|
|
2167
|
+
const end2 = findTagEnd(source, index);
|
|
2168
|
+
const name2 = parseClosingTag(source, index, end2);
|
|
2169
|
+
const element = currentElement(stack);
|
|
2170
|
+
if (element === void 0 || element.name !== name2) {
|
|
2171
|
+
fail(`Mismatched closing XML element: </${name2}>`);
|
|
2172
|
+
}
|
|
2173
|
+
element.close = source.slice(index, end2 + 1);
|
|
2174
|
+
stack.pop();
|
|
2175
|
+
index = end2 + 1;
|
|
2176
|
+
continue;
|
|
2177
|
+
}
|
|
2178
|
+
if (source.startsWith("<!", index)) {
|
|
2179
|
+
const end2 = findTagEnd(source, index, true);
|
|
2180
|
+
parseDeclaration(source, index, end2);
|
|
2181
|
+
appendNode2(currentElement(stack)?.children ?? children, {
|
|
2182
|
+
kind: "declaration",
|
|
2183
|
+
raw: source.slice(index, end2 + 1)
|
|
2184
|
+
});
|
|
2185
|
+
index = end2 + 1;
|
|
2186
|
+
continue;
|
|
2187
|
+
}
|
|
2188
|
+
const end = findTagEnd(source, index);
|
|
2189
|
+
const { name, selfClosing } = parseStartTag(source, index, end);
|
|
2190
|
+
if (stack.length === 0) {
|
|
2191
|
+
if (root !== void 0) {
|
|
2192
|
+
fail("Multiple root XML elements are not allowed");
|
|
2193
|
+
}
|
|
2194
|
+
root = {
|
|
2195
|
+
kind: "element",
|
|
2196
|
+
name,
|
|
2197
|
+
open: source.slice(index, end + 1),
|
|
2198
|
+
selfClosing,
|
|
2199
|
+
children: []
|
|
2200
|
+
};
|
|
2201
|
+
children.push(root);
|
|
2202
|
+
} else {
|
|
2203
|
+
const element = {
|
|
2204
|
+
kind: "element",
|
|
2205
|
+
name,
|
|
2206
|
+
open: source.slice(index, end + 1),
|
|
2207
|
+
selfClosing,
|
|
2208
|
+
children: []
|
|
2209
|
+
};
|
|
2210
|
+
currentElement(stack)?.children.push(element);
|
|
2211
|
+
if (!selfClosing) {
|
|
2212
|
+
stack.push(element);
|
|
2213
|
+
}
|
|
2214
|
+
index = end + 1;
|
|
2215
|
+
continue;
|
|
2216
|
+
}
|
|
2217
|
+
if (!selfClosing) {
|
|
2218
|
+
stack.push(root);
|
|
2219
|
+
}
|
|
2220
|
+
index = end + 1;
|
|
2221
|
+
}
|
|
2222
|
+
if (stack.length > 0) {
|
|
2223
|
+
fail(`Unclosed XML element: <${currentElement(stack)?.name}>`);
|
|
2224
|
+
}
|
|
2225
|
+
if (root === void 0) {
|
|
2226
|
+
fail("XML input does not contain a root element");
|
|
2227
|
+
}
|
|
2228
|
+
return { children, root };
|
|
2229
|
+
}
|
|
2230
|
+
function indentation(depth) {
|
|
2231
|
+
return INDENT.repeat(depth);
|
|
2232
|
+
}
|
|
2233
|
+
function renderInline(node) {
|
|
2234
|
+
const content = node.children.map((child) => {
|
|
2235
|
+
if (child.kind === "element") {
|
|
2236
|
+
return renderInline(child);
|
|
2237
|
+
}
|
|
2238
|
+
return child.kind === "text" ? child.value : child.raw;
|
|
2239
|
+
}).join("");
|
|
2240
|
+
return `${node.open}${content}${node.close ?? ""}`;
|
|
2241
|
+
}
|
|
2242
|
+
function hasOnlyTextChildren(node) {
|
|
2243
|
+
return node.children.every((child) => child.kind === "text");
|
|
2244
|
+
}
|
|
2245
|
+
function hasSignificantText(node) {
|
|
2246
|
+
return node.children.some((child) => child.kind === "text" && child.value.trim() !== "");
|
|
2247
|
+
}
|
|
2248
|
+
function hasOnlyWhitespaceText(node) {
|
|
2249
|
+
return node.children.every((child) => child.kind === "text" && child.value.trim() === "");
|
|
2250
|
+
}
|
|
2251
|
+
function toSelfClosingTag(open) {
|
|
2252
|
+
return `${open.slice(0, -1).trimEnd()}/>`;
|
|
2253
|
+
}
|
|
2254
|
+
function formatElement(node, depth, isRoot) {
|
|
2255
|
+
const prefix = indentation(depth);
|
|
2256
|
+
if (node.selfClosing) {
|
|
2257
|
+
return [`${prefix}${node.open}`];
|
|
2258
|
+
}
|
|
2259
|
+
if (node.close === void 0) {
|
|
2260
|
+
fail(`Unclosed XML element: <${node.name}>`);
|
|
2261
|
+
}
|
|
2262
|
+
if (INTRINSICALLY_EMPTY_ELEMENTS.has(node.name) && hasOnlyWhitespaceText(node)) {
|
|
2263
|
+
return [`${prefix}${toSelfClosingTag(node.open)}`];
|
|
2264
|
+
}
|
|
2265
|
+
if (isRoot && hasOnlyTextChildren(node)) {
|
|
2266
|
+
const text = node.children.filter((child) => child.kind === "text").map((child) => child.value).join("");
|
|
2267
|
+
const trimmedText = text.trim();
|
|
2268
|
+
if (trimmedText === "") {
|
|
2269
|
+
return [`${prefix}${node.open}`, `${prefix}${node.close}`];
|
|
2270
|
+
}
|
|
2271
|
+
if (text.includes("\n") || text.includes("\r") || text !== trimmedText) {
|
|
2272
|
+
return [`${prefix}${renderInline(node)}`];
|
|
2273
|
+
}
|
|
2274
|
+
return [`${prefix}${node.open}`, `${indentation(depth + 1)}${trimmedText}`, `${prefix}${node.close}`];
|
|
2275
|
+
}
|
|
2276
|
+
if (hasSignificantText(node)) {
|
|
2277
|
+
return [`${prefix}${renderInline(node)}`];
|
|
2278
|
+
}
|
|
2279
|
+
const lines = [`${prefix}${node.open}`];
|
|
2280
|
+
for (const child of node.children) {
|
|
2281
|
+
if (child.kind === "text") {
|
|
2282
|
+
continue;
|
|
2283
|
+
}
|
|
2284
|
+
if (child.kind === "element") {
|
|
2285
|
+
lines.push(...formatElement(child, depth + 1, false));
|
|
2286
|
+
} else {
|
|
2287
|
+
lines.push(`${indentation(depth + 1)}${child.raw}`);
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2290
|
+
lines.push(`${prefix}${node.close}`);
|
|
2291
|
+
return lines;
|
|
2292
|
+
}
|
|
2293
|
+
function stripTrailingWhitespace(value) {
|
|
2294
|
+
return value.replace(/[ \t]+$/gm, "");
|
|
2295
|
+
}
|
|
2296
|
+
function getTrailingLineBreaks(value) {
|
|
2297
|
+
let start = value.length;
|
|
2298
|
+
while (start > 0) {
|
|
2299
|
+
if (value[start - 1] === "\n") {
|
|
2300
|
+
start -= 1;
|
|
2301
|
+
if (start > 0 && value[start - 1] === "\r") {
|
|
2302
|
+
start -= 1;
|
|
2303
|
+
}
|
|
2304
|
+
continue;
|
|
2305
|
+
}
|
|
2306
|
+
if (value[start - 1] === "\r") {
|
|
2307
|
+
start -= 1;
|
|
2308
|
+
continue;
|
|
2309
|
+
}
|
|
2310
|
+
break;
|
|
2311
|
+
}
|
|
2312
|
+
return value.slice(start);
|
|
2313
|
+
}
|
|
2314
|
+
function stripTrailingLineBreaks(value) {
|
|
2315
|
+
let end = value.length;
|
|
2316
|
+
while (end > 0) {
|
|
2317
|
+
if (value[end - 1] === "\n") {
|
|
2318
|
+
end -= 1;
|
|
2319
|
+
if (end > 0 && value[end - 1] === "\r") {
|
|
2320
|
+
end -= 1;
|
|
2321
|
+
}
|
|
2322
|
+
continue;
|
|
2323
|
+
}
|
|
2324
|
+
if (value[end - 1] === "\r") {
|
|
2325
|
+
end -= 1;
|
|
2326
|
+
continue;
|
|
2327
|
+
}
|
|
2328
|
+
break;
|
|
2329
|
+
}
|
|
2330
|
+
return value.slice(0, end);
|
|
2331
|
+
}
|
|
2332
|
+
function preserveTrailingLineBreak(formatted, trailingLineBreaks) {
|
|
2333
|
+
if (trailingLineBreaks === "") {
|
|
2334
|
+
return formatted;
|
|
2335
|
+
}
|
|
2336
|
+
return `${stripTrailingLineBreaks(formatted)}${trailingLineBreaks}`;
|
|
2337
|
+
}
|
|
2338
|
+
function renderDocument(document) {
|
|
2339
|
+
const lines = [];
|
|
2340
|
+
for (const child of document.children) {
|
|
2341
|
+
if (child.kind === "text") {
|
|
2342
|
+
continue;
|
|
2343
|
+
}
|
|
2344
|
+
if (child.kind === "element") {
|
|
2345
|
+
lines.push(...formatElement(child, 0, child === document.root));
|
|
2346
|
+
} else {
|
|
2347
|
+
lines.push(child.raw);
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
return stripTrailingWhitespace(lines.join("\n")).trim();
|
|
2351
|
+
}
|
|
2352
|
+
function unwrapFormattedFragment(formatted) {
|
|
2353
|
+
const opening = `<${FRAGMENT_ROOT}>`;
|
|
2354
|
+
const closing = `</${FRAGMENT_ROOT}>`;
|
|
2355
|
+
if (!formatted.startsWith(opening) || !formatted.endsWith(closing)) {
|
|
2356
|
+
return void 0;
|
|
2357
|
+
}
|
|
2358
|
+
if (formatted === `${opening}${closing}`) {
|
|
2359
|
+
return "";
|
|
2360
|
+
}
|
|
2361
|
+
const multilineOpening = `${opening}
|
|
2362
|
+
`;
|
|
2363
|
+
const multilineClosing = `
|
|
2364
|
+
${closing}`;
|
|
2365
|
+
if (formatted.startsWith(multilineOpening) && formatted.endsWith(multilineClosing)) {
|
|
2366
|
+
const content = formatted.slice(multilineOpening.length, -multilineClosing.length);
|
|
2367
|
+
return content.split("\n").map((line) => line.startsWith(INDENT) ? line.slice(INDENT.length) : line).join("\n");
|
|
2368
|
+
}
|
|
2369
|
+
return formatted.slice(opening.length, -closing.length);
|
|
2370
|
+
}
|
|
2371
|
+
function formatXmlFragment(xml) {
|
|
2372
|
+
const trailingLineBreaks = getTrailingLineBreaks(xml);
|
|
2373
|
+
const source = xml.trim();
|
|
2374
|
+
if (source === "") {
|
|
2375
|
+
return "";
|
|
2376
|
+
}
|
|
2377
|
+
const wrapped = `<${FRAGMENT_ROOT}>${source}</${FRAGMENT_ROOT}>`;
|
|
2378
|
+
let formatted;
|
|
2379
|
+
try {
|
|
2380
|
+
formatted = renderDocument(parseXml(wrapped));
|
|
2381
|
+
} catch {
|
|
2382
|
+
return xml;
|
|
2383
|
+
}
|
|
2384
|
+
return preserveTrailingLineBreak(unwrapFormattedFragment(formatted) ?? xml, trailingLineBreaks);
|
|
2385
|
+
}
|
|
2386
|
+
|
|
2387
|
+
// packages/ssml-editor-react/src/editableSsml.ts
|
|
2388
|
+
function isSsmlElement(node) {
|
|
2389
|
+
return typeof node !== "string" && node.type !== "text";
|
|
2390
|
+
}
|
|
2391
|
+
function isVoice(element) {
|
|
2392
|
+
return element.type === "voice";
|
|
2393
|
+
}
|
|
2394
|
+
function isProsody(element) {
|
|
2395
|
+
return element.type === "prosody";
|
|
2396
|
+
}
|
|
2397
|
+
function getSsmlElementName(element) {
|
|
2398
|
+
return element.type === "custom" || element.type === "element" ? element.name : element.type;
|
|
2399
|
+
}
|
|
2400
|
+
function findEditableTagEnd(source, start) {
|
|
2401
|
+
let quote;
|
|
2402
|
+
for (let index = start + 1; index < source.length; index += 1) {
|
|
2403
|
+
const character = source[index];
|
|
2404
|
+
if (quote !== void 0) {
|
|
2405
|
+
if (character === quote) {
|
|
2406
|
+
quote = void 0;
|
|
2407
|
+
}
|
|
2408
|
+
continue;
|
|
2409
|
+
}
|
|
2410
|
+
if (character === '"' || character === "'") {
|
|
2411
|
+
quote = character;
|
|
2412
|
+
continue;
|
|
2413
|
+
}
|
|
2414
|
+
if (character === ">") {
|
|
2415
|
+
return index;
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
return source.length;
|
|
2419
|
+
}
|
|
2420
|
+
function collectEditableStartTags(source) {
|
|
2421
|
+
const tags = [];
|
|
2422
|
+
let index = 0;
|
|
2423
|
+
while (index < source.length) {
|
|
2424
|
+
if (source[index] !== "<") {
|
|
2425
|
+
index += 1;
|
|
2426
|
+
continue;
|
|
2427
|
+
}
|
|
2428
|
+
if (source.startsWith("<!--", index)) {
|
|
2429
|
+
const end2 = source.indexOf("-->", index + 4);
|
|
2430
|
+
index = end2 === -1 ? source.length : end2 + 3;
|
|
2431
|
+
continue;
|
|
2432
|
+
}
|
|
2433
|
+
if (source.startsWith("<![CDATA[", index)) {
|
|
2434
|
+
const end2 = source.indexOf("]]>", index + 9);
|
|
2435
|
+
index = end2 === -1 ? source.length : end2 + 3;
|
|
2436
|
+
continue;
|
|
2437
|
+
}
|
|
2438
|
+
if (source.startsWith("<?", index)) {
|
|
2439
|
+
const end2 = source.indexOf("?>", index + 2);
|
|
2440
|
+
index = end2 === -1 ? source.length : end2 + 2;
|
|
2441
|
+
continue;
|
|
2442
|
+
}
|
|
2443
|
+
if (source.startsWith("</", index) || source.startsWith("<!", index)) {
|
|
2444
|
+
const end2 = findEditableTagEnd(source, index);
|
|
2445
|
+
index = end2 === source.length ? source.length : end2 + 1;
|
|
2446
|
+
continue;
|
|
2447
|
+
}
|
|
2448
|
+
const end = findEditableTagEnd(source, index);
|
|
2449
|
+
if (end === source.length) {
|
|
2450
|
+
break;
|
|
2451
|
+
}
|
|
2452
|
+
const raw = source.slice(index, end + 1);
|
|
2453
|
+
const match = raw.match(/^<([A-Za-z_][A-Za-z0-9_.:-]*)/);
|
|
2454
|
+
if (match) {
|
|
2455
|
+
tags.push({ name: match[1], selfClosing: /\/\s*>$/.test(raw) });
|
|
2456
|
+
}
|
|
2457
|
+
index = end + 1;
|
|
2458
|
+
}
|
|
2459
|
+
return tags;
|
|
2460
|
+
}
|
|
2461
|
+
function preserveEmptyPairElements(nodes, startTags, startTagIndex) {
|
|
2462
|
+
return nodes.map((node) => {
|
|
2463
|
+
if (!isSsmlElement(node)) {
|
|
2464
|
+
return node;
|
|
2465
|
+
}
|
|
2466
|
+
const elementName = getSsmlElementName(node);
|
|
2467
|
+
const startTag = startTags[startTagIndex.value];
|
|
2468
|
+
startTagIndex.value += 1;
|
|
2469
|
+
if (node.children === void 0 || node.children.length === 0) {
|
|
2470
|
+
return startTag?.name === elementName && !startTag.selfClosing && !INTRINSICALLY_EMPTY_ELEMENTS.has(elementName) ? { ...node, children: [""] } : node;
|
|
2471
|
+
}
|
|
2472
|
+
const children = preserveEmptyPairElements(node.children, startTags, startTagIndex);
|
|
2473
|
+
if (children.every((child, index) => child === node.children?.[index])) {
|
|
2474
|
+
return node;
|
|
2475
|
+
}
|
|
2476
|
+
return { ...node, children };
|
|
2477
|
+
});
|
|
2478
|
+
}
|
|
2479
|
+
function getDocumentChildren2(document) {
|
|
2480
|
+
return document.children ?? (document.content === void 0 ? [] : [document.content]);
|
|
2481
|
+
}
|
|
2482
|
+
function findFirstElementPath(nodes, predicate, ancestors = []) {
|
|
2483
|
+
for (const node of nodes) {
|
|
2484
|
+
if (!isSsmlElement(node)) {
|
|
2485
|
+
continue;
|
|
2486
|
+
}
|
|
2487
|
+
const path = [...ancestors, node];
|
|
2488
|
+
if (predicate(node)) {
|
|
2489
|
+
return path;
|
|
2490
|
+
}
|
|
2491
|
+
const childPath = findFirstElementPath(node.children ?? [], predicate, path);
|
|
2492
|
+
if (childPath) {
|
|
2493
|
+
return childPath;
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
return void 0;
|
|
2497
|
+
}
|
|
2498
|
+
function updateFirstElement(nodes, predicate, update) {
|
|
2499
|
+
let updated = false;
|
|
2500
|
+
const nextNodes = nodes.map((node) => {
|
|
2501
|
+
if (updated || !isSsmlElement(node)) {
|
|
2502
|
+
return node;
|
|
2503
|
+
}
|
|
2504
|
+
if (predicate(node)) {
|
|
2505
|
+
updated = true;
|
|
2506
|
+
return update(node);
|
|
2507
|
+
}
|
|
2508
|
+
if (node.children) {
|
|
2509
|
+
const result = updateFirstElement(node.children, predicate, update);
|
|
2510
|
+
if (result.updated) {
|
|
2511
|
+
updated = true;
|
|
2512
|
+
return { ...node, children: result.nodes };
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2515
|
+
return node;
|
|
2516
|
+
});
|
|
2517
|
+
return { nodes: nextNodes, updated };
|
|
2518
|
+
}
|
|
2519
|
+
function withChildren(document, children) {
|
|
2520
|
+
const nextDocument = { ...document, children };
|
|
2521
|
+
if (nextDocument.content !== void 0) {
|
|
2522
|
+
delete nextDocument.content;
|
|
2523
|
+
}
|
|
2524
|
+
return nextDocument;
|
|
2525
|
+
}
|
|
2526
|
+
function parseEditableText(value, lang) {
|
|
2527
|
+
try {
|
|
2528
|
+
const wrapper = buildSsml({
|
|
2529
|
+
version: "1.0",
|
|
2530
|
+
lang,
|
|
2531
|
+
children: []
|
|
2532
|
+
});
|
|
2533
|
+
const openingTagEnd = wrapper.indexOf(">") + 1;
|
|
2534
|
+
const children = parseSsml(`${wrapper.slice(0, openingTagEnd)}${value}</speak>`).children ?? [];
|
|
2535
|
+
return children.some(isSsmlElement) ? preserveEmptyPairElements(children, collectEditableStartTags(value), { value: 0 }) : [value];
|
|
2536
|
+
} catch {
|
|
2537
|
+
return [value];
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2540
|
+
function serializeEditableText(nodes, lang) {
|
|
2541
|
+
if (nodes.length === 1 && typeof nodes[0] === "string") {
|
|
2542
|
+
return nodes[0];
|
|
2543
|
+
}
|
|
2544
|
+
const xml = buildSsml({
|
|
2545
|
+
version: "1.0",
|
|
2546
|
+
lang,
|
|
2547
|
+
children: nodes
|
|
2548
|
+
});
|
|
2549
|
+
const contentStart = xml.indexOf(">") + 1;
|
|
2550
|
+
return xml.slice(contentStart, -"</speak>".length);
|
|
2551
|
+
}
|
|
2552
|
+
function getEditableRegion(document) {
|
|
2553
|
+
const children = getDocumentChildren2(document);
|
|
2554
|
+
const path = findFirstElementPath(children, isProsody) ?? findFirstElementPath(children, isVoice);
|
|
2555
|
+
const element = path ? path[path.length - 1] : void 0;
|
|
2556
|
+
const voice = path ? [...path].reverse().find(isVoice) : void 0;
|
|
2557
|
+
return {
|
|
2558
|
+
children: element?.children ?? children,
|
|
2559
|
+
...voice ? { voiceName: voice.name } : {}
|
|
2560
|
+
};
|
|
2561
|
+
}
|
|
2562
|
+
function getEditableText(document) {
|
|
2563
|
+
return serializeEditableText(getEditableRegion(document).children, document.lang);
|
|
2564
|
+
}
|
|
2565
|
+
function updateEditableText(document, value) {
|
|
2566
|
+
const nextChildren = parseEditableText(value, document.lang);
|
|
2567
|
+
const editableChildren = nextChildren.length > 0 ? nextChildren : [value];
|
|
2568
|
+
const children = getDocumentChildren2(document);
|
|
2569
|
+
const prosodyResult = updateFirstElement(children, isProsody, (prosody) => ({
|
|
2570
|
+
...prosody,
|
|
2571
|
+
children: editableChildren
|
|
2572
|
+
}));
|
|
2573
|
+
if (prosodyResult.updated) {
|
|
2574
|
+
return withChildren(document, prosodyResult.nodes);
|
|
2575
|
+
}
|
|
2576
|
+
const voiceResult = updateFirstElement(children, isVoice, (voice) => ({
|
|
2577
|
+
...voice,
|
|
2578
|
+
children: editableChildren
|
|
2579
|
+
}));
|
|
2580
|
+
if (voiceResult.updated) {
|
|
2581
|
+
return withChildren(document, voiceResult.nodes);
|
|
2582
|
+
}
|
|
2583
|
+
return withChildren(document, editableChildren);
|
|
2584
|
+
}
|
|
2585
|
+
|
|
2586
|
+
// packages/ssml-editor-react/src/ssmlInsertion.ts
|
|
2587
|
+
function isLineStart(value, offset) {
|
|
2588
|
+
return offset === 0 || value[offset - 1] === "\n" || value[offset - 1] === "\r";
|
|
2589
|
+
}
|
|
2590
|
+
function isLineEnd(value, offset) {
|
|
2591
|
+
return offset === value.length || value[offset] === "\n" || value[offset] === "\r";
|
|
2592
|
+
}
|
|
2593
|
+
function getLineBreakAt(value, offset) {
|
|
2594
|
+
if (value.startsWith("\r\n", offset)) {
|
|
2595
|
+
return "\r\n";
|
|
2596
|
+
}
|
|
2597
|
+
if (value[offset] === "\n" || value[offset] === "\r") {
|
|
2598
|
+
return value[offset];
|
|
2599
|
+
}
|
|
2600
|
+
return "";
|
|
2601
|
+
}
|
|
2602
|
+
function startsWithLineBreak(value) {
|
|
2603
|
+
return value.startsWith("\n") || value.startsWith("\r");
|
|
2604
|
+
}
|
|
2605
|
+
function endsWithLineBreak(value) {
|
|
2606
|
+
return value.endsWith("\n") || value.endsWith("\r");
|
|
2607
|
+
}
|
|
2608
|
+
function createSsmlInsertionEdit(source, startOffset, endOffset, template, eol = "\n", selectedText = startOffset === endOffset ? "" : source.slice(startOffset, endOffset)) {
|
|
2609
|
+
if (template.mode === SSML_INSERTION_MODES.wrap) {
|
|
2610
|
+
const trailingLineBreak2 = getLineBreakAt(source, endOffset) === "" ? eol : "";
|
|
2611
|
+
return {
|
|
2612
|
+
replacement: `${template.prefix}${selectedText}${template.suffix}${trailingLineBreak2}`,
|
|
2613
|
+
selectionOffset: template.prefix.length
|
|
2614
|
+
};
|
|
2615
|
+
}
|
|
2616
|
+
const followingLineBreak = getLineBreakAt(source, endOffset);
|
|
2617
|
+
const leadingLineBreak = !isLineStart(source, startOffset) && !startsWithLineBreak(template.prefix) ? eol : "";
|
|
2618
|
+
const needsTrailingLineBreak = selectedText.length > 0 ? !selectedText.startsWith("\n") && !selectedText.startsWith("\r") : !isLineEnd(source, endOffset) || followingLineBreak === "";
|
|
2619
|
+
const trailingLineBreak = needsTrailingLineBreak && !endsWithLineBreak(template.prefix) ? eol : "";
|
|
2620
|
+
const insertionPrefix = `${leadingLineBreak}${template.prefix}`;
|
|
2621
|
+
return {
|
|
2622
|
+
replacement: `${insertionPrefix}${trailingLineBreak}${selectedText}`,
|
|
2623
|
+
selectionOffset: insertionPrefix.length + trailingLineBreak.length + (selectedText.length === 0 && trailingLineBreak === "" ? followingLineBreak.length : 0)
|
|
2624
|
+
};
|
|
2625
|
+
}
|
|
2626
|
+
|
|
2627
|
+
// packages/ssml-editor-react/src/ssmlContext.ts
|
|
2628
|
+
function findTagEnd2(source, start, limit) {
|
|
2629
|
+
let quote;
|
|
2630
|
+
for (let index = start + 1; index < limit; index += 1) {
|
|
2631
|
+
const character = source[index];
|
|
2632
|
+
if (quote !== void 0) {
|
|
2633
|
+
if (character === quote) {
|
|
2634
|
+
quote = void 0;
|
|
2635
|
+
}
|
|
2636
|
+
continue;
|
|
2637
|
+
}
|
|
2638
|
+
if (character === '"' || character === "'") {
|
|
2639
|
+
quote = character;
|
|
2640
|
+
continue;
|
|
2641
|
+
}
|
|
2642
|
+
if (character === ">") {
|
|
2643
|
+
return index;
|
|
2644
|
+
}
|
|
2645
|
+
}
|
|
2646
|
+
return -1;
|
|
2647
|
+
}
|
|
2648
|
+
function getVoiceName(tag) {
|
|
2649
|
+
return tag.match(/\bname\s*=\s*(["'])([\s\S]*?)\1/i)?.[2];
|
|
2650
|
+
}
|
|
2651
|
+
function closeElement(stack, name) {
|
|
2652
|
+
for (let index = stack.length - 1; index >= 0; index -= 1) {
|
|
2653
|
+
if (stack[index]?.name === name) {
|
|
2654
|
+
stack.splice(index);
|
|
2655
|
+
return;
|
|
2656
|
+
}
|
|
2657
|
+
}
|
|
2658
|
+
}
|
|
2659
|
+
function findActiveSsmlTags(source, offset) {
|
|
2660
|
+
const limit = Math.max(0, Math.min(offset, source.length));
|
|
2661
|
+
const stack = [];
|
|
2662
|
+
let index = 0;
|
|
2663
|
+
while (index < source.length) {
|
|
2664
|
+
const tagStart = source.indexOf("<", index);
|
|
2665
|
+
if (tagStart === -1 || tagStart > limit) {
|
|
2666
|
+
break;
|
|
2667
|
+
}
|
|
2668
|
+
const nonContentEnd = source.startsWith("<!--", tagStart) ? source.indexOf("-->", tagStart + 4) : source.startsWith("<![CDATA[", tagStart) ? source.indexOf("]]>", tagStart + 9) : source.startsWith("<?", tagStart) ? source.indexOf("?>", tagStart + 2) : void 0;
|
|
2669
|
+
if (nonContentEnd !== void 0) {
|
|
2670
|
+
const delimiterLength = source.startsWith("<?", tagStart) ? 2 : 3;
|
|
2671
|
+
const end = nonContentEnd === -1 ? source.length : nonContentEnd + delimiterLength;
|
|
2672
|
+
if (limit < end) {
|
|
2673
|
+
break;
|
|
2674
|
+
}
|
|
2675
|
+
index = end;
|
|
2676
|
+
continue;
|
|
2677
|
+
}
|
|
2678
|
+
const tagEnd = findTagEnd2(source, tagStart, source.length);
|
|
2679
|
+
const tag = source.slice(tagStart, tagEnd === -1 ? source.length : tagEnd + 1);
|
|
2680
|
+
const closingMatch = tag.match(/^<\s*\/\s*([A-Za-z_][A-Za-z0-9_.:-]*)/);
|
|
2681
|
+
const openingMatch = tag.match(/^<\s*([A-Za-z_][A-Za-z0-9_.:-]*)/);
|
|
2682
|
+
if (tagEnd === -1 || limit <= tagEnd) {
|
|
2683
|
+
if (openingMatch?.[1]) {
|
|
2684
|
+
stack.push({ name: openingMatch[1].toLowerCase() });
|
|
2685
|
+
}
|
|
2686
|
+
break;
|
|
2687
|
+
}
|
|
2688
|
+
if (closingMatch?.[1]) {
|
|
2689
|
+
closeElement(stack, closingMatch[1].toLowerCase());
|
|
2690
|
+
} else if (openingMatch?.[1] && !/\/\s*>$/.test(tag)) {
|
|
2691
|
+
stack.push({ name: openingMatch[1].toLowerCase() });
|
|
2692
|
+
}
|
|
2693
|
+
index = tagEnd + 1;
|
|
2694
|
+
}
|
|
2695
|
+
return new Set(stack.map(({ name }) => name));
|
|
2696
|
+
}
|
|
2697
|
+
function findSsmlVoiceContext(source, offset) {
|
|
2698
|
+
const limit = Math.max(0, Math.min(offset, source.length));
|
|
2699
|
+
const stack = [];
|
|
2700
|
+
let index = 0;
|
|
2701
|
+
while (index < limit) {
|
|
2702
|
+
const tagStart = source.indexOf("<", index);
|
|
2703
|
+
if (tagStart === -1 || tagStart >= limit) {
|
|
2704
|
+
break;
|
|
2705
|
+
}
|
|
2706
|
+
if (source.startsWith("<!--", tagStart)) {
|
|
2707
|
+
const end = source.indexOf("-->", tagStart + 4);
|
|
2708
|
+
index = end === -1 || end + 3 > limit ? limit : end + 3;
|
|
2709
|
+
continue;
|
|
2710
|
+
}
|
|
2711
|
+
if (source.startsWith("<![CDATA[", tagStart)) {
|
|
2712
|
+
const end = source.indexOf("]]>", tagStart + 9);
|
|
2713
|
+
index = end === -1 || end + 3 > limit ? limit : end + 3;
|
|
2714
|
+
continue;
|
|
2715
|
+
}
|
|
2716
|
+
if (source.startsWith("<?", tagStart)) {
|
|
2717
|
+
const end = source.indexOf("?>", tagStart + 2);
|
|
2718
|
+
index = end === -1 || end + 2 > limit ? limit : end + 2;
|
|
2719
|
+
continue;
|
|
2720
|
+
}
|
|
2721
|
+
const tagEnd = findTagEnd2(source, tagStart, limit);
|
|
2722
|
+
if (tagEnd === -1) {
|
|
2723
|
+
break;
|
|
2724
|
+
}
|
|
2725
|
+
const tag = source.slice(tagStart, tagEnd + 1);
|
|
2726
|
+
if (tag.startsWith("<!")) {
|
|
2727
|
+
index = tagEnd + 1;
|
|
2728
|
+
continue;
|
|
2729
|
+
}
|
|
2730
|
+
const closingMatch = tag.match(/^<\s*\/\s*([A-Za-z_][A-Za-z0-9_.:-]*)/);
|
|
2731
|
+
if (closingMatch?.[1]) {
|
|
2732
|
+
closeElement(stack, closingMatch[1].toLowerCase());
|
|
2733
|
+
index = tagEnd + 1;
|
|
2734
|
+
continue;
|
|
2735
|
+
}
|
|
2736
|
+
const openingMatch = tag.match(/^<\s*([A-Za-z_][A-Za-z0-9_.:-]*)/);
|
|
2737
|
+
if (openingMatch?.[1] && !/\/\s*>$/.test(tag)) {
|
|
2738
|
+
const name = openingMatch[1].toLowerCase();
|
|
2739
|
+
stack.push({
|
|
2740
|
+
name,
|
|
2741
|
+
...name === "voice" ? { voiceName: getVoiceName(tag) } : {}
|
|
2742
|
+
});
|
|
2743
|
+
}
|
|
2744
|
+
index = tagEnd + 1;
|
|
2745
|
+
}
|
|
2746
|
+
for (let stackIndex = stack.length - 1; stackIndex >= 0; stackIndex -= 1) {
|
|
2747
|
+
const element = stack[stackIndex];
|
|
2748
|
+
if (element?.name === "voice") {
|
|
2749
|
+
return element.voiceName === void 0 ? {} : { voiceName: element.voiceName };
|
|
2750
|
+
}
|
|
2751
|
+
}
|
|
2752
|
+
return void 0;
|
|
2753
|
+
}
|
|
2754
|
+
|
|
2755
|
+
// packages/ssml-editor-react/src/ssmlCompletion.ts
|
|
2756
|
+
var SSML_ATTRIBUTE_VALUE_PATTERN = /<([\w:-]+)\s+[^>]*?\b([\w:-]+)=["']([^"']*)$/i;
|
|
2757
|
+
var EXPRESS_AS_TAG_NAMES = /* @__PURE__ */ new Set(["mstts:express-as", "express-as", "expressas"]);
|
|
2758
|
+
function findSsmlAttributePresets(tagName, attributeName) {
|
|
2759
|
+
const tagPresets = Object.entries(SSML_ATTRIBUTE_PRESETS).find(
|
|
2760
|
+
([presetTagName]) => presetTagName.toLowerCase() === tagName.toLowerCase()
|
|
2761
|
+
)?.[1];
|
|
2762
|
+
return Object.entries(tagPresets ?? {}).find(
|
|
2763
|
+
([presetAttributeName]) => presetAttributeName.toLowerCase() === attributeName.toLowerCase()
|
|
2764
|
+
)?.[1];
|
|
2765
|
+
}
|
|
2766
|
+
var SSML_COMPLETION_SNIPPETS = [
|
|
2767
|
+
{
|
|
2768
|
+
label: "break",
|
|
2769
|
+
insertText: '<break time="500ms" />'
|
|
2770
|
+
},
|
|
2771
|
+
{
|
|
2772
|
+
label: "prosody",
|
|
2773
|
+
insertText: `<prosody rate="medium" pitch="medium">\${1:text}</prosody>`
|
|
2774
|
+
},
|
|
2775
|
+
{
|
|
2776
|
+
label: "mstts:express-as",
|
|
2777
|
+
insertText: `<mstts:express-as style="cheerful">\${1:text}</mstts:express-as>`
|
|
2778
|
+
},
|
|
2779
|
+
{
|
|
2780
|
+
label: "sub",
|
|
2781
|
+
insertText: `<sub alias="\${1:\u8AAD\u307F}">\${2:\u6F22\u5B57}</sub>`
|
|
2782
|
+
}
|
|
2783
|
+
];
|
|
2784
|
+
function registerSsmlCompletionProvider(monaco, options = {}) {
|
|
2785
|
+
const provider = {
|
|
2786
|
+
provideCompletionItems(model, position) {
|
|
2787
|
+
if (options.model && options.model !== model) {
|
|
2788
|
+
return { suggestions: [] };
|
|
2789
|
+
}
|
|
2790
|
+
const value = model.getValue();
|
|
2791
|
+
const offset = model.getOffsetAt(position);
|
|
2792
|
+
const textUntilPosition = value.slice(0, offset);
|
|
2793
|
+
const isClosingTag = /<\/[a-zA-Z0-9:-]*$/.test(textUntilPosition);
|
|
2794
|
+
if (isClosingTag) {
|
|
2795
|
+
return { suggestions: [] };
|
|
2796
|
+
}
|
|
2797
|
+
const attributeMatch = SSML_ATTRIBUTE_VALUE_PATTERN.exec(textUntilPosition);
|
|
2798
|
+
let attributeValues = attributeMatch ? findSsmlAttributePresets(attributeMatch[1], attributeMatch[2]) : void 0;
|
|
2799
|
+
if (attributeMatch && attributeValues && EXPRESS_AS_TAG_NAMES.has(attributeMatch[1].toLowerCase()) && attributeMatch[2].toLowerCase() === "style") {
|
|
2800
|
+
const voiceContext = findSsmlVoiceContext(value, offset);
|
|
2801
|
+
const voiceName = voiceContext === void 0 ? options.getOuterVoiceName?.() : voiceContext.voiceName;
|
|
2802
|
+
attributeValues = resolveExpressAsStyles(voiceName, attributeValues);
|
|
2803
|
+
}
|
|
2804
|
+
const openTagMatch = textUntilPosition.match(/<(?!\/)[a-zA-Z0-9:-]*$/);
|
|
2805
|
+
const openTagLength = openTagMatch?.[0].length ?? 0;
|
|
2806
|
+
const isAfterBracket = model.getValueInRange({
|
|
2807
|
+
startLineNumber: position.lineNumber,
|
|
2808
|
+
startColumn: position.column - 1,
|
|
2809
|
+
endLineNumber: position.lineNumber,
|
|
2810
|
+
endColumn: position.column
|
|
2811
|
+
}) === "<";
|
|
2812
|
+
const hasClosingBracket = isAfterBracket && model.getValueInRange({
|
|
2813
|
+
startLineNumber: position.lineNumber,
|
|
2814
|
+
startColumn: position.column,
|
|
2815
|
+
endLineNumber: position.lineNumber,
|
|
2816
|
+
endColumn: position.column + 1
|
|
2817
|
+
}) === ">";
|
|
2818
|
+
const range = {
|
|
2819
|
+
startLineNumber: position.lineNumber,
|
|
2820
|
+
startColumn: openTagLength > 0 ? position.column - openTagLength : position.column,
|
|
2821
|
+
endLineNumber: position.lineNumber,
|
|
2822
|
+
endColumn: hasClosingBracket ? position.column + 1 : position.column
|
|
2823
|
+
};
|
|
2824
|
+
return {
|
|
2825
|
+
suggestions: [
|
|
2826
|
+
...attributeMatch ? [] : SSML_COMPLETION_SNIPPETS.map(({ label, insertText }) => ({
|
|
2827
|
+
label,
|
|
2828
|
+
kind: monaco.languages.CompletionItemKind.Snippet,
|
|
2829
|
+
insertText,
|
|
2830
|
+
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
2831
|
+
range
|
|
2832
|
+
})),
|
|
2833
|
+
...attributeValues?.map((value2) => ({
|
|
2834
|
+
label: value2,
|
|
2835
|
+
kind: monaco.languages.CompletionItemKind.Value,
|
|
2836
|
+
insertText: value2,
|
|
2837
|
+
range
|
|
2838
|
+
})) ?? []
|
|
2839
|
+
]
|
|
2840
|
+
};
|
|
2841
|
+
},
|
|
2842
|
+
triggerCharacters: ["<", '"', "'"]
|
|
2843
|
+
};
|
|
2844
|
+
return monaco.languages.registerCompletionItemProvider("xml", provider);
|
|
2845
|
+
}
|
|
2846
|
+
|
|
2847
|
+
// packages/ssml-editor-react/src/ssmlHover.ts
|
|
2848
|
+
var {
|
|
2849
|
+
BREAK_STRENGTH_PRESETS: BREAK_STRENGTH_PRESETS2,
|
|
2850
|
+
EMPHASIS_LEVEL_PRESETS: EMPHASIS_LEVEL_PRESETS2,
|
|
2851
|
+
PHONEME_ALPHABET_PRESETS: PHONEME_ALPHABET_PRESETS2,
|
|
2852
|
+
PROSODY_RATE_VALUES: PROSODY_RATE_VALUES2,
|
|
2853
|
+
PROSODY_VOLUME_PRESETS: PROSODY_VOLUME_PRESETS2,
|
|
2854
|
+
SILENCE_TYPE_PRESETS: SILENCE_TYPE_PRESETS2,
|
|
2855
|
+
SSML_PRESET_EXAMPLES: SSML_PRESET_EXAMPLES2,
|
|
2856
|
+
VISEME_TYPE_PRESETS: VISEME_TYPE_PRESETS2
|
|
2857
|
+
} = ssmlPresets_exports;
|
|
2858
|
+
var SSML_TAG_DEFINITIONS = [
|
|
2859
|
+
{
|
|
2860
|
+
name: "voice",
|
|
2861
|
+
description: "Selects the voice and optional voice effect used to synthesize the enclosed text.",
|
|
2862
|
+
parameters: [
|
|
2863
|
+
{
|
|
2864
|
+
name: "name",
|
|
2865
|
+
description: "The voice name, such as `en-US-JennyNeural`.",
|
|
2866
|
+
example: "en-US-JennyNeural"
|
|
2867
|
+
},
|
|
2868
|
+
{
|
|
2869
|
+
name: "effect",
|
|
2870
|
+
description: "An optional voice effect, such as `eq_car`."
|
|
2871
|
+
}
|
|
2872
|
+
]
|
|
2873
|
+
},
|
|
2874
|
+
{
|
|
2875
|
+
name: "prosody",
|
|
2876
|
+
description: "Changes the speaking rate, pitch, volume, or pitch contour of the enclosed text.",
|
|
2877
|
+
parameters: [
|
|
2878
|
+
{
|
|
2879
|
+
name: "rate",
|
|
2880
|
+
description: "Controls speaking speed.",
|
|
2881
|
+
values: PROSODY_RATE_VALUES2,
|
|
2882
|
+
example: SSML_PRESET_EXAMPLES2.prosodyRate
|
|
2883
|
+
},
|
|
2884
|
+
{
|
|
2885
|
+
name: "pitch",
|
|
2886
|
+
description: "Adjusts pitch using a named value, percentage, frequency, or semitone value.",
|
|
2887
|
+
example: SSML_PRESET_EXAMPLES2.prosodyPitch
|
|
2888
|
+
},
|
|
2889
|
+
{
|
|
2890
|
+
name: "volume",
|
|
2891
|
+
description: "Controls loudness using a named value, percentage, or decibel value.",
|
|
2892
|
+
values: PROSODY_VOLUME_PRESETS2,
|
|
2893
|
+
example: SSML_PRESET_EXAMPLES2.prosodyVolume
|
|
2894
|
+
},
|
|
2895
|
+
{
|
|
2896
|
+
name: "contour",
|
|
2897
|
+
description: "Defines a sequence of relative pitch changes at positions in the text.",
|
|
2898
|
+
example: "(0%,+0st) (100%,+2st)"
|
|
2899
|
+
},
|
|
2900
|
+
{
|
|
2901
|
+
name: "range",
|
|
2902
|
+
description: "Adjusts the pitch range of the voice.",
|
|
2903
|
+
example: "+2st"
|
|
2904
|
+
}
|
|
2905
|
+
]
|
|
2906
|
+
},
|
|
2907
|
+
{
|
|
2908
|
+
name: "break",
|
|
2909
|
+
description: "Inserts a pause between words or other spoken content.",
|
|
2910
|
+
parameters: [
|
|
2911
|
+
{
|
|
2912
|
+
name: "time",
|
|
2913
|
+
description: "The pause duration, for example `500ms` or `1s`.",
|
|
2914
|
+
example: SSML_PRESET_EXAMPLES2.breakTime
|
|
2915
|
+
},
|
|
2916
|
+
{
|
|
2917
|
+
name: "strength",
|
|
2918
|
+
description: "The relative pause strength.",
|
|
2919
|
+
values: BREAK_STRENGTH_PRESETS2
|
|
2920
|
+
}
|
|
2921
|
+
]
|
|
2922
|
+
},
|
|
2923
|
+
{
|
|
2924
|
+
name: "mstts:express-as",
|
|
2925
|
+
aliases: ["express-as", "expressAs"],
|
|
2926
|
+
description: "Applies a speaking style, style degree, or role to the enclosed text.",
|
|
2927
|
+
parameters: [
|
|
2928
|
+
{
|
|
2929
|
+
name: "style",
|
|
2930
|
+
description: "The speaking style supported by the selected voice, such as `cheerful`.",
|
|
2931
|
+
example: SSML_PRESET_EXAMPLES2.expressAsStyle
|
|
2932
|
+
},
|
|
2933
|
+
{
|
|
2934
|
+
name: "styledegree",
|
|
2935
|
+
aliases: ["style-degree", "styleDegree"],
|
|
2936
|
+
description: "Controls the intensity of the selected speaking style.",
|
|
2937
|
+
example: "1.5"
|
|
2938
|
+
},
|
|
2939
|
+
{
|
|
2940
|
+
name: "role",
|
|
2941
|
+
description: "Changes the speaking role when supported by the selected voice.",
|
|
2942
|
+
example: "YoungAdultFemale"
|
|
2943
|
+
}
|
|
2944
|
+
]
|
|
2945
|
+
},
|
|
2946
|
+
{
|
|
2947
|
+
name: "say-as",
|
|
2948
|
+
aliases: ["sayAs"],
|
|
2949
|
+
description: "Controls how the enclosed text is interpreted and spoken.",
|
|
2950
|
+
parameters: [
|
|
2951
|
+
{
|
|
2952
|
+
name: "interpret-as",
|
|
2953
|
+
description: "Specifies the interpretation, such as characters, digits, date, or time.",
|
|
2954
|
+
example: "characters"
|
|
2955
|
+
},
|
|
2956
|
+
{
|
|
2957
|
+
name: "format",
|
|
2958
|
+
description: "Provides a format hint for the selected interpretation."
|
|
2959
|
+
},
|
|
2960
|
+
{
|
|
2961
|
+
name: "detail",
|
|
2962
|
+
description: "Provides an additional detail hint for the selected interpretation."
|
|
2963
|
+
}
|
|
2964
|
+
]
|
|
2965
|
+
},
|
|
2966
|
+
{
|
|
2967
|
+
name: "phoneme",
|
|
2968
|
+
description: "Replaces normal pronunciation with the supplied phonetic pronunciation.",
|
|
2969
|
+
parameters: [
|
|
2970
|
+
{
|
|
2971
|
+
name: "alphabet",
|
|
2972
|
+
description: "The phonetic alphabet used by the `ph` value.",
|
|
2973
|
+
values: PHONEME_ALPHABET_PRESETS2,
|
|
2974
|
+
example: SSML_PRESET_EXAMPLES2.phonemeAlphabet
|
|
2975
|
+
},
|
|
2976
|
+
{
|
|
2977
|
+
name: "ph",
|
|
2978
|
+
description: "The phonetic pronunciation for the enclosed text.",
|
|
2979
|
+
example: "h\u0259\u02C8lo\u028A"
|
|
2980
|
+
}
|
|
2981
|
+
]
|
|
2982
|
+
},
|
|
2983
|
+
{
|
|
2984
|
+
name: "emphasis",
|
|
2985
|
+
description: "Adds emphasis to the enclosed text.",
|
|
2986
|
+
parameters: [
|
|
2987
|
+
{
|
|
2988
|
+
name: "level",
|
|
2989
|
+
description: "Controls the amount of emphasis.",
|
|
2990
|
+
values: EMPHASIS_LEVEL_PRESETS2
|
|
2991
|
+
}
|
|
2992
|
+
]
|
|
2993
|
+
},
|
|
2994
|
+
{
|
|
2995
|
+
name: "audio",
|
|
2996
|
+
description: "Plays an audio file as part of the synthesized output.",
|
|
2997
|
+
parameters: [
|
|
2998
|
+
{
|
|
2999
|
+
name: "src",
|
|
3000
|
+
description: "The URI of the audio file.",
|
|
3001
|
+
example: "https://example.com/intro.wav"
|
|
3002
|
+
},
|
|
3003
|
+
{
|
|
3004
|
+
name: "desc",
|
|
3005
|
+
description: "Alternative text to use if the audio cannot be played."
|
|
3006
|
+
},
|
|
3007
|
+
{
|
|
3008
|
+
name: "clipBegin",
|
|
3009
|
+
description: "The starting offset within the audio file.",
|
|
3010
|
+
example: "0s"
|
|
3011
|
+
},
|
|
3012
|
+
{
|
|
3013
|
+
name: "clipEnd",
|
|
3014
|
+
description: "The ending offset within the audio file.",
|
|
3015
|
+
example: "5s"
|
|
3016
|
+
},
|
|
3017
|
+
{
|
|
3018
|
+
name: "speed",
|
|
3019
|
+
description: "The playback speed of the audio file.",
|
|
3020
|
+
example: "1.0"
|
|
3021
|
+
},
|
|
3022
|
+
{
|
|
3023
|
+
name: "repeatCount",
|
|
3024
|
+
description: "The number of times to repeat the audio.",
|
|
3025
|
+
example: "2"
|
|
3026
|
+
},
|
|
3027
|
+
{
|
|
3028
|
+
name: "repeatDuration",
|
|
3029
|
+
description: "The total duration for which the audio may repeat.",
|
|
3030
|
+
example: "10s"
|
|
3031
|
+
},
|
|
3032
|
+
{
|
|
3033
|
+
name: "soundLevel",
|
|
3034
|
+
description: "The audio volume adjustment in decibels.",
|
|
3035
|
+
example: "-3dB"
|
|
3036
|
+
}
|
|
3037
|
+
]
|
|
3038
|
+
},
|
|
3039
|
+
{
|
|
3040
|
+
name: "sub",
|
|
3041
|
+
description: "Substitutes the alias text when speaking the enclosed text.",
|
|
3042
|
+
parameters: [
|
|
3043
|
+
{
|
|
3044
|
+
name: "alias",
|
|
3045
|
+
description: "The text to speak instead of the enclosed text.",
|
|
3046
|
+
example: "World Wide Web"
|
|
3047
|
+
}
|
|
3048
|
+
]
|
|
3049
|
+
},
|
|
3050
|
+
{
|
|
3051
|
+
name: "lang",
|
|
3052
|
+
description: "Changes the language used for the enclosed text.",
|
|
3053
|
+
parameters: [
|
|
3054
|
+
{
|
|
3055
|
+
name: "xml:lang",
|
|
3056
|
+
aliases: ["lang"],
|
|
3057
|
+
description: "The BCP-47 language tag.",
|
|
3058
|
+
example: "ja-JP"
|
|
3059
|
+
}
|
|
3060
|
+
]
|
|
3061
|
+
},
|
|
3062
|
+
{
|
|
3063
|
+
name: "mark",
|
|
3064
|
+
description: "Inserts a custom marker into the synthesized audio stream.",
|
|
3065
|
+
parameters: [
|
|
3066
|
+
{
|
|
3067
|
+
name: "name",
|
|
3068
|
+
description: "The application-defined marker name.",
|
|
3069
|
+
example: "chapter-1"
|
|
3070
|
+
}
|
|
3071
|
+
]
|
|
3072
|
+
},
|
|
3073
|
+
{
|
|
3074
|
+
name: "bookmark",
|
|
3075
|
+
description: "Inserts a bookmark marker into the synthesized audio stream.",
|
|
3076
|
+
parameters: [
|
|
3077
|
+
{
|
|
3078
|
+
name: "mark",
|
|
3079
|
+
description: "The application-defined bookmark name.",
|
|
3080
|
+
example: "chapter-1"
|
|
3081
|
+
}
|
|
3082
|
+
]
|
|
3083
|
+
},
|
|
3084
|
+
{
|
|
3085
|
+
name: "lexicon",
|
|
3086
|
+
description: "Associates a pronunciation lexicon with the synthesized document.",
|
|
3087
|
+
parameters: [
|
|
3088
|
+
{
|
|
3089
|
+
name: "uri",
|
|
3090
|
+
description: "The URI of the pronunciation lexicon.",
|
|
3091
|
+
example: "https://example.com/lexicon.pls"
|
|
3092
|
+
}
|
|
3093
|
+
]
|
|
3094
|
+
},
|
|
3095
|
+
{
|
|
3096
|
+
name: "p",
|
|
3097
|
+
description: "Groups text into a paragraph.",
|
|
3098
|
+
parameters: []
|
|
3099
|
+
},
|
|
3100
|
+
{
|
|
3101
|
+
name: "s",
|
|
3102
|
+
description: "Groups text into a sentence.",
|
|
3103
|
+
parameters: []
|
|
3104
|
+
},
|
|
3105
|
+
{
|
|
3106
|
+
name: "w",
|
|
3107
|
+
description: "Groups text into a word.",
|
|
3108
|
+
parameters: []
|
|
3109
|
+
},
|
|
3110
|
+
{
|
|
3111
|
+
name: "mstts:silence",
|
|
3112
|
+
aliases: ["silence"],
|
|
3113
|
+
description: "Adds a specified silence before or after text or at a punctuation boundary.",
|
|
3114
|
+
parameters: [
|
|
3115
|
+
{
|
|
3116
|
+
name: "type",
|
|
3117
|
+
description: "The silence position or punctuation boundary.",
|
|
3118
|
+
values: SILENCE_TYPE_PRESETS2
|
|
3119
|
+
},
|
|
3120
|
+
{
|
|
3121
|
+
name: "value",
|
|
3122
|
+
description: "The silence duration, for example `300ms`.",
|
|
3123
|
+
example: SSML_PRESET_EXAMPLES2.silenceValue
|
|
3124
|
+
}
|
|
3125
|
+
]
|
|
3126
|
+
},
|
|
3127
|
+
{
|
|
3128
|
+
name: "mstts:viseme",
|
|
3129
|
+
aliases: ["viseme"],
|
|
3130
|
+
description: "Requests viseme events for the synthesized audio.",
|
|
3131
|
+
parameters: [
|
|
3132
|
+
{
|
|
3133
|
+
name: "type",
|
|
3134
|
+
description: "The viseme event format.",
|
|
3135
|
+
values: VISEME_TYPE_PRESETS2
|
|
3136
|
+
}
|
|
3137
|
+
]
|
|
3138
|
+
}
|
|
3139
|
+
];
|
|
3140
|
+
var definitionsByName = /* @__PURE__ */ new Map();
|
|
3141
|
+
for (const definition of SSML_TAG_DEFINITIONS) {
|
|
3142
|
+
definitionsByName.set(definition.name, definition);
|
|
3143
|
+
for (const alias of definition.aliases ?? []) {
|
|
3144
|
+
definitionsByName.set(alias, definition);
|
|
3145
|
+
}
|
|
3146
|
+
}
|
|
3147
|
+
function isXmlNameStart3(value) {
|
|
3148
|
+
return value !== void 0 && /[A-Za-z_]/.test(value);
|
|
3149
|
+
}
|
|
3150
|
+
function isXmlNameCharacter3(value) {
|
|
3151
|
+
return value !== void 0 && /[A-Za-z0-9_.:-]/.test(value);
|
|
3152
|
+
}
|
|
3153
|
+
function isXmlWhitespace3(value) {
|
|
3154
|
+
return value === " " || value === " " || value === "\r" || value === "\n";
|
|
3155
|
+
}
|
|
3156
|
+
function positionToOffset(source, lineNumber, column) {
|
|
3157
|
+
if (!Number.isInteger(lineNumber) || !Number.isInteger(column) || lineNumber < 1 || column < 1) {
|
|
3158
|
+
return void 0;
|
|
3159
|
+
}
|
|
3160
|
+
let lineStart = 0;
|
|
3161
|
+
for (let line = 1; line < lineNumber; line += 1) {
|
|
3162
|
+
const newline = source.indexOf("\n", lineStart);
|
|
3163
|
+
if (newline === -1) {
|
|
3164
|
+
return void 0;
|
|
3165
|
+
}
|
|
3166
|
+
lineStart = newline + 1;
|
|
3167
|
+
}
|
|
3168
|
+
const lineEnd = source.indexOf("\n", lineStart);
|
|
3169
|
+
const lineLength = lineEnd === -1 ? source.length - lineStart : lineEnd - lineStart;
|
|
3170
|
+
if (column > lineLength + 1) {
|
|
3171
|
+
return void 0;
|
|
3172
|
+
}
|
|
3173
|
+
return lineStart + column - 1;
|
|
3174
|
+
}
|
|
3175
|
+
function offsetToPosition(source, offset) {
|
|
3176
|
+
const lastNewline = source.lastIndexOf("\n", offset - 1);
|
|
3177
|
+
const lineNumber = source.slice(0, offset).split("\n").length;
|
|
3178
|
+
return {
|
|
3179
|
+
lineNumber,
|
|
3180
|
+
column: offset - lastNewline
|
|
3181
|
+
};
|
|
3182
|
+
}
|
|
3183
|
+
function toRange(source, token) {
|
|
3184
|
+
const start = offsetToPosition(source, token.start);
|
|
3185
|
+
const end = offsetToPosition(source, token.end);
|
|
3186
|
+
return {
|
|
3187
|
+
startLineNumber: start.lineNumber,
|
|
3188
|
+
startColumn: start.column,
|
|
3189
|
+
endLineNumber: end.lineNumber,
|
|
3190
|
+
endColumn: end.column
|
|
3191
|
+
};
|
|
3192
|
+
}
|
|
3193
|
+
function containsOffset(token, offset) {
|
|
3194
|
+
return offset >= token.start && offset < token.end;
|
|
3195
|
+
}
|
|
3196
|
+
function findTagEnd3(source, start) {
|
|
3197
|
+
let quote;
|
|
3198
|
+
for (let index = start; index < source.length; index += 1) {
|
|
3199
|
+
const character = source[index];
|
|
3200
|
+
if (quote !== void 0) {
|
|
3201
|
+
if (character === quote) {
|
|
3202
|
+
quote = void 0;
|
|
3203
|
+
}
|
|
3204
|
+
} else if (character === '"' || character === "'") {
|
|
3205
|
+
quote = character;
|
|
3206
|
+
} else if (character === ">") {
|
|
3207
|
+
return index;
|
|
3208
|
+
}
|
|
3209
|
+
}
|
|
3210
|
+
return void 0;
|
|
3211
|
+
}
|
|
3212
|
+
function parseTag(source, start, contentEnd, tokenEnd) {
|
|
3213
|
+
let index = start + 1;
|
|
3214
|
+
let closing = false;
|
|
3215
|
+
if (source[index] === "/") {
|
|
3216
|
+
closing = true;
|
|
3217
|
+
index += 1;
|
|
3218
|
+
}
|
|
3219
|
+
while (index < contentEnd && isXmlWhitespace3(source[index])) {
|
|
3220
|
+
index += 1;
|
|
3221
|
+
}
|
|
3222
|
+
if (!isXmlNameStart3(source[index])) {
|
|
3223
|
+
return void 0;
|
|
3224
|
+
}
|
|
3225
|
+
const nameStart = index;
|
|
3226
|
+
index += 1;
|
|
3227
|
+
while (index < contentEnd && isXmlNameCharacter3(source[index])) {
|
|
3228
|
+
index += 1;
|
|
3229
|
+
}
|
|
3230
|
+
const nameEnd = index;
|
|
3231
|
+
const attributes = [];
|
|
3232
|
+
if (!closing) {
|
|
3233
|
+
while (index < contentEnd) {
|
|
3234
|
+
while (index < contentEnd && isXmlWhitespace3(source[index])) {
|
|
3235
|
+
index += 1;
|
|
3236
|
+
}
|
|
3237
|
+
if (index >= contentEnd || source[index] === "/") {
|
|
3238
|
+
break;
|
|
3239
|
+
}
|
|
3240
|
+
if (!isXmlNameStart3(source[index])) {
|
|
3241
|
+
index += 1;
|
|
3242
|
+
continue;
|
|
3243
|
+
}
|
|
3244
|
+
const attributeStart = index;
|
|
3245
|
+
index += 1;
|
|
3246
|
+
while (index < contentEnd && isXmlNameCharacter3(source[index])) {
|
|
3247
|
+
index += 1;
|
|
3248
|
+
}
|
|
3249
|
+
const attributeEnd = index;
|
|
3250
|
+
while (index < contentEnd && isXmlWhitespace3(source[index])) {
|
|
3251
|
+
index += 1;
|
|
3252
|
+
}
|
|
3253
|
+
let value;
|
|
3254
|
+
if (source[index] === "=") {
|
|
3255
|
+
index += 1;
|
|
3256
|
+
while (index < contentEnd && isXmlWhitespace3(source[index])) {
|
|
3257
|
+
index += 1;
|
|
3258
|
+
}
|
|
3259
|
+
const quote = source[index];
|
|
3260
|
+
if (quote === '"' || quote === "'") {
|
|
3261
|
+
index += 1;
|
|
3262
|
+
const valueStart = index;
|
|
3263
|
+
while (index < contentEnd && source[index] !== quote) {
|
|
3264
|
+
index += 1;
|
|
3265
|
+
}
|
|
3266
|
+
value = { start: valueStart, end: index };
|
|
3267
|
+
if (index < contentEnd) {
|
|
3268
|
+
index += 1;
|
|
3269
|
+
}
|
|
3270
|
+
} else {
|
|
3271
|
+
const valueStart = index;
|
|
3272
|
+
while (index < contentEnd && !isXmlWhitespace3(source[index]) && source[index] !== "/") {
|
|
3273
|
+
index += 1;
|
|
3274
|
+
}
|
|
3275
|
+
value = { start: valueStart, end: index };
|
|
3276
|
+
}
|
|
3277
|
+
}
|
|
3278
|
+
attributes.push({
|
|
3279
|
+
name: { start: attributeStart, end: attributeEnd },
|
|
3280
|
+
value
|
|
3281
|
+
});
|
|
3282
|
+
}
|
|
3283
|
+
}
|
|
3284
|
+
return {
|
|
3285
|
+
name: source.slice(nameStart, nameEnd),
|
|
3286
|
+
nameRange: { start: nameStart, end: nameEnd },
|
|
3287
|
+
start,
|
|
3288
|
+
end: tokenEnd,
|
|
3289
|
+
closing,
|
|
3290
|
+
attributes
|
|
3291
|
+
};
|
|
3292
|
+
}
|
|
3293
|
+
function findTagAtOffset(source, offset) {
|
|
3294
|
+
let searchStart = 0;
|
|
3295
|
+
while (searchStart < source.length) {
|
|
3296
|
+
const start = source.indexOf("<", searchStart);
|
|
3297
|
+
if (start === -1 || start > offset) {
|
|
3298
|
+
return void 0;
|
|
3299
|
+
}
|
|
3300
|
+
if (source.startsWith("<!--", start)) {
|
|
3301
|
+
const commentEnd = source.indexOf("-->", start + 4);
|
|
3302
|
+
const tokenEnd2 = commentEnd === -1 ? source.length : commentEnd + 3;
|
|
3303
|
+
if (offset < tokenEnd2) {
|
|
3304
|
+
return void 0;
|
|
3305
|
+
}
|
|
3306
|
+
searchStart = tokenEnd2;
|
|
3307
|
+
continue;
|
|
3308
|
+
}
|
|
3309
|
+
if (source.startsWith("<![CDATA[", start)) {
|
|
3310
|
+
const cdataEnd = source.indexOf("]]>", start + 9);
|
|
3311
|
+
const tokenEnd2 = cdataEnd === -1 ? source.length : cdataEnd + 3;
|
|
3312
|
+
if (offset < tokenEnd2) {
|
|
3313
|
+
return void 0;
|
|
3314
|
+
}
|
|
3315
|
+
searchStart = tokenEnd2;
|
|
3316
|
+
continue;
|
|
3317
|
+
}
|
|
3318
|
+
if (source.startsWith("<?", start)) {
|
|
3319
|
+
const processingEnd = source.indexOf("?>", start + 2);
|
|
3320
|
+
const tokenEnd2 = processingEnd === -1 ? source.length : processingEnd + 2;
|
|
3321
|
+
if (offset < tokenEnd2) {
|
|
3322
|
+
return void 0;
|
|
3323
|
+
}
|
|
3324
|
+
searchStart = tokenEnd2;
|
|
3325
|
+
continue;
|
|
3326
|
+
}
|
|
3327
|
+
const tagEnd = findTagEnd3(source, start + 1);
|
|
3328
|
+
const contentEnd = tagEnd ?? source.length;
|
|
3329
|
+
const tokenEnd = tagEnd === void 0 ? source.length : tagEnd + 1;
|
|
3330
|
+
if (offset < tokenEnd) {
|
|
3331
|
+
return parseTag(source, start, contentEnd, tokenEnd);
|
|
3332
|
+
}
|
|
3333
|
+
if (tagEnd === void 0) {
|
|
3334
|
+
return void 0;
|
|
3335
|
+
}
|
|
3336
|
+
searchStart = tokenEnd;
|
|
3337
|
+
}
|
|
3338
|
+
return void 0;
|
|
3339
|
+
}
|
|
3340
|
+
function findParameter(definition, name) {
|
|
3341
|
+
return definition.parameters.find(
|
|
3342
|
+
(parameter) => parameter.name === name || parameter.aliases?.includes(name) === true
|
|
3343
|
+
);
|
|
3344
|
+
}
|
|
3345
|
+
function getSsmlTagDefinition(name) {
|
|
3346
|
+
return definitionsByName.get(name);
|
|
3347
|
+
}
|
|
3348
|
+
function findSsmlHoverTarget(source, lineNumber, column) {
|
|
3349
|
+
const offset = positionToOffset(source, lineNumber, column);
|
|
3350
|
+
if (offset === void 0) {
|
|
3351
|
+
return void 0;
|
|
3352
|
+
}
|
|
3353
|
+
const tag = findTagAtOffset(source, offset);
|
|
3354
|
+
if (!tag) {
|
|
3355
|
+
return void 0;
|
|
3356
|
+
}
|
|
3357
|
+
const definition = getSsmlTagDefinition(tag.name);
|
|
3358
|
+
if (!definition) {
|
|
3359
|
+
return void 0;
|
|
3360
|
+
}
|
|
3361
|
+
if (containsOffset(tag.nameRange, offset)) {
|
|
3362
|
+
return {
|
|
3363
|
+
kind: "tag",
|
|
3364
|
+
tagName: tag.name,
|
|
3365
|
+
isClosingTag: tag.closing,
|
|
3366
|
+
definition,
|
|
3367
|
+
range: toRange(source, tag.nameRange)
|
|
3368
|
+
};
|
|
3369
|
+
}
|
|
3370
|
+
for (const attribute of tag.attributes) {
|
|
3371
|
+
if (containsOffset(attribute.name, offset)) {
|
|
3372
|
+
const parameter = findParameter(definition, source.slice(attribute.name.start, attribute.name.end));
|
|
3373
|
+
if (!parameter) {
|
|
3374
|
+
return void 0;
|
|
3375
|
+
}
|
|
3376
|
+
return {
|
|
3377
|
+
kind: "parameter",
|
|
3378
|
+
tagName: tag.name,
|
|
3379
|
+
isClosingTag: tag.closing,
|
|
3380
|
+
definition,
|
|
3381
|
+
parameter,
|
|
3382
|
+
range: toRange(source, attribute.name)
|
|
3383
|
+
};
|
|
3384
|
+
}
|
|
3385
|
+
if (attribute.value && containsOffset(attribute.value, offset)) {
|
|
3386
|
+
const parameter = findParameter(definition, source.slice(attribute.name.start, attribute.name.end));
|
|
3387
|
+
if (!parameter) {
|
|
3388
|
+
return void 0;
|
|
3389
|
+
}
|
|
3390
|
+
return {
|
|
3391
|
+
kind: "parameter-value",
|
|
3392
|
+
tagName: tag.name,
|
|
3393
|
+
isClosingTag: tag.closing,
|
|
3394
|
+
definition,
|
|
3395
|
+
parameter,
|
|
3396
|
+
range: toRange(source, attribute.value)
|
|
3397
|
+
};
|
|
3398
|
+
}
|
|
3399
|
+
}
|
|
3400
|
+
return void 0;
|
|
3401
|
+
}
|
|
3402
|
+
function code(value) {
|
|
3403
|
+
return `\`${value.replace(/\\/g, "\\\\").replace(/`/g, "\\`")}\``;
|
|
3404
|
+
}
|
|
3405
|
+
function formatParameter(parameter, tagName, locale) {
|
|
3406
|
+
const localizedParameter = SSML_HOVER_COPY[locale].tags[tagName]?.parameters[parameter.name];
|
|
3407
|
+
const description = localizedParameter?.description ?? parameter.description;
|
|
3408
|
+
const values = parameter.values && parameter.values.length > 0 ? ` ${SSML_HOVER_COPY[locale].allowedValues}: ${parameter.values.map(code).join(", ")}.` : "";
|
|
3409
|
+
const example = parameter.example ? ` ${SSML_HOVER_COPY[locale].example}: ${code(parameter.example)}.` : "";
|
|
3410
|
+
return `- ${code(parameter.name)}: ${description}${values}${example}`;
|
|
3411
|
+
}
|
|
3412
|
+
function formatSsmlHover(target, locale = "en") {
|
|
3413
|
+
const localizedTag = SSML_HOVER_COPY[locale].tags[target.definition.name];
|
|
3414
|
+
const tagTitle = localizedTag?.title ?? target.definition.name;
|
|
3415
|
+
const tagDescription = localizedTag?.description ?? target.definition.description;
|
|
3416
|
+
const tagSyntax = target.isClosingTag ? `</${target.tagName}>` : `<${target.tagName}>`;
|
|
3417
|
+
const lines = [`### ${code(tagSyntax)}`, "", `**${tagTitle}**`, "", tagDescription];
|
|
3418
|
+
if (target.parameter) {
|
|
3419
|
+
const localizedParameter = localizedTag?.parameters[target.parameter.name];
|
|
3420
|
+
const parameterTitle = localizedParameter?.title ?? target.parameter.name;
|
|
3421
|
+
const parameterDescription = localizedParameter?.description ?? target.parameter.description;
|
|
3422
|
+
lines.push("", `**${SSML_HOVER_COPY[locale].parameterHeading} ${code(parameterTitle)}**`, "", parameterDescription);
|
|
3423
|
+
if (target.parameter.values && target.parameter.values.length > 0) {
|
|
3424
|
+
lines.push("", `${SSML_HOVER_COPY[locale].allowedValues}: ${target.parameter.values.map(code).join(", ")}.`);
|
|
3425
|
+
}
|
|
3426
|
+
if (target.parameter.example) {
|
|
3427
|
+
lines.push("", `${SSML_HOVER_COPY[locale].example}: ${code(target.parameter.example)}.`);
|
|
3428
|
+
}
|
|
3429
|
+
} else if (target.definition.parameters.length > 0) {
|
|
3430
|
+
lines.push(
|
|
3431
|
+
"",
|
|
3432
|
+
`**${SSML_HOVER_COPY[locale].parametersHeading}**`,
|
|
3433
|
+
"",
|
|
3434
|
+
...target.definition.parameters.map((parameter) => formatParameter(parameter, target.definition.name, locale))
|
|
3435
|
+
);
|
|
3436
|
+
} else {
|
|
3437
|
+
lines.push("", SSML_HOVER_COPY[locale].noParameters);
|
|
3438
|
+
}
|
|
3439
|
+
return lines.join("\n");
|
|
3440
|
+
}
|
|
3441
|
+
|
|
3442
|
+
export {
|
|
3443
|
+
BREAK_TIME_PRESETS,
|
|
3444
|
+
PROSODY_RATE_PRESETS,
|
|
3445
|
+
PROSODY_PITCH_PRESETS,
|
|
3446
|
+
PROSODY_VOLUME_PRESETS,
|
|
3447
|
+
EXPRESS_AS_STYLE_PRESETS,
|
|
3448
|
+
getExpressAsStyleCategory,
|
|
3449
|
+
resolveExpressAsStyles,
|
|
3450
|
+
EMPHASIS_LEVEL_PRESETS,
|
|
3451
|
+
SAY_AS_PRESETS,
|
|
3452
|
+
LANGUAGE_PRESETS,
|
|
3453
|
+
SILENCE_VALUE_PRESETS,
|
|
3454
|
+
SSML_ATTRIBUTE_PRESETS,
|
|
3455
|
+
BREAK_TIME_DESCRIPTIONS,
|
|
3456
|
+
EMPHASIS_LEVEL_DESCRIPTIONS,
|
|
3457
|
+
PROSODY_RATE_DESCRIPTIONS,
|
|
3458
|
+
PROSODY_PITCH_DESCRIPTIONS,
|
|
3459
|
+
PROSODY_VOLUME_DESCRIPTIONS,
|
|
3460
|
+
EXPRESS_AS_STYLE_DESCRIPTIONS,
|
|
3461
|
+
SAY_AS_DESCRIPTIONS,
|
|
3462
|
+
LANGUAGE_DESCRIPTIONS,
|
|
3463
|
+
SILENCE_VALUE_DESCRIPTIONS,
|
|
3464
|
+
EDITOR_COPY,
|
|
3465
|
+
INLINE_BADGE_COPY,
|
|
3466
|
+
SSML_HOVER_COPY,
|
|
3467
|
+
DEFAULT_LOCALE,
|
|
3468
|
+
OVERLAY_Z_INDEX,
|
|
3469
|
+
SELECTION_OVERLAY_ABOVE_THRESHOLD_LINES,
|
|
3470
|
+
buildSsml,
|
|
3471
|
+
parseSsml,
|
|
3472
|
+
buildPartialSsml,
|
|
3473
|
+
validateSsml,
|
|
3474
|
+
clearSsmlDocument,
|
|
3475
|
+
formatXmlFragment,
|
|
3476
|
+
getEditableRegion,
|
|
3477
|
+
getEditableText,
|
|
3478
|
+
updateEditableText,
|
|
3479
|
+
createSsmlInsertionEdit,
|
|
3480
|
+
findActiveSsmlTags,
|
|
3481
|
+
findSsmlVoiceContext,
|
|
3482
|
+
registerSsmlCompletionProvider,
|
|
3483
|
+
findSsmlHoverTarget,
|
|
3484
|
+
formatSsmlHover
|
|
3485
|
+
};
|
|
3486
|
+
//# sourceMappingURL=chunk-2XJER2BG.mjs.map
|