系统语音播报功能

181 阅读1分钟
  if ('speechSynthesis' in window) {
  var msg = new SpeechSynthesisUtterance();
  msg.text = '你好,欢迎使用语音播报功能';
  msg.lang = 'zh-CN';
  msg.volume = 1; // 音量范围从0到1
  msg.rate = 1; // 语速范围从0.1到10
  msg.pitch = 1; // 音调范围从0到2
  speechSynthesis.speak(msg);
} else {
  console.log('浏览器不支持Web Speech API');
}