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();