@naersen/tts-rich-text 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/config.d.ts +1 -1
- package/dist/core.js +7 -7
- package/package.json +1 -1
package/dist/core/config.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ export declare const ToolConfig: {
|
|
|
66
66
|
readonly label: "忽略读音";
|
|
67
67
|
readonly icon: "editor-ingore";
|
|
68
68
|
readonly type: "ignore";
|
|
69
|
-
readonly deleteMode: "
|
|
69
|
+
readonly deleteMode: "convertToText";
|
|
70
70
|
};
|
|
71
71
|
};
|
|
72
72
|
export type CustomTagType = 'stop' | 'customStop' | 'continue' | 'pinyin' | 'replace' | 'language' | 'ignore';
|
package/dist/core.js
CHANGED
|
@@ -62,7 +62,7 @@ const f = {
|
|
|
62
62
|
label: "忽略读音",
|
|
63
63
|
icon: "editor-ingore",
|
|
64
64
|
type: "ignore",
|
|
65
|
-
deleteMode: f.
|
|
65
|
+
deleteMode: f.CONVERT_TO_TEXT
|
|
66
66
|
}
|
|
67
67
|
}, _ = [
|
|
68
68
|
{ value: "zh", label: "中文" },
|
|
@@ -183,7 +183,7 @@ const pe = [
|
|
|
183
183
|
// { label: '位数读法', func: toPhoneReading },
|
|
184
184
|
{ label: "位数读法", func: F },
|
|
185
185
|
{ label: "口语读法", func: j }
|
|
186
|
-
], k = /[\u0000-\u0008\u000B-\u001F\u007F-\u009F\u00AD\u200B-\u200F\u202A-\u202E\u2060-\u206F\uFE00-\uFE0F\uFEFF\uFFFD\uE000-\uF8FF]/g, z = /[\t\f\v\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g,
|
|
186
|
+
], k = /[\u0000-\u0008\u000B-\u001F\u007F-\u009F\u00AD\u200B-\u200F\u202A-\u202E\u2060-\u206F\uFE00-\uFE0F\uFEFF\uFFFD\uE000-\uF8FF]/g, z = /[\t\f\v\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g, O = {
|
|
187
187
|
"‘": "'",
|
|
188
188
|
"’": "'",
|
|
189
189
|
"‚": "'",
|
|
@@ -216,11 +216,11 @@ const pe = [
|
|
|
216
216
|
"︕": "!",
|
|
217
217
|
"︖": "?"
|
|
218
218
|
}, H = new RegExp(
|
|
219
|
-
`[${Object.keys(
|
|
219
|
+
`[${Object.keys(O).join("")}]`,
|
|
220
220
|
"g"
|
|
221
221
|
), X = (e) => e.replace(/[\uFF21-\uFF3A\uFF41-\uFF5A\uFF10-\uFF19]/g, (n) => String.fromCharCode(n.charCodeAt(0) - 65248)), G = (e) => X(e).replace(/\r\n?/g, `
|
|
222
222
|
`).replace(/[\u2028\u2029]/g, `
|
|
223
|
-
`).replace(k, "").replace(z, " ").replace(H, (n) =>
|
|
223
|
+
`).replace(k, "").replace(z, " ").replace(H, (n) => O[n] || "").replace(/ *\n */g, `
|
|
224
224
|
`).replace(/\n{3,}/g, `
|
|
225
225
|
|
|
226
226
|
`), ge = (e) => {
|
|
@@ -235,10 +235,10 @@ const pe = [
|
|
|
235
235
|
minSegmentLength: 32,
|
|
236
236
|
maxSegmentLength: 64,
|
|
237
237
|
rebalanceRatio: 0.4
|
|
238
|
-
},
|
|
238
|
+
}, L = /[一-鿿㐀-䶿豈- -〿-]/, I = /[。!?!?\.]/, P = /[;;]/, M = /[,,::]/, Y = /[、]/, R = "", S = "", p = (e) => {
|
|
239
239
|
let n = 0;
|
|
240
240
|
for (const t of e)
|
|
241
|
-
n +=
|
|
241
|
+
n += L.test(t) ? 2 : 1;
|
|
242
242
|
return n;
|
|
243
243
|
}, K = (e) => e.replace(/\r/g, "").split(`
|
|
244
244
|
`).map((n) => n.trim()).filter(Boolean).join(" ").replace(/\s+/g, " ").trim(), q = (e) => {
|
|
@@ -251,7 +251,7 @@ const pe = [
|
|
|
251
251
|
}, b = (e) => e.split(R).join(",").split(S).join("."), E = (e, n) => {
|
|
252
252
|
let t = 0;
|
|
253
253
|
for (let o = 0; o < e.length; o += 1)
|
|
254
|
-
if (t +=
|
|
254
|
+
if (t += L.test(e[o]) ? 2 : 1, t >= n)
|
|
255
255
|
return o + 1;
|
|
256
256
|
return e.length;
|
|
257
257
|
}, x = (e, n, t, o, s) => {
|