jsp页面增加语音播报
//调用百度语音接口需联网 http://tts.baidu.com/text2audio?lan=zh&ie=UTF-8&spd=5&text='你好'
//js调用客户端语音功能,无需联网,亲测IE8可用 //初始化ActiveX插件,并创建隐藏域,此种方法需打开IE ActiveX功能,启用 <script LANGUAGE="JavaScript"> // Create the Sapi SpVoice object var VoiceObj = new ActiveXObject("Sapi.SpVoice"); function SpeakText() { try { VoiceObj.Speak(idTextBox.value, 2); } catch(exception) { console.log("Speak error"); } } </script> <textarea style="display:none" id="idTextBox" >测试语音</textarea> <button style="display:none" id="idbSpeakText" onclick="SpeakText()"></button> //赋值并播放语音 idTextBox.value=content; $("#idbSpeakText").click();