<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<button onclick="speak();">在线听故事</button>
<button onclick="zhanting();">暂停</button>
<button onclick="stop();">停止</button>
<button onclick="comon();">继续</button>
<div id="txt" style="visibility:hidden; ">
</div>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script>
var mess = $("#txt").text()
function zhanting(mess) {
window.speechSynthesis.pause(mess);
}
function stop(mess) {
window.speechSynthesis.cancel(mess);
}
function comon(mess) {
window.speechSynthesis.resume(mess);
}
function speak(mess) {
var mess = $("#txt").text()
var msg = new SpeechSynthesisUtterance(mess)
msg.volume = 100
msg.rate = 1
msg.pitch = 1.5
speechSynthesis.speak(msg);
}
</script>
</body>
</html>