<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>语音播报</title>
</head>
<body>
<h1>语音播报</h1>
<input id="btn1" type="button" value ="点我" onclick="speak();"/>
</body>
</html>
<script>
function speak()
{
const synth = window.speechSynthesis;
let msg = new SpeechSynthesisUtterance("孙文剑不是一个好人");
msg.lang = "zh-CN"; // 使用的语言:中文
msg.volume = 100; // 声音音量:1
msg.rate = 0.75; // 语速:1
msg.pitch = 100000; // 音高:1、
synth.speak(msg)
}
</script>
js API语音播报笔记
最新推荐文章于 2025-03-12 15:32:18 发布