通过jiavascript将文本内容转化为语音播放,代码如下:
<body>
<button onclick="start()">点击</button>
<script>
var text = '语音输入开始'
var msg = new SpeechSynthesisUtterance(text)
function start () {
msg.value = 2 // 音量
msg.rate = 0.8 // 语速
window.speechSynthesis.speak(msg)
}
</script>
</body>