MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / cleanTextForTTS

Function cleanTextForTTS

t/t.ts:102–122  ·  view source on GitHub ↗

清理文本(emoji/不在白名单的符号;合并连续标点)

(text: string)

Source from the content-addressed store, hash-verified

100 "孙悟空": "8d96d5525334476aa67677fb43059dc5", "王琨": "4f201abba2574feeae11e5ebf737859e",
101 "麦辣鸡腿堡": "c293697468924f3089cd9b90520dbc16", "猪八戒": "4313e3ec56f14eb3946630dbdad01059",
102 "夏(中配) 蔚蓝档案": "c5fca4f670214e3cb7fbb9d595552e6e", "蔚蓝档案阿洛娜": "6ec8168d8392467c82358a780b35c5ca",
103 "蔚蓝档案星野": "057265ac020c41a9a91d57c747d3b4c0"
104 };
105}
106
107/** 清理文本(emoji/不在白名单的符号;合并连续标点) */
108function cleanTextForTTS(text: string): string {
109 if (!text) return "";
110 let cleanedText = text;
111 const broadSymbolRegex = new RegExp(
112 "[" +
113 "\u{1F600}-\u{1F64F}" +
114 "\u{1F300}-\u{1F5FF}" +
115 "\u{1F680}-\u{1F6FF}" +
116 "\u{2600}-\u{26FF}" +
117 "\u{2700}-\u{27BF}" +
118 "\u{FE0F}" +
119 "\u{200D}" +
120 "]",
121 "gu"
122 );
123 cleanedText = cleanedText.replace(broadSymbolRegex, "");
124 const whitelistRegex = /[^\u4e00-\u9fa5a-zA-Z0-9\s,。?!、,?!.]/g;
125 cleanedText = cleanedText.replace(whitelistRegex, "");

Callers 1

ttsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected