Untitled
unknown
plain_text
a year ago
2.4 kB
5
Indexable
[ { "isEnabled": true, "name": "旁白/对话", "version": 4, "ruleId": "ttsrv.multi_voice", "author": "TTS Server", "code": "let SpeechRuleJS = {\n\n name: \"旁白/对话\",\n\n id: \"ttsrv.multi_voice\",\n\n author: \"TTS Server\",\n\n version: 4,\n\n tags: { narration: \"旁白\", dialogue: \"对话\", system: \"sys\" },\n\n\n\n handleText(text) {\n\n const list = [];\n\n let tmpStr = \"\";\n\n let endTag = \"narration\";\n\n\n\n text = text.replace(/-ssi/g, \"shi\")\n\n .replace(/Ok Toyeon/g, \"Ohk Toyeon\")\n\n .replace(/Lumian/g, \"Lu-mi-ahn\")\n \n .replace(/tsk/g, \"ticsk\")\n \n .replace(/Tsk/g, \"ticsk\");\n\n\n text.split(\"\").forEach((char, index) => {\n\n tmpStr += char;\n\n\n\n if (char === '“') {\n\n endTag = \"dialogue\";\n\n list.push({ text: tmpStr, tag: \"narration\" });\n\n tmpStr = \"\";\n\n } else if (char === '”') {\n\n endTag = \"narration\";\n\n tmpStr = tmpStr.slice(0, -1);\n\n list.push({ text: tmpStr, tag: \"dialogue\" });\n\n tmpStr = \"\";\n\n } else if (char === '[') {\n\n endTag = \"system\";\n\n list.push({ text: tmpStr, tag: endTag });\n\n tmpStr = \"\";\n\n } else if (char === ']') {\n\n endTag = \"narration\"; // Assuming you want to go back to narration after system\n\n tmpStr = tmpStr.slice(0, -1);\n\n list.push({ text: tmpStr, tag: \"system\" });\n\n tmpStr = \"\";\n\n } else if (index === text.length - 1) {\n\n list.push({ text: tmpStr, tag: endTag });\n\n }\n\n });\n\n\n\n return list;\n\n },\n\n\n\n splitText(text) {\n\n let separatorStr = \"。?? ?!!;;\"\n\n\n\n let list = []\n\n let tmpStr = \"\"\n\n text.split(\"\").forEach((char, index) => {\n\n tmpStr += char\n\n\n\n if (separatorStr.includes(char)) {\n\n list.push(tmpStr)\n\n tmpStr = \"\"\n\n } else if (index === text.length - 1) {\n\n list.push(tmpStr);\n\n }\n\n })\n\n\n\n return list.filter(item => item.replace(/[“”]/g, '').trim().length > 0);\n\n }\n\n};\n\n", "tags": { "narration": "旁白", "dialogue": "对话", "system": "sys" } } ]
Editor is loading...
Leave a Comment