1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<!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>
<span>123123</span>
</body>
</html>

<script>
const synth = window.speechSynthesis;
let utterThis = new SpeechSynthesisUtterance();
utterThis.volume = 1; // 声音的音量 范围是0到1
utterThis.rate = 0.7; //语速,数值,默认值是1,范围是0.1到10
function AddVoice(text) {
let utterance = new SpeechSynthesisUtterance(text);
synth.speak(utterance);
}
AddVoice("您有新的消息,请注意查收")
</script>