美文网首页
前端 文字转语音

前端 文字转语音

作者: 西木木亢 | 来源:发表于2019-12-12 16:36 被阅读0次
Vue.prototype.$speak = (textToSpeak) => {
  var u = new SpeechSynthesisUtterance();
  u.text = textToSpeak;
  //汉语
  u.lang = 'zh';
  u.rate = 1;
  speechSynthesis.speak(u);
  //部分浏览器的播放页需要有用户交互,才能正常播放
  //没有用户交互需要在Chrome中 chrome://settings/content/sound 
  //中添加网站域名 才能播放
}

相关文章

网友评论

      本文标题:前端 文字转语音

      本文链接:https://www.haomeiwen.com/subject/imytnctx.html