SpeechSynthesisUtterance是HTML5中新增的API用于将指定文字合成为对应的语音。button onclickplay()朗读/button script var utterThis new SpeechSynthesisUtterance(); utterThis.text hello word; utterThis.volume 1; // 声音的音量 范围是0到1 utterThis.rate 0.7; //语速数值默认值是1范围是0.1到10 mutterThisg.pitch 0; // 音高数值范围从0最小到2最大。默认值为1 function play() { speechSynthesis.speak(utterThis); } /script
网页实现文字转语音朗读功能
SpeechSynthesisUtterance是HTML5中新增的API用于将指定文字合成为对应的语音。button onclickplay()朗读/button script var utterThis new SpeechSynthesisUtterance(); utterThis.text hello word; utterThis.volume 1; // 声音的音量 范围是0到1 utterThis.rate 0.7; //语速数值默认值是1范围是0.1到10 mutterThisg.pitch 0; // 音高数值范围从0最小到2最大。默认值为1 function play() { speechSynthesis.speak(utterThis); } /script