wsa.js
7 0
Web Speech API ,朗读页面选中的内容
netnr 2019-12-08
var ssu = {
    init: function () {
        var txt = window.getSelection().toString();
        ssu.speech(txt);
    },
    speech: function (txt) {
        if (!txt || txt.trim() == "") {
            txt = "未选择文字";
        }
        var ws = new window.SpeechSynthesisUtterance(txt);
        window.speechSynthesis.speak(ws);
    }
}
ssu.init();
登录写评论