浏览器 文本发音
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<input id="ipt" type="text"></input>
<button id="btn">发音</button>
<script>
const btn = document.getElementById('btn')
const ipt = document.getElementById('ipt')
btn.onclick = function(){
const value = ipt.value;
const ssa = new SpeechSynthesisUtterance(value);
ssa.lang = 'zh-CN';
ssa.rate = 1;
ssa.volume = 1;
window.speechSynthesis.speak(ssa);
}
</script>
</body>
</html>