1 语音播报脚本,也可以用来朗读英语
只需要简单的两行程序保存为.vbs,点击打开就可以念诗:
set objTTS = CreateObject("sapi.spvoice") objTTS.speak("问来问去的问题too young too simple,sometimes naive")
使用JS可以调用百度的API:
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>语音测试</title> <script type="text/javascript"> function doTTS(){ var ttsDiv = document.getElementById(‘bdtts_div_id‘); var ttsAudio = document.getElementById(‘tts_autio_id‘); var ttsText = document.getElementById(‘ttsText‘).value; ttsDiv.removeChild(ttsAudio); var au1 = ‘<audio id="tts_autio_id" autoplay="autoplay">‘; var sss = ‘<source id="tts_source_id" src="http://tts.baidu.com/text2audio?lan=zh&ie=UTF-8&spd=3&text=‘+ttsText+‘" type="audio/mpeg">‘; var eee = ‘<embed id="tts_embed_id" height="0" width="0" src="">‘; var au2 = ‘</audio>‘; ttsDiv.innerHTML = au1 + sss + eee + au2; ttsAudio = document.getElementById(‘tts_autio_id‘); ttsAudio.play(); } </script> </head> <body> <div> <input type="text" id="ttsText"> <input type="button" id="tts_btn" onclick="doTTS()" value="播放"> </div> <div id="bdtts_div_id"> <audio id="tts_autio_id" autoplay="autoplay"> <source id="tts_source_id" src="http://tts.baidu.com/text2audio?lan=zh&ie=UTF-8&spd=1&text=播报内容" type="audio/mpeg"> <embed id="tts_embed_id" height="0" width="0" src=""> </audio> </div> </body> </html>
时间: 2024-11-04 20:48:43