Open Silence-dream opened 1 year ago
<!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> <button onclick="press()">点击我</button> <script> function press() { const text = "你好"; const utterance = new SpeechSynthesisUtterance(text); utterance.lang = "en"; // 语言 utterance.rate = 1; utterance.pitch = 1; window.speechSynthesis.speak(utterance); } </script> </body> </html>