jing332 / tts-server-android

这是一个Android系统TTS应用,内置微软演示接口,可自定义HTTP请求,可导入其他本地TTS引擎,以及根据中文双引号的简单旁白/对话识别朗读 ,还有自动重试,备用配置,文本替换等更多功能。
3.02k stars 242 forks source link

单人朗读规则 #163

Closed atengya closed 5 months ago

atengya commented 5 months ago

个人使用过程中,不喜欢对话规则,仿写了一个处理脚本,给小白使用,用了半个小时,没出什么问题

let SpeechRuleJS = {  
    name: "我的脚本",  
    id: "ttsrv.myjs",  
    author: "guoteng",  
    version: 4,  
    tags: {all: "所有"},  

    handleText: function(text) {  
        // 设计用来将文本按照句号分割。  
        const list = [];  
        let tmpStr = "";  
        let endTag = "all";  
        let separatorStr = "。??!!;;";  

        for (let i = 0; i < text.length; i++) {  
            tmpStr += text[i];  
            if (separatorStr.includes(text[i])) {  
                list.push({text: tmpStr, tag: "all"});  
                tmpStr = "";  
            } else if (i === text.length - 1) {  
                list.push({text: tmpStr, tag: endTag});  
            }  
        }  
        return list;  
    },  

    splitText: function(text) {  
        let separatorStr = ",,";  
        let list = [];  
        let tmpStr = "";  

        for (let i = 0; i < text.length; i++) {  
            tmpStr += text[i];  
            if (separatorStr.includes(text[i])) {  
                list.push(tmpStr);  
                tmpStr = "";  
            } else if (i === text.length - 1) {  
                list.push(tmpStr);  
            }  
        }  
        return list.filter(item => item.replace(/[“”]/g, '').trim() !== '');  
    }  
};
jing332 commented 5 months ago

??? 有朗读全部了,用这个脚本有啥意义吗

atengya commented 5 months ago

哦,原来已经有了吗,我自己找了好久没找到开关。