Skip to content

Instantly share code, notes, and snippets.

@huanggm
Last active September 16, 2019 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huanggm/7c935836587eacbf56ade456b860ce96 to your computer and use it in GitHub Desktop.
Save huanggm/7c935836587eacbf56ade456b860ce96 to your computer and use it in GitHub Desktop.
var ms = new SpeechSynthesisUtterance("ある程度の人数を集めなければいけなかったので、実父の趣味で「祭り」の仲間に大勢来てもらう事が出来ました。そのおかげで、友人は居ませんでしたが、和太鼓の演舞や新郎を簡易のお神輿に乗せて練り歩く等の余興をしてもらう事ができて、とても賑やかな式になりました。 (40歳/女性)");
msg.lang = 'ja-JP';
msg.rate = 0.8;
var list = speechSynthesis.getVoices();
var newlist = list.filter(l => l.lang.indexOf('ja') >= 0)
console.log(newlist)
msg.voice = newlist[0]
window.speechSynthesis.speak(msg);
需要注意Voices中,有些是需要联网的。导致过长的文本朗读不全,并且有BUG,导致不能再次朗读
//speechSynthesis.cancel();
https://recalll.co/?q=javascript%20-%20Chrome%20Speech%20Synthesis%20with%20longer%20texts&type=code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment